From efc7a59f2be935b808f74e05f8f2c8bbce08692a Mon Sep 17 00:00:00 2001 From: young Date: Thu, 3 Apr 2014 12:56:30 +0000 Subject: [PATCH] Add two standard accessors, m() and n(), and do some cleaning. git-svn-id: https://svn.dealii.org/trunk@32711 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/lac/constraint_matrix.templates.h | 2 +- .../include/deal.II/lac/lapack_full_matrix.h | 75 ++++++++++++------- deal.II/source/lac/lapack_full_matrix.cc | 2 +- 3 files changed, 51 insertions(+), 28 deletions(-) diff --git a/deal.II/include/deal.II/lac/constraint_matrix.templates.h b/deal.II/include/deal.II/lac/constraint_matrix.templates.h index 36c3304668..2cf08a4f3d 100644 --- a/deal.II/include/deal.II/lac/constraint_matrix.templates.h +++ b/deal.II/include/deal.II/lac/constraint_matrix.templates.h @@ -2798,7 +2798,7 @@ add_entries_local_to_global (const std::vector &local_dof_indices, sparsity_pattern.add_entries(actual_dof_indices[i], actual_dof_indices.begin(), actual_dof_indices.end(), - true); + true); // need to add the whole row and column structure in case we keep // constrained entries. Unfortunately, we can't use the nice matrix 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 ee8339ba60..ee4401d1a4 100644 --- a/deal.II/include/deal.II/lac/lapack_full_matrix.h +++ b/deal.II/include/deal.II/lac/lapack_full_matrix.h @@ -55,6 +55,7 @@ template class LAPACKFullMatrix : public TransposeTable { public: + /** * Declare type for container size. */ @@ -130,6 +131,18 @@ public: template void copy_from (const MATRIX &); + /** + * Return the dimension of the range space. @note The matrix is of + * dimension \f$m \times n\f$. + */ + unsigned int m () const; + + /** + * Return the number of the range space. @note The matrix is of + * dimension \f$m \times n\f$. + */ + unsigned int n () const; + /** * Fill rectangular block. * @@ -369,7 +382,7 @@ public: * system is to be performed. */ void apply_lu_factorization (Vector &v, - const bool transposed) const; + const bool transposed) const; /** * Solve the linear system with multiple right hand sides (as many as there @@ -381,7 +394,7 @@ public: * system is to be performed. */ void apply_lu_factorization (LAPACKFullMatrix &B, - const bool transposed) const; + const bool transposed) const; /** * Compute eigenvalues of the matrix. After this routine has been called, @@ -402,7 +415,7 @@ public: * @note Calls the LAPACK function Xgeev. */ void compute_eigenvalues (const bool right_eigenvectors = false, - const bool left_eigenvectors = false); + const bool left_eigenvectors = false); /** * Compute eigenvalues and eigenvectors of a real symmetric matrix. Only @@ -422,12 +435,11 @@ public: * @note Calls the LAPACK function Xsyevx. For this to work, ./configure has * to be told to use LAPACK. */ - void compute_eigenvalues_symmetric( - const number lower_bound, - const number upper_bound, - const number abs_accuracy, - Vector &eigenvalues, - FullMatrix &eigenvectors); + void compute_eigenvalues_symmetric (const number lower_bound, + const number upper_bound, + const number abs_accuracy, + Vector &eigenvalues, + FullMatrix &eigenvectors); /** * Compute generalized eigenvalues and eigenvectors of a real generalized @@ -450,15 +462,14 @@ public: * @note Calls the LAPACK function Xsygvx. For this to work, ./configure has * to be told to use LAPACK. */ - void compute_generalized_eigenvalues_symmetric( - LAPACKFullMatrix &B, - const number lower_bound, - const number upper_bound, - const number abs_accuracy, - Vector &eigenvalues, - std::vector > &eigenvectors, - const int itype = 1); - + void compute_generalized_eigenvalues_symmetric (LAPACKFullMatrix &B, + const number lower_bound, + const number upper_bound, + const number abs_accuracy, + Vector &eigenvalues, + std::vector > &eigenvectors, + const int itype = 1); + /** * Same as the other compute_generalized_eigenvalues_symmetric function * except that all eigenvalues are computed and the tolerance is set @@ -475,10 +486,9 @@ public: * @note Calls the LAPACK function Xsygv. For this to work, ./configure has * to be told to use LAPACK. */ - void compute_generalized_eigenvalues_symmetric ( - LAPACKFullMatrix &B, - std::vector > &eigenvectors, - const int itype = 1); + void compute_generalized_eigenvalues_symmetric (LAPACKFullMatrix &B, + std::vector > &eigenvectors, + const int itype = 1); /** * Compute the singular value decomposition of the matrix using LAPACK @@ -488,7 +498,7 @@ public: * #wr, #svd_u, and #svd_vt, and leaves the object in the #state * LAPACKSupport::svd. */ - void compute_svd(); + void compute_svd (); /** * Compute the inverse of the matrix by singular value decomposition. @@ -555,9 +565,6 @@ public: const double threshold = 0.) const; private: - /** - * n_rows - */ /** * Since LAPACK operations notoriously change the meaning of the matrix @@ -651,7 +658,23 @@ private: SmartPointer >,PreconditionLU > mem; }; +/*---------------------- Inline functions -----------------------------------*/ + +template +inline +unsigned int +LAPACKFullMatrix::m () const +{ + return this->n_rows (); +} +template +inline +unsigned int +LAPACKFullMatrix::n () const +{ + return this->n_cols (); +} template template diff --git a/deal.II/source/lac/lapack_full_matrix.cc b/deal.II/source/lac/lapack_full_matrix.cc index 98aa0a1d52..d1080d946b 100644 --- a/deal.II/source/lac/lapack_full_matrix.cc +++ b/deal.II/source/lac/lapack_full_matrix.cc @@ -744,7 +744,7 @@ LAPACKFullMatrix::compute_eigenvalues_symmetric(const number lowe size_type col_begin(i*nn); for (size_type j=0; j < static_cast (nn); ++j) { - eigenvectors(j,i) = values_eigenvectors[col_begin+j]; + eigenvectors(i,j) = values_eigenvectors[col_begin+j]; } } -- 2.39.5