GenSVM
gensvm_sparse.h
Go to the documentation of this file.
1 
30 #ifndef GENSVM_SPARSE_H
31 #define GENSVM_SPARSE_H
32 
33 // includes
34 #include "gensvm_globals.h"
35 
36 // type declarations
37 
55 struct GenSparse {
56  long nnz;
58  long n_row;
60  long n_col;
62 
63  double *values;
65  long *ia;
67  long *ja;
69 };
70 
71 struct GenSparse *gensvm_init_sparse(void);
72 void gensvm_free_sparse(struct GenSparse *sp);
73 long gensvm_count_nnz(double *A, long rows, long cols);
74 bool gensvm_nnz_comparison(long nnz, long rows, long cols);
75 bool gensvm_could_sparse(double *A, long rows, long cols);
76 struct GenSparse *gensvm_dense_to_sparse(double *A, long rows, long cols);
77 double *gensvm_sparse_to_dense(struct GenSparse *A);
78 
79 #endif
long * ja
column indices, should be of length nnz
Definition: gensvm_sparse.h:67
long n_col
number of columns of the original matrix
Definition: gensvm_sparse.h:60
void gensvm_free_sparse(struct GenSparse *sp)
Free an allocated GenSparse structure.
Definition: gensvm_sparse.c:62
long nnz
number of nonzero elements
Definition: gensvm_sparse.h:56
bool gensvm_nnz_comparison(long nnz, long rows, long cols)
Compare the number of nonzeros is such that sparsity if worth it.
Global definitions.
double * values
actual nonzero values, should be of length nnz
Definition: gensvm_sparse.h:63
long gensvm_count_nnz(double *A, long rows, long cols)
Count the number of nonzeros in a matrix.
Definition: gensvm_sparse.c:84
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.
Definition: gensvm_sparse.c:38
long * ia
cumulative row lengths, should be of length n_row+1
Definition: gensvm_sparse.h:65
A structure to represent a sparse matrix in CSR format.
Definition: gensvm_sparse.h:55
long n_row
number of rows of the original matrix
Definition: gensvm_sparse.h:58