From: kanschat Date: Wed, 2 Aug 2006 17:42:32 +0000 (+0000) Subject: add print function X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=94edbca05f1bd1b8d8527045b036ee450a46a845;p=dealii-svn.git add print function git-svn-id: https://svn.dealii.org/trunk@13575 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/tridiagonal_matrix.h b/deal.II/lac/include/lac/tridiagonal_matrix.h index 51ecfd59e4..db6609dc71 100644 --- a/deal.II/lac/include/lac/tridiagonal_matrix.h +++ b/deal.II/lac/include/lac/tridiagonal_matrix.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2005 by the deal.II authors +// Copyright (C) 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -18,6 +18,7 @@ #include #include +#include // forward declarations template class Vector; @@ -256,52 +257,11 @@ class TridiagonalMatrix * Output of the matrix in * user-defined format. */ - void print (std::ostream &s, + template + void print (OUT& s, const unsigned int width=5, const unsigned int precision=2) 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 explicitly - * set to zero are displayed as - * such. - * - * The parameters allow for a - * flexible setting of the output - * format: precision and - * scientific are used to - * determine the number format, - * where scientific = false - * means fixed point notation. A - * zero entry for width makes - * the function compute a width, - * but it may be changed to a - * positive value, if output is - * crude. - * - * Additionally, a character for - * an empty value may be - * specified. - * - * Finally, the whole matrix can - * be multiplied with a common - * denominator to produce more - * readable output, even - * integers. - */ - void print_formatted (std::ostream &out, - const unsigned int presicion=3, - const bool scientific = true, - const unsigned int width = 0, - const char *zero_string = " ", - const double denominator = 1.) const; - /** * Determine an estimate for the * memory consumption (in bytes) @@ -401,6 +361,31 @@ TridiagonalMatrix::operator()(unsigned int i, unsigned int j) } +template +template +void +TridiagonalMatrix::print ( + OUT& s, + const unsigned int width, + const unsigned int) const +{ + for (unsigned int i=0;i0) + s << std::setw(width) << (*this)(i,i-1); + else + s << std::setw(width) << ""; + + s << ' ' << (*this)(i,i) << ' '; + + if (i