30 #ifndef GENSVM_SPARSE_H 31 #define GENSVM_SPARSE_H long * ja
column indices, should be of length nnz
long n_col
number of columns of the original matrix
void gensvm_free_sparse(struct GenSparse *sp)
Free an allocated GenSparse structure.
long nnz
number of nonzero elements
bool gensvm_nnz_comparison(long nnz, long rows, long cols)
Compare the number of nonzeros is such that sparsity if worth it.
double * values
actual nonzero values, should be of length nnz
long gensvm_count_nnz(double *A, long rows, long cols)
Count the number of nonzeros in a matrix.
double * gensvm_sparse_to_dense(struct GenSparse *A)
Convert a GenSparse structure to a dense matrix.
struct GenSparse * gensvm_dense_to_sparse(double *A, long rows, long cols)
Convert a dense matrix to a GenSparse structure if advantageous.
bool gensvm_could_sparse(double *A, long rows, long cols)
Check if it is worthwile to convert to a sparse matrix.
struct GenSparse * gensvm_init_sparse(void)
Initialize a GenSparse structure.
long * ia
cumulative row lengths, should be of length n_row+1
A structure to represent a sparse matrix in CSR format.
long n_row
number of rows of the original matrix