help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gsl] Reading vectors and matrices from text files


From: Ivan Adzhubey
Subject: Re: [Help-gsl] Reading vectors and matrices from text files
Date: Wed, 28 Dec 2005 15:53:59 -0500
User-agent: KMail/1.8.1

Hi James,

On Tuesday 27 December 2005 10:07 am, address@hidden wrote:
> Quoting Ivan Adzhubey <address@hidden>:
> > What is the best way to read vector/matrix data from a file? The
>
> ...
>
> > i.e., one vector per line, comma-separated vector elements. The idea is
> > to read the whole block of data in and then loop over it (creating vector
> > views?) doing calculations.
>
> Hi Ivan,
>
> You are right that GSL has a very minimal I/O.  It isn't so much for
> reading data in <your> format, as providing a quick way to dump stuff to
> file and then read it back.  

I sort of figured it out myself but some hints in the documentation would be 
nice, don't you think?

> The idea is to use routines like getline(), 
> strtod(), strchr(), scanf() and so on to get the job done.

Have it working now with a simple fgets()/sscanf() loop. It's really for 
testing purposes only, now I need to add Postgresql bindings for the real 
thing.

I also tried to benchmark GSL a bit with my own code and was surprised to see 
it only marginally (e.g. 50%) faster than R (www.r-project.org), which I use 
routinely. The main goal of recoding my vector functions in C/GSL was to have 
things calculate faster but it seems it's not gonna happen ;-(. Now, R being 
an interpreted language, still uses BLAS hooks to do all matrix arithmetic so 
I probably should not be expecting too much improvement in speed.

Thanks!

-- 
Ivan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]