From 2e24d4df7451dccc413197f265a540ae3d60d8a3 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 27 Apr 1998 09:32:59 +0000 Subject: [PATCH] Add output function. git-svn-id: https://svn.dealii.org/trunk@200 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/dfmatrix.h | 26 ++++++++++++++++++++++++++ deal.II/lac/source/dfmatrix.cc | 27 +++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/deal.II/lac/include/lac/dfmatrix.h b/deal.II/lac/include/lac/dfmatrix.h index 82c9ecde43..54306adf01 100644 --- a/deal.II/lac/include/lac/dfmatrix.h +++ b/deal.II/lac/include/lac/dfmatrix.h @@ -361,6 +361,32 @@ class dFMatrix * Output of the matrix in user-defined format. */ void print (FILE* fp, const char* format = 0) const; + + /** + * Print the matrix in the usual format, + * i.e. as a matrix and not as a list of + * nonzero elements. For better + * readability, zero elements + * are displayed as empty space. + * + * Each entry is printed in scientific + * format, with one pre-comma digit and + * the number of digits given by + * #precision# after the comma, with one + * space following. + * The precision defaults to four, which + * suffices for most cases. The precision + * and output format are {\it not} + * properly reset to the old values + * when the function exits. + * + * 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 unsigned int presicion=3) const; //@} /** diff --git a/deal.II/lac/source/dfmatrix.cc b/deal.II/lac/source/dfmatrix.cc index c2e943d0ac..dd42cbabed 100644 --- a/deal.II/lac/source/dfmatrix.cc +++ b/deal.II/lac/source/dfmatrix.cc @@ -1,10 +1,10 @@ // $Id$ -#include -#include -#include +#include +#include +#include #include - +#include @@ -980,3 +980,22 @@ void dFMatrix::invert (const dFMatrix &M) { }; }; + + +void dFMatrix::print_formatted (ostream &out, const unsigned int precision) const { + out.precision (precision); + out.setf (ios::scientific, ios::floatfield); // set output format + + for (unsigned int i=0; i