GenSVM
gensvm_debug.c
Go to the documentation of this file.
1 
30 #include "gensvm_debug.h"
31 
42 void gensvm_print_matrix(double *M, long rows, long cols)
43 {
44  long i, j;
45 
46  for (i=0; i<rows; i++) {
47  for (j=0; j<cols; j++) {
48  if (j > 0)
49  note(" ");
50  note("%+6.6f", matrix_get(M, cols, i, j));
51  }
52  note("\n");
53  }
54  note("\n");
55 }
56 
67 {
68  long i;
69 
70  // print matrix dimensions
71  note("Sparse Matrix:\n");
72  note("\tnnz = %li, rows = %li, cols = %li\n", A->nnz, A->n_row,
73  A->n_col);
74 
75  // print nonzero values
76  note("\tvalues = [ ");
77  for (i=0; i<A->nnz; i++) {
78  if (i != 0) note(", ");
79  note("%f", A->values[i]);
80  }
81  note(" ]\n");
82 
83  // print row indices
84  note("\tIA = [ ");
85  for (i=0; i<A->n_row+1; i++) {
86  if (i != 0) note(", ");
87  note("%i", A->ia[i]);
88  }
89  note(" ]\n");
90 
91  // print column indices
92  note("\tJA = [ ");
93  for (i=0; i<A->nnz; i++) {
94  if (i != 0) note(", ");
95  note("%i", A->ja[i]);
96  }
97  note(" ]\n");
98 }
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
Header file for gensvm_debug.c.
#define matrix_get(M, cols, i, j)
void gensvm_print_matrix(double *M, long rows, long cols)
Print a dense matrix.
Definition: gensvm_debug.c:42
long nnz
number of nonzero elements
Definition: gensvm_sparse.h:56
void gensvm_print_sparse(struct GenSparse *A)
Print a sparse matrix.
Definition: gensvm_debug.c:66
double * values
actual nonzero values, should be of length nnz
Definition: gensvm_sparse.h:63
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
void note(const char *fmt,...)
Parse a formatted string and write to the output stream.
Definition: gensvm_print.c:62
long n_row
number of rows of the original matrix
Definition: gensvm_sparse.h:58