<h3>lac</h3>
<ol>
+ <li> <p>Improved: A simple <code class="member">print_formatted</code>
+ function has been added to <code class="class">SparseMatrixEZ</code>.
+ <br>
+ (Moritz Allmaras 2007/02/08)
+ </p>
+
<li> <p>Fixed: The <code class="class">SparseDirectMA27</code>
class works for symmetric matrices and had a check to make sure the
matrix is indeed symmetric. However, the check compared entries for
* may produce @em large amounts of
* output if applied to a large matrix!
*/
-// void print_formatted (std::ostream &out,
-// const unsigned int precision = 3,
-// const bool scientific = true,
-// const unsigned int width = 0,
-// const char *zero_string = " ",
-// const double denominator = 1.) const;
+ void print_formatted (std::ostream &out,
+ const unsigned int precision = 3,
+ const bool scientific = true,
+ const unsigned int width = 0,
+ const char *zero_string = " ",
+ const double denominator = 1.) const;
/**
* Write the data of this object
#include <lac/vector.h>
#include <iostream>
+#include <iomanip>
#include <algorithm>
#include <cmath>
}
+template <typename number>
+void
+SparseMatrixEZ<number>::print_formatted ( std::ostream &out,
+ const unsigned int precision,
+ const bool scientific,
+ const unsigned int width_,
+ const char* zero_string,
+ const double denominator) const
+{
+ AssertThrow (out, ExcIO());
+ Assert (m() != 0, ExcNotInitialized());
+ Assert (n() != 0, ExcNotInitialized());
+
+ unsigned int width = width_;
+
+ std::ios::fmtflags old_flags = out.flags();
+ unsigned int old_precision = out.precision (precision);
+
+ if (scientific)
+ {
+ out.setf (std::ios::scientific, std::ios::floatfield);
+ if (!width)
+ width = precision+7;
+ } else {
+ out.setf (std::ios::fixed, std::ios::floatfield);
+ if (!width)
+ width = precision+2;
+ }
+
+ // TODO: Skip nonexisting entries
+ for (unsigned int i=0; i<m(); ++i)
+ {
+ for (unsigned int j=0; j<n(); ++j)
+ {
+ const Entry* entry = locate(i,j);
+ if (entry)
+ out << std::setw(width)
+ << entry->value * denominator << ' ';
+ else
+ out << std::setw(width) << zero_string << ' ';
+ }
+ out << std::endl;
+ };
+
+ // reset output format
+ out.precision(old_precision);
+ out.flags (old_flags);
+}
+
+
template <typename number>
void
SparseMatrixEZ<number>::block_write (std::ostream &out) const