I think that in general, the best way to read data is to use a
parser, generated by
a parser generator (for example bison or antlr).
the following grammar will read a single vector of integers:
vector : vectorbegin intlist '\n' { YYACCEPT; }
;
vectorbegin : {vector_buffer.clear(); }
;
intlist: INTEGER { vector_buffer.push_back($1); }
| intlist ',' INTEGER {vector_buffer.push_back($3); }
;
Here I've assumed that vector_buffer is a global std::vector<int>,
which will contain
the vector read when the parser returns.
Doubles can be handled in a similar way.
Dec 26, 2005 kl. 7:11 AM skrev Ivan Adzhubey:
Hi,
What is the best way to read vector/matrix data from a file? The
gsl_*_fscanf() family og functions surprisingly lack the format
specification
parameter and nothing in the documentation hints on how they really
work. I
have pre-generated sets of vectors stored in text files in the
following
simple format:
1,2,3,4,5,10
2,2,4,5,6,20
...
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.
Next step would be to replace text files as an input source with
the database,
Postgresql in my case, since I need to process very large data
sets, e.g.
ranging from 100,000 to 100,000,000 of sample vectors. I appreciate
if anyone
with the similar experience would share it.
TIA,
Ivan
_______________________________________________
Help-gsl mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gsl
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
_______________________________________________
Help-gsl mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gsl