GNU Scientific Library – Reference Manual: Sparse Matrices Conversion Between Sparse and Dense

Next: Sparse Matrices Examples, Previous: Sparse Matrices Compressed Format, Up: Sparse Matrices [Index]

### 41.12 Conversion Between Sparse and Dense Matrices

The `gsl_spmatrix` structure can be converted into the dense `gsl_matrix` format and vice versa with the following routines.

Function: int gsl_spmatrix_d2sp (gsl_spmatrix * S, const gsl_matrix * A)

  This function converts the dense matrix A into sparse triplet format and stores the result in S.

Function: int gsl_spmatrix_sp2d (gsl_matrix * A, const gsl_spmatrix * S)

  This function converts the sparse matrix S into a dense matrix and stores the result in A. S must be in triplet format.