![]() |
Eigen
5.0.1
|
#include <Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h>
Computes eigenvalues and eigenvectors of the generalized selfadjoint eigen problem.
This is defined in the Eigenvalues module.
| MatrixType_ | the type of the matrix of which we are computing the eigendecomposition; this is expected to be an instantiation of the Matrix class template. |
This class solves the generalized eigenvalue problem \( Av = \lambda Bv \). In this case, the matrix \( A \) should be selfadjoint and the matrix \( B \) should be positive definite.
Only the lower triangular part of the input matrix is referenced.
Call the function compute() to compute the eigenvalues and eigenvectors of a given matrix. Alternatively, you can use the GeneralizedSelfAdjointEigenSolver(const MatrixType&, const MatrixType&, int) constructor which computes the eigenvalues and eigenvectors at construction time. Once the eigenvalue and eigenvectors are computed, they can be retrieved with the eigenvalues() and eigenvectors() functions.
The documentation for GeneralizedSelfAdjointEigenSolver(const MatrixType&, const MatrixType&, int) contains an example of the typical use of this class.
Inheritance diagram for Eigen::GeneralizedSelfAdjointEigenSolver< MatrixType_ >:Public Member Functions | |
| template<typename InputTypeA, typename InputTypeB> | |
| GeneralizedSelfAdjointEigenSolver & | compute (const EigenBase< InputTypeA > &matA, const EigenBase< InputTypeB > &matB, int options=ComputeEigenvectors|Ax_lBx) |
| Computes generalized eigendecomposition of given matrix pencil. | |
| GeneralizedSelfAdjointEigenSolver () | |
| Default constructor for fixed-size matrices. | |
| template<typename InputTypeA, typename InputTypeB> | |
| GeneralizedSelfAdjointEigenSolver (const EigenBase< InputTypeA > &matA, const EigenBase< InputTypeB > &matB, int options=ComputeEigenvectors|Ax_lBx) | |
| Constructor; computes generalized eigendecomposition of given matrix pencil. | |
| template<typename InputTypeA, typename InputTypeB, bool IsRef = internal::is_ref<MatrixType>::value, std::enable_if_t< IsRef, int > = 0> | |
| GeneralizedSelfAdjointEigenSolver (EigenBase< InputTypeA > &matA, EigenBase< InputTypeB > &matB, int options=ComputeEigenvectors|Ax_lBx) | |
| Constructor for inplace decomposition . | |
| GeneralizedSelfAdjointEigenSolver (Index size) | |
| Constructor, pre-allocates memory for dynamic-size matrices. | |
Public Member Functions inherited from Eigen::SelfAdjointEigenSolver< MatrixType_ > | |
| template<typename InputType> | |
| SelfAdjointEigenSolver & | compute (const EigenBase< InputType > &matrix, int options=ComputeEigenvectors) |
| Computes eigendecomposition of given matrix. | |
| SelfAdjointEigenSolver & | computeDirect (const MatrixType &matrix, int options=ComputeEigenvectors) |
| Computes eigendecomposition of given matrix primarily using a closed-form algorithm. | |
| SelfAdjointEigenSolver & | computeFromTridiagonal (const RealVectorType &diag, const SubDiagonalType &subdiag, int options=ComputeEigenvectors) |
| Computes the eigen decomposition from a tridiagonal symmetric matrix. | |
| const RealVectorType & | eigenvalues () const |
| Returns the eigenvalues of given matrix. | |
| const EigenvectorsType & | eigenvectors () const |
| Returns the eigenvectors of given matrix. | |
| ComputationInfo | info () const |
| Reports whether previous computation was successful. | |
| PlainMatrixType | operatorExp () const |
| Computes the matrix exponential of the matrix. | |
| PlainMatrixType | operatorInverseSqrt () const |
| Computes the inverse square root of the matrix. | |
| PlainMatrixType | operatorSqrt () const |
| Computes the positive-definite square root of the matrix. | |
| SelfAdjointEigenSolver () | |
| Default constructor for fixed-size matrices. | |
| template<typename InputType> | |
| SelfAdjointEigenSolver (const EigenBase< InputType > &matrix, int options=ComputeEigenvectors) | |
| Constructor; computes eigendecomposition of given matrix. | |
| template<typename InputType, bool IsRef = internal::is_ref<MatrixType>::value, std::enable_if_t< IsRef, int > = 0> | |
| SelfAdjointEigenSolver (EigenBase< InputType > &matrix, int options=ComputeEigenvectors) | |
| Constructor for inplace decomposition . | |
| SelfAdjointEigenSolver (Index size) | |
| Constructor, pre-allocates memory for dynamic-size matrices. | |
Additional Inherited Members | |
Public Types inherited from Eigen::SelfAdjointEigenSolver< MatrixType_ > | |
| using | EigenvectorsType |
| Type of the matrix returned by eigenvectors(). | |
| using | Index |
| using | PlainMatrixType |
Plain matrix type with the shape and storage options of MatrixType_; MatrixType_ itself unless that is a Ref<>. | |
| using | RealScalar |
Real scalar type for MatrixType_. | |
| using | Scalar |
Scalar type for matrices of type MatrixType_. | |
| using | VectorType |
| Type for vector of eigenvalues as returned by eigenvalues(). | |
Static Public Attributes inherited from Eigen::SelfAdjointEigenSolver< MatrixType_ > | |
| static const int | m_maxIterations |
| Maximum number of iterations. | |
|
inline |
Default constructor for fixed-size matrices.
The default constructor is useful in cases in which the user intends to perform decompositions via compute(). This constructor can only be used if MatrixType_ is a fixed-size matrix; use GeneralizedSelfAdjointEigenSolver(Index) for dynamic-size matrices.
|
inlineexplicit |
Constructor, pre-allocates memory for dynamic-size matrices.
| [in] | size | Positive integer, size of the matrix whose eigenvalues and eigenvectors will be computed. |
This constructor is useful for dynamic-size matrices, when the user intends to perform decompositions via compute(). The size parameter is only used as a hint. It is not an error to give a wrong size, but it may impair performance.
|
inline |
Constructor; computes generalized eigendecomposition of given matrix pencil.
| [in] | matA | Selfadjoint matrix in matrix pencil. Only the lower triangular part of the matrix is referenced. |
| [in] | matB | Positive-definite matrix in matrix pencil. Only the lower triangular part of the matrix is referenced. |
| [in] | options | A or-ed set of flags {ComputeEigenvectors,EigenvaluesOnly} | {Ax_lBx,ABx_lx,BAx_lx}. Default is ComputeEigenvectors|Ax_lBx. |
This constructor calls compute(const MatrixType&, const MatrixType&, int) to compute the eigenvalues and (if requested) the eigenvectors of the generalized eigenproblem \( Ax = \lambda B x \) with matA the selfadjoint matrix \( A \) and matB the positive definite matrix \( B \). Each eigenvector \( x \) satisfies the property \( x^* B x = 1 \) for Ax_lBx and ABx_lx, and the property \( x^* B^{-1} x = 1 \) for BAx_lx. The eigenvectors are computed if options contains ComputeEigenvectors.
In addition, the two following variants can be solved via options:
ABx_lx: \( ABx = \lambda x \)BAx_lx: \( BAx = \lambda x \)Example:
Output:
Here is a random symmetric matrix, A: -0.422 0.855 -1.12 1.21 0.648 0.855 0.0536 1.44 0.0267 0.997 -1.12 1.44 -0.396 -0.734 -0.859 1.21 0.0267 -0.734 1.89 1.38 0.648 0.997 -0.859 1.38 1.8 and a random positive-definite matrix, B: 2.9 -0.786 0.295 0.431 1.2 -0.786 2.44 0.689 1.51 0.571 0.295 0.689 1.13 0.809 0.732 0.431 1.51 0.809 2.44 1.69 1.2 0.571 0.732 1.69 1.78 The eigenvalues of the pencil (A,B) are: -1.96 -0.294 0.272 2.26 4.43 The matrix of eigenvectors, V, is: -0.109 0.727 0.302 -0.102 0.298 -0.645 0.266 0.414 -0.183 -0.615 0.861 -0.126 0.285 -0.738 0.0968 0.143 -0.236 0.344 0.174 1.55 0.0991 -0.291 -0.351 0.768 -1.69 Consider the first eigenvalue, lambda = -1.96 If v is the corresponding eigenvector, then A * v = -1.23 1.22 -1.34 -0.373 -1.08 ... and lambda * B * v = -1.23 1.22 -1.34 -0.373 -1.08
|
inline |
Constructor for inplace decomposition .
| [in,out] | matA | Selfadjoint matrix in matrix pencil. Only the lower triangular part of the matrix is referenced. |
| [in,out] | matB | Positive-definite matrix in matrix pencil. Only the lower triangular part of the matrix is referenced. |
| [in] | options | A or-ed set of flags {ComputeEigenvectors,EigenvaluesOnly} | {Ax_lBx,ABx_lx,BAx_lx}. Default is ComputeEigenvectors|Ax_lBx. |
This constructor is only available when MatrixType is a Ref<>. The decomposition is then computed within the memory of matA and matB: matB receives the Cholesky factor of B and matA the transformed matrix C, then, with ComputeEigenvectors, the eigenvectors, which eigenvectors() refers to. The forms ABx_lx and BAx_lx allocate one temporary of the size of matA for the products that cannot run in place.
| GeneralizedSelfAdjointEigenSolver & Eigen::GeneralizedSelfAdjointEigenSolver< MatrixType_ >::compute | ( | const EigenBase< InputTypeA > & | matA, |
| const EigenBase< InputTypeB > & | matB, | ||
| int | options = ComputeEigenvectors|Ax_lBx ) |
Computes generalized eigendecomposition of given matrix pencil.
| [in] | matA | Selfadjoint matrix in matrix pencil. Only the lower triangular part of the matrix is referenced. |
| [in] | matB | Positive-definite matrix in matrix pencil. Only the lower triangular part of the matrix is referenced. |
| [in] | options | A or-ed set of flags {ComputeEigenvectors,EigenvaluesOnly} | {Ax_lBx,ABx_lx,BAx_lx}. Default is ComputeEigenvectors|Ax_lBx. |
*this According to options, this function computes eigenvalues and (if requested) the eigenvectors of one of the following three generalized eigenproblems:
Ax_lBx: \( Ax = \lambda B x \)ABx_lx: \( ABx = \lambda x \)BAx_lx: \( BAx = \lambda x \) with matA the selfadjoint matrix \( A \) and matB the positive definite matrix \( B \). In addition, each eigenvector \( x \) satisfies the property \( x^* B x = 1 \) for Ax_lBx and ABx_lx. For BAx_lx, the eigenvectors are instead normalized such that \( x^* B^{-1} x = 1 \), following the same convention as LAPACK's ?sygv with itype=3.The eigenvalues() function can be used to retrieve the eigenvalues. If options contains ComputeEigenvectors, then the eigenvectors are also computed and can be retrieved by calling eigenvectors().
The implementation uses LLT to compute the Cholesky decomposition \( B = LL^* \) and computes the classical eigendecomposition of the selfadjoint matrix \( L^{-1} A (L^*)^{-1} \) if options contains Ax_lBx and of \( L^{*} A L \) otherwise. This solves the generalized eigenproblem, because any solution of the generalized eigenproblem \( Ax = \lambda B x \) corresponds to a solution \( L^{-1} A (L^*)^{-1} (L^* x) = \lambda (L^* x) \) of the eigenproblem for \( L^{-1} A (L^*)^{-1} \). Similar statements can be made for the two other variants.
Example:
Output:
The eigenvalues of the pencil (A,B) are: 0.0219 0.207 0.37 2.16 3.81 The eigenvalues of the pencil (B,A) are: 0.263 0.463 2.7 4.82 45.8