aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gensvm_debug.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/gensvm_debug.c b/src/gensvm_debug.c
index f4b4151..632bf73 100644
--- a/src/gensvm_debug.c
+++ b/src/gensvm_debug.c
@@ -12,7 +12,7 @@
#include "gensvm_debug.h"
/**
- * @brief print a matrix
+ * @brief Print a dense matrix
*
* @details
* Debug function to print a matrix
@@ -35,3 +35,46 @@ void gensvm_print_matrix(double *M, long rows, long cols)
}
note("\n");
}
+
+/**
+ * @brief Print a sparse matrix
+ *
+ * @details
+ * Debug function to print a GenSparse sparse matrix
+ *
+ * @param[in] A a GenSparse matrix to print
+ *
+ */
+void gensvm_print_sparse(struct GenSparse *A)
+{
+ long i;
+
+ // print matrix dimensions
+ note("Sparse Matrix:\n");
+ note("\tnnz = %li, rows = %li, cols = %li\n", A->nnz, A->n_row,
+ A->n_col);
+
+ // print nonzero values
+ note("\tvalues = [ ");
+ for (i=0; i<A->nnz; i++) {
+ if (i != 0) note(", ");
+ note("%f", A->values[i]);
+ }
+ note(" ]\n");
+
+ // print row indices
+ note("\tIA = [ ");
+ for (i=0; i<A->n_row+1; i++) {
+ if (i != 0) note(", ");
+ note("%i", A->ia[i]);
+ }
+ note(" ]\n");
+
+ // print column indices
+ note("\tJA = [ ");
+ for (i=0; i<A->nnz; i++) {
+ if (i != 0) note(", ");
+ note("%i", A->ja[i]);
+ }
+ note(" ]\n");
+}