data input/output for programs using GSL
Tribulations Parallèles
paratribulations@free.fr
Sat Nov 12 16:16:00 GMT 2005
Hi everybody,
I just discover GSL. I am not an expert in numerical analysis.
I just wonder how reading and writing data (vectors and matrices) in files.
In the chapter 9 of the documentation, some functions are presented, but we
learn here that "it may not be portable between different architectures".
Moreover, for example we must know the size of the vector, before using
gsl_vector_fread. To my mind, these two aspects are rather annoying.
Why not having functions that read in files and place the scalars, vectors,
and matrices in a convenient structure named entities:
struct gsl_vector_with_name
{
char * name;
gsl_vector foo; // Or a pointer, as you want
};
struct gsl_matrix_with_name
{
char * name;
gsl_matrix foo;
};
struct entities
{
gsl_vector_with_name * vectors;
gsl_matrix_with_name * matrices;
};
So after file reading, vectors pointer could be empty (so still equal to NULL
if initialized to NULL) if there were only matrices in the file. I have only
treated the case of matrices and vectors here.
The fied name would be the name of the vector or matrix in the file, as saved
by the user. The same name that we encounter in Matlab/Octave/Scilab after we
type 'load data.mat' (given by command 'who' in the workspace). There would
be two types of storage:
- binary: a format as Matlab .mat one (understood by Octave, and perhaps
Scilab, I don't remember).
- ascii: an explicit storage, readable by the user. Rather Matlab oriented:
a=[5 4 7]; % Line-vector
b=[3
4
7]; % Column-vector
c=[5 6 7
3 4 5]; % Matrix
So it would be possible to use the same data files in Matlab/Octave/Scilab and
GSL, it would be rather convenient.
What do you think of that? It is just an idea, perhaps I'm wrong. How do you
manage I/O in your programs?
Julien
More information about the Gsl-discuss
mailing list