Next: , Previous: Sparse Matrices Initializing Elements, Up: Sparse Matrices   [Index]


41.5 Reading and Writing Matrices

Function: int gsl_spmatrix_fwrite (FILE * stream, const gsl_spmatrix * m)

This function writes the elements of the matrix m to the stream stream in binary format. The return value is 0 for success and GSL_EFAILED if there was a problem writing to the file. Since the data is written in the native binary format it may not be portable between different architectures.

Function: int gsl_spmatrix_fread (FILE * stream, gsl_spmatrix * m)

This function reads into the matrix m from the open stream stream in binary format. The matrix m must be preallocated with the correct storage format, dimensions and have a sufficiently large nzmax in order to read in all matrix elements, otherwise GSL_EBADLEN is returned. The return value is 0 for success and GSL_EFAILED if there was a problem reading from the file. The data is assumed to have been written in the native binary format on the same architecture.

Function: int gsl_spmatrix_fprintf (FILE * stream, const gsl_spmatrix * m, const char * format)

This function writes the elements of the matrix m line-by-line to the stream stream using the format specifier format, which should be one of the %g, %e or %f formats for floating point numbers. The function returns 0 for success and GSL_EFAILED if there was a problem writing to the file. The input matrix m may be in any storage format, and the output file will be written in MatrixMarket format.

Function: gsl_spmatrix * gsl_spmatrix_fscanf (FILE * stream)

This function reads sparse matrix data in the MatrixMarket format from the stream stream and stores it in a newly allocated matrix which is returned in triplet format. The function returns 0 for success and GSL_EFAILED if there was a problem reading from the file. The user should free the returned matrix when it is no longer needed.


Next: , Previous: Sparse Matrices Initializing Elements, Up: Sparse Matrices   [Index]