From d50b34ff69c9f2362258db75411e6c860f085b40 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Sat, 18 Mar 2017 17:50:32 +0100 Subject: [PATCH] Restrict LAPACKFullMatrix::print_formatted to matrix states --- doc/news/changes/incompatibilities/20170318DanielArndt | 4 ++++ include/deal.II/lac/lapack_full_matrix.h | 4 ++++ include/deal.II/lac/lapack_support.h | 9 ++++++--- source/lac/lapack_full_matrix.cc | 3 +++ 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 doc/news/changes/incompatibilities/20170318DanielArndt diff --git a/doc/news/changes/incompatibilities/20170318DanielArndt b/doc/news/changes/incompatibilities/20170318DanielArndt new file mode 100644 index 0000000000..f344ef5ef0 --- /dev/null +++ b/doc/news/changes/incompatibilities/20170318DanielArndt @@ -0,0 +1,4 @@ +Changed: LAPACKFullMatrix::print_formatted is only allowed +if the state is 'matrix' or 'inverse_matrix'. +
+(Daniel Arndt, 2017/03/18) diff --git a/include/deal.II/lac/lapack_full_matrix.h b/include/deal.II/lac/lapack_full_matrix.h index e31861687e..24d80a09a9 100644 --- a/include/deal.II/lac/lapack_full_matrix.h +++ b/include/deal.II/lac/lapack_full_matrix.h @@ -592,6 +592,10 @@ public: * * @arg threshold: all entries with absolute value smaller than * this are considered zero. + * + * @note The entries stored resemble a matrix only if the state is either + * LAPACKSupport::matrix or LAPACK::inverse_matrix. Otherwise, calling this + * function is not allowed. */ void print_formatted (std::ostream &out, const unsigned int precision = 3, diff --git a/include/deal.II/lac/lapack_support.h b/include/deal.II/lac/lapack_support.h index 193c63da11..a507df2c14 100644 --- a/include/deal.II/lac/lapack_support.h +++ b/include/deal.II/lac/lapack_support.h @@ -26,9 +26,12 @@ DEAL_II_NAMESPACE_OPEN namespace LAPACKSupport { /** - * Most LAPACK functions change the contents of the matrix applied to to - * something which is not a matrix anymore. Therefore, LAPACK matrix classes - * in deal.II have a state flag indicating what happened to them. + * Most of the LAPACK functions one can apply to a matrix (e.g., by calling + * the member functions of this class) change its content in some ways. For + * example, they may invert the matrix, or may replace it by a matrix whose + * columns represent the eigenvectors of the original content of the matrix. + * The elements of this enumeration are therefore used to track what is + * currently being stored by this object. * * @author Guido Kanschat, 2005 */ diff --git a/source/lac/lapack_full_matrix.cc b/source/lac/lapack_full_matrix.cc index ad272cc9aa..473167f90a 100644 --- a/source/lac/lapack_full_matrix.cc +++ b/source/lac/lapack_full_matrix.cc @@ -985,6 +985,9 @@ LAPACKFullMatrix::print_formatted ( Assert ((!this->empty()) || (this->n_cols()+this->n_rows()==0), ExcInternalError()); + Assert (state == LAPACKSupport::matrix || + state == LAPACKSupport::inverse_matrix, + ExcState(state)); // set output format, but store old // state -- 2.39.5