]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Finish support for formatted output.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 15 Apr 1998 12:04:27 +0000 (12:04 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 15 Apr 1998 12:04:27 +0000 (12:04 +0000)
git-svn-id: https://svn.dealii.org/trunk@174 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/dsmatrix.h
deal.II/lac/source/dsmatrix.cc

index 7ee18cddb58f4a8a3e60ac438198dca51764fd65..d8eef99fd68bafdb92edf7f74a22dbb71a081cd4 100644 (file)
@@ -329,15 +329,24 @@ class dSMatrix
                                      * 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.
+                                     * 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;
+    void print_formatted (ostream &out,
+                         const unsigned int presicion=3) const;
     
                                     /**
                                      * Exception
index fadb3854d109db1fdf7baa9e5ba430c071894e78..be393ca0a1c799bd2147bfbdaf3fb9af8e517909 100644 (file)
@@ -628,14 +628,20 @@ void dSMatrix::print (ostream &out) const {
 
 
 
-void dSMatrix::print_formatted (ostream &out) const {
+void dSMatrix::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<m(); ++i) 
     {
       for (unsigned int j=0; j<n(); ++j)
        if ((*cols)(i,j) != -1)
-         out << setw(6) << val[cols->operator()(i,j)] << " ";
+         out << setw(precision+7)
+             << val[cols->operator()(i,j)] << ' ';
        else
-         out << "       ";
+         out << setw(precision+8) << " ";
       out << endl;
     };
+
+  out.setf (0, ios::floatfield);                 // reset output format
 };

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.