std::complex<number>
eigenvalue (unsigned int i) const;
+ /**
+ * Print the matrix and allow
+ * formatting of entries.
+ *
+ * The parameters allow for a
+ * flexible setting of the output
+ * format:
+ *
+ * @arg <tt>precision</tt>
+ * denotes the number of trailing
+ * digits.
+ *
+ * @arg <tt>scientific</tt> is
+ * used to determine the number
+ * format, where
+ * <tt>scientific</tt> =
+ * <tt>false</tt> means fixed
+ * point notation.
+ *
+ * @arg <tt>width</tt> denotes
+ * the with of each column. A
+ * zero entry for <tt>width</tt>
+ * makes the function compute a
+ * width, but it may be changed
+ * to a positive value, if output
+ * is crude.
+ *
+ * @arg <tt>zero_string</tt>
+ * specifies a string printed for
+ * zero entries.
+ *
+ * @arg <tt>denominator</tt>
+ * Multiply the whole matrix by
+ * this common denominator to get
+ * nicer numbers.
+ *
+ * @arg <tt>threshold</tt>: all
+ * entries with absolute value
+ * smaller than this are
+ * considered zero.
+ */
+ 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 double threshold = 0.) const;
+
private:
/**
* Since LAPACK operations
const unsigned int src_offset_i,
const unsigned int src_offset_j)
{
- const unsigned int endrow = src_offset_i + this->m();
- const unsigned int endcol = src_offset_j + this->n();
-
- for (unsigned int i=0;i<this->m();++i)
+ const unsigned int endrow = this->n_rows() - dst_offset_i;
+ const unsigned int endcol = src_offset_j + this->n_cols();
+
+ const typename MATRIX::const_iterator
+ end = M.end(src_offset_i+n_rows()-dst_offset_i-1);
+ for (typename MATRIX::const_iterator entry = M.begin(src_offset_i);
+ entry != end; ++entry)
{
- const typename MATRIX::const_iterator end = M.end(src_offset_i+i);
- for (typename MATRIX::const_iterator entry = M.begin(src_offset_i+i);
- entry != end; ++entry)
- if (entry->column() < endcol)
- this->el(dst_offset_i+i,
- dst_offset_j+entry->column()-src_offset_j)
- = entry->value();
+ const unsigned int i = entry->row();
+ const unsigned int j = entry->column();
+
+ if (j >= src_offset_j && j < endcol)
+ this->operator()(dst_offset_i-src_offset_i+i,
+ dst_offset_j-src_offset_j+j)
+ = entry->value();
}
state = LAPACKSupport::matrix;
#include <lac/vector.h>
#include <iostream>
+#include <iomanip>
using namespace LAPACKSupport;
Tvmult(w, v, true);
}
+template <typename number>
+void
+LAPACKFullMatrix<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 double threshold) const
+{
+ unsigned int width = width_;
+
+ Assert ((!this->empty()) || (this->n_cols()+this->n_rows()==0),
+ ExcInternalError());
+
+ // set output format, but store old
+ // state
+ 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;
+ }
+
+ for (unsigned int i=0; i<n_rows(); ++i)
+ {
+ for (unsigned int j=0; j<n_cols(); ++j)
+ if (std::fabs(this->el(i,j)) > threshold)
+ out << std::setw(width)
+ << this->el(i,j) * denominator << ' ';
+ else
+ out << std::setw(width) << zero_string << ' ';
+ out << std::endl;
+ };
+
+ AssertThrow (out, ExcIO());
+ // reset output format
+ out.flags (old_flags);
+ out.precision(old_precision);
+}
+
template class LAPACKFullMatrix<double>;
template LAPACKFullMatrix<double> &