*/
void print (ostream &out) const;
+ /**
+ * Print the matrix in the usual format,
+ * i.e. as a matrix and not as a list of
+ * nonzero elements. For better
+ * readability, elements not in the matrix
+ * are displayed as empty space, while
+ * matrix elements which are explicitely
+ * set to zero are displayed as such.
+ *
+ * Each entry is printed as a six character
+ * wide field, with one space following.
+ *
+ * You should be aware that this function
+ * may produce {\bf large} amounts of
+ * output if applied to a large matrix!
+ * Be careful with it.
+ */
+ void print_formatted (ostream &out) const;
+
/**
* Exception
*/
// Roland Becker, Guido Kanschat, Franz-Theo Suttmeier
#include <lac/dsmatrix.h>
-#include <ostream.h>
-
+#include <iostream>
+#include <iomanip>
/*----------------- from sort.h -------------------------*/
for (unsigned int j=cols->rowstart[i]; j<cols->rowstart[i+1]; ++j)
out << "(" << i << "," << cols->colnums[j] << ") " << val[j] << endl;
};
+
+
+
+void dSMatrix::print_formatted (ostream &out) const {
+ for (unsigned int i=0; i<m(); ++i)
+ {
+ for (unsigned int j=0; j<n(); ++j)
+ if ((*cols)(i,j) != -1)
+ out << setw(6) << val[cols->operator()(i,j)] << " ";
+ else
+ out << " ";
+ out << endl;
+ };
+};