aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGertjan van den Burg <burg@ese.eur.nl>2016-10-17 12:07:41 +0200
committerGertjan van den Burg <burg@ese.eur.nl>2016-10-17 12:08:26 +0200
commit7004385c7204586ec3bbfdd4f4f46ee858a13892 (patch)
tree615fe43716f2a5183528bf2771521ac53a0d3b24 /src
parentremove temporary test seed setting (diff)
downloadgensvm-7004385c7204586ec3bbfdd4f4f46ee858a13892.tar.gz
gensvm-7004385c7204586ec3bbfdd4f4f46ee858a13892.zip
Create debug function for printing GenSparse structs
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");
+}