]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Expose eigenvectors of LAPACKFullMatrix
authorMartin Kronbichler <martin.kronbichler@uni-a.de>
Thu, 9 Mar 2023 14:14:49 +0000 (15:14 +0100)
committerMartin Kronbichler <martin.kronbichler@uni-a.de>
Tue, 14 Mar 2023 12:19:52 +0000 (13:19 +0100)
include/deal.II/lac/lapack_full_matrix.h

index fe7154a183c77d336afc94d0f351f3814d937628..6d915861777ae5a18ebae91a332422d8917bf450 100644 (file)
@@ -835,6 +835,27 @@ public:
   std::complex<number>
   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<number>
+  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<number>
+  get_left_eigenvectors() const;
+
   /**
    * Retrieve singular values after compute_svd() or compute_inverse_svd() was
    * called.
@@ -1155,6 +1176,32 @@ LAPACKFullMatrix<number>::eigenvalue(const size_type i) const
 }
 
 
+template <typename number>
+inline std::vector<number>
+LAPACKFullMatrix<number>::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 <typename number>
+inline std::vector<number>
+LAPACKFullMatrix<number>::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 <typename number>
 inline number
 LAPACKFullMatrix<number>::singular_value(const size_type i) const

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.