From db134f6727ab09ed4dfbedddacef719bae19266b Mon Sep 17 00:00:00 2001 From: young Date: Thu, 10 Apr 2014 09:06:33 +0000 Subject: [PATCH] Allow LAAPCKFullMatrix to be reinitialised (reset state). git-svn-id: https://svn.dealii.org/trunk@32754 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/deal.II/lac/lapack_full_matrix.h | 25 ++++++++++++++++--- deal.II/source/lac/lapack_full_matrix.cc | 23 ++++++++++++++++- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/deal.II/include/deal.II/lac/lapack_full_matrix.h b/deal.II/include/deal.II/lac/lapack_full_matrix.h index ddff7b1a09..4f97d3464e 100644 --- a/deal.II/include/deal.II/lac/lapack_full_matrix.h +++ b/deal.II/include/deal.II/lac/lapack_full_matrix.h @@ -70,7 +70,7 @@ public: * * By default, no memory is allocated. */ - explicit LAPACKFullMatrix (const size_type n = 0); + explicit LAPACKFullMatrix (const size_type size = 0); /** @@ -79,6 +79,7 @@ public: LAPACKFullMatrix (const size_type rows, const size_type cols); + /** * Copy constructor. This constructor does a deep copy of the * matrix. Therefore, it poses a possible efficiency problem, if for @@ -131,6 +132,21 @@ public: template void copy_from (const MATRIX &); + /** + * Regenerate the current matrix by one that has the same properties + * as if it were created by the constructor of this class with the + * same argument list as this present function. + */ + void reinit (const size_type size); + + /** + * Regenerate the current matrix by one that has the same properties + * as if it were created by the constructor of this class with the + * same argument list as this present function. + */ + void reinit (const size_type rows, + const size_type cols); + /** * Return the dimension of the range space. @note The matrix is of * dimension $m \times n$. @@ -565,10 +581,11 @@ public: const double threshold = 0.) const; private: - + /** - * Since LAPACK operations notoriously change the meaning of the matrix - * entries, we record the current state after the last operation here. + * Since LAPACK operations notoriously change the meaning of the + * matrix entries, we record the current state after the last + * operation here. */ LAPACKSupport::State state; diff --git a/deal.II/source/lac/lapack_full_matrix.cc b/deal.II/source/lac/lapack_full_matrix.cc index 98aa0a1d52..f1e45edc7f 100644 --- a/deal.II/source/lac/lapack_full_matrix.cc +++ b/deal.II/source/lac/lapack_full_matrix.cc @@ -42,7 +42,7 @@ template LAPACKFullMatrix::LAPACKFullMatrix (const size_type m, const size_type n) : - TransposeTable (m,n), + TransposeTable (m, n), state (matrix) {} @@ -65,6 +65,25 @@ LAPACKFullMatrix::operator = (const LAPACKFullMatrix &M) } +template +void +LAPACKFullMatrix::reinit (const size_type n) +{ + this->TransposeTable::reinit (n, n); + state = LAPACKSupport::matrix; +} + + +template +void +LAPACKFullMatrix::reinit (const size_type m, + const size_type n) +{ + this->TransposeTable::reinit (m, n); + state = LAPACKSupport::matrix; +} + + template template LAPACKFullMatrix & @@ -738,6 +757,7 @@ LAPACKFullMatrix::compute_eigenvalues_symmetric(const number lowe eigenvalues.reinit(n_eigenpairs); eigenvectors.reinit(nn, n_eigenpairs, true); + for (size_type i=0; i < static_cast (n_eigenpairs); ++i) { eigenvalues(i) = wr[i]; @@ -838,6 +858,7 @@ LAPACKFullMatrix::compute_generalized_eigenvalues_symmetric( eigenvalues.reinit(n_eigenpairs); eigenvectors.resize(n_eigenpairs); + for (size_type i=0; i < static_cast (n_eigenpairs); ++i) { eigenvalues(i) = wr[i]; -- 2.39.5