From: Wolfgang Bangerth Date: Wed, 15 Apr 1998 10:03:44 +0000 (+0000) Subject: Add formatted print function to sparse matrices. X-Git-Tag: v8.0.0~23081 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8856d41e11fa88abe8c1dcd836ac3321cebd7155;p=dealii.git Add formatted print function to sparse matrices. git-svn-id: https://svn.dealii.org/trunk@173 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/dsmatrix.h b/deal.II/lac/include/lac/dsmatrix.h index 8dbfba49ff..7ee18cddb5 100644 --- a/deal.II/lac/include/lac/dsmatrix.h +++ b/deal.II/lac/include/lac/dsmatrix.h @@ -320,6 +320,25 @@ class dSMatrix */ 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 */ diff --git a/deal.II/lac/source/dsmatrix.cc b/deal.II/lac/source/dsmatrix.cc index 7c73da5cfe..fadb3854d1 100644 --- a/deal.II/lac/source/dsmatrix.cc +++ b/deal.II/lac/source/dsmatrix.cc @@ -5,8 +5,8 @@ // Roland Becker, Guido Kanschat, Franz-Theo Suttmeier #include -#include - +#include +#include /*----------------- from sort.h -------------------------*/ @@ -625,3 +625,17 @@ void dSMatrix::print (ostream &out) const { for (unsigned int j=cols->rowstart[i]; jrowstart[i+1]; ++j) out << "(" << i << "," << cols->colnums[j] << ") " << val[j] << endl; }; + + + +void dSMatrix::print_formatted (ostream &out) const { + for (unsigned int i=0; ioperator()(i,j)] << " "; + else + out << " "; + out << endl; + }; +};