88 for (i=0; i<rows*cols; i++)
89 nnz += (A[i] != 0.0) ? 1 : 0;
107 return (nnz < (rows*(cols-1.0)-1.0)/2.0);
154 long i, j, cnt,
nnz = 0;
170 for (i=0; i<rows; i++) {
172 for (j=0; j<cols; j++) {
181 spA->
ia[i+1] = spA->
ia[i] + row_cnt;
204 for (i=0; i<A->
n_row; i++) {
205 for (jj=A->
ia[i]; jj<A->
ia[i+1]; jj++) {
#define Calloc(type, size)
long * ja
column indices, should be of length nnz
long n_col
number of columns of the original matrix
struct GenSparse * gensvm_init_sparse(void)
Initialize a GenSparse structure.
long gensvm_count_nnz(double *A, long rows, long cols)
Count the number of nonzeros in a matrix.
#define matrix_get(M, cols, i, j)
bool gensvm_nnz_comparison(long nnz, long rows, long cols)
Compare the number of nonzeros is such that sparsity if worth it.
long nnz
number of nonzero elements
Header file for gensvm_sparse.c.
#define Malloc(type, size)
bool gensvm_could_sparse(double *A, long rows, long cols)
Check if it is worthwile to convert to a sparse matrix.
double * values
actual nonzero values, should be of length nnz
void gensvm_free_sparse(struct GenSparse *sp)
Free an allocated GenSparse structure.
struct GenSparse * gensvm_dense_to_sparse(double *A, long rows, long cols)
Convert a dense matrix to a GenSparse structure if advantageous.
#define matrix_set(M, cols, i, j, val)
double * gensvm_sparse_to_dense(struct GenSparse *A)
Convert a GenSparse structure to a dense matrix.
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