34 mu_assert(sp->
nnz == 0,
"nnz not initialized correctly");
38 mu_assert(sp->
ia == NULL,
"ia not initialized correctly");
39 mu_assert(sp->
ja == NULL,
"ja not initialized correctly");
48 double *A =
Calloc(
double, 3*2);
64 double *A =
Calloc(
double, 5*2);
68 "Incorrect could sparse (1)");
71 "Incorrect could sparse (2)");
79 double *A =
Calloc(
double, 4*4);
114 double *A =
Calloc(
double, 4*4);
124 for (i=0; i<4*4; i++)
125 mu_assert(B[i] == A[i],
"Incorrect element of B");
Minimal unit testing framework for C.
#define Calloc(type, size)
long * ja
column indices, should be of length nnz
long n_col
number of columns of the original matrix
#define mu_assert(test, message)
void gensvm_free_sparse(struct GenSparse *sp)
Free an allocated GenSparse structure.
long nnz
number of nonzero elements
Header file for gensvm_sparse.c.
#define mu_run_test(test)
double * values
actual nonzero values, should be of length nnz
char * test_sparse_to_dense()
long gensvm_count_nnz(double *A, long rows, long cols)
Count the number of nonzeros in a matrix.
char * test_gensvm_could_sparse()
char * test_dense_to_sparse()
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.
char * test_init_free_sparse()
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