From: Martin Kronbichler Date: Thu, 9 Mar 2023 14:14:49 +0000 (+0100) Subject: Expose eigenvectors of LAPACKFullMatrix X-Git-Tag: v9.5.0-rc1~474^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=560b8aa73d0e0a9b2bc15872d39ce31437642ff1;p=dealii.git Expose eigenvectors of LAPACKFullMatrix --- diff --git a/include/deal.II/lac/lapack_full_matrix.h b/include/deal.II/lac/lapack_full_matrix.h index fe7154a183..6d91586177 100644 --- a/include/deal.II/lac/lapack_full_matrix.h +++ b/include/deal.II/lac/lapack_full_matrix.h @@ -835,6 +835,27 @@ public: std::complex eigenvalue(const size_type i) const; + /** + * After a call to compute_eigenvalues(), this function returns all (right) + * eigenvectors as returned by LAPACK. This means that eigenvectors are + * contained in column-major ordering in a matrix associated to the given + * flat vector. Note that for real-valued matrices, there might appear + * complex eigenvalues with complex-conjugate values and eigenvectors. For + * those cases, LAPACK places a column of n() entries with the real part and + * the next column (corresponding to the complex conjugate eigenvalue) for + * the imaginary part of the eigenvector. + */ + std::vector + get_right_eigenvectors() const; + + /** + * Return the matrix of left eigenvectors after a call to + * compute_eigenvalues(), following the same convention as + * get_right_eigenvectors(). + */ + std::vector + get_left_eigenvectors() const; + /** * Retrieve singular values after compute_svd() or compute_inverse_svd() was * called. @@ -1155,6 +1176,32 @@ LAPACKFullMatrix::eigenvalue(const size_type i) const } +template +inline std::vector +LAPACKFullMatrix::get_right_eigenvectors() const +{ + Assert(state & LAPACKSupport::eigenvalues, ExcInvalidState()); + Assert(vr.size() == this->n_rows() * this->n_cols(), + ExcMessage("Right eigenvectors are not available! Did you " + "set the associated flag in compute_eigenvalues()")); + + return vr; +} + + +template +inline std::vector +LAPACKFullMatrix::get_left_eigenvectors() const +{ + Assert(state & LAPACKSupport::eigenvalues, ExcInvalidState()); + Assert(vl.size() == this->n_rows() * this->n_cols(), + ExcMessage("Left eigenvectors are not available! Did you " + "set the associated flag in compute_eigenvalues()")); + + return vl; +} + + template inline number LAPACKFullMatrix::singular_value(const size_type i) const