Public Types | Public Member Functions | Private Types | List of all members
Eigen::GeneralizedSelfAdjointEigenSolver< _MatrixType > Class Template Reference

Computes eigenvalues and eigenvectors of the generalized selfadjoint eigen problem. More...

#include <GeneralizedSelfAdjointEigenSolver.h>

Inheritance diagram for Eigen::GeneralizedSelfAdjointEigenSolver< _MatrixType >:
Inheritance graph
[legend]

Public Types

typedef _MatrixType MatrixType
 
- Public Types inherited from Eigen::SelfAdjointEigenSolver< _MatrixType >
enum  { Size = MatrixType::RowsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime, Options = MatrixType::Options, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime }
 
typedef Matrix< Scalar, Size, Size, ColMajor, MaxColsAtCompileTime, MaxColsAtCompileTimeEigenvectorsType
 
typedef Eigen::Index Index
 
typedef _MatrixType MatrixType
 
typedef NumTraits< Scalar >::Real RealScalar
 Real scalar type for _MatrixType. More...
 
typedef internal::plain_col_type< MatrixType, RealScalar >::type RealVectorType
 Type for vector of eigenvalues as returned by eigenvalues(). More...
 
typedef MatrixType::Scalar Scalar
 Scalar type for matrices of type _MatrixType. More...
 
typedef TridiagonalizationType::SubDiagonalType SubDiagonalType
 
typedef Tridiagonalization< MatrixTypeTridiagonalizationType
 

Public Member Functions

GeneralizedSelfAdjointEigenSolvercompute (const MatrixType &matA, const MatrixType &matB, int options=ComputeEigenvectors|Ax_lBx)
 Computes generalized eigendecomposition of given matrix pencil. More...
 
 GeneralizedSelfAdjointEigenSolver ()
 Default constructor for fixed-size matrices. More...
 
 GeneralizedSelfAdjointEigenSolver (Index size)
 Constructor, pre-allocates memory for dynamic-size matrices. More...
 
 GeneralizedSelfAdjointEigenSolver (const MatrixType &matA, const MatrixType &matB, int options=ComputeEigenvectors|Ax_lBx)
 Constructor; computes generalized eigendecomposition of given matrix pencil. More...
 
- Public Member Functions inherited from Eigen::SelfAdjointEigenSolver< _MatrixType >
template<typename InputType >
EIGEN_DEVICE_FUNC SelfAdjointEigenSolvercompute (const EigenBase< InputType > &matrix, int options=ComputeEigenvectors)
 Computes eigendecomposition of given matrix. More...
 
template<typename InputType >
EIGEN_DEVICE_FUNC SelfAdjointEigenSolver< MatrixType > & compute (const EigenBase< InputType > &a_matrix, int options)
 
EIGEN_DEVICE_FUNC SelfAdjointEigenSolvercomputeDirect (const MatrixType &matrix, int options=ComputeEigenvectors)
 Computes eigendecomposition of given matrix using a closed-form algorithm. More...
 
SelfAdjointEigenSolvercomputeFromTridiagonal (const RealVectorType &diag, const SubDiagonalType &subdiag, int options=ComputeEigenvectors)
 Computes the eigen decomposition from a tridiagonal symmetric matrix. More...
 
EIGEN_DEVICE_FUNC const RealVectorTypeeigenvalues () const
 Returns the eigenvalues of given matrix. More...
 
EIGEN_DEVICE_FUNC const EigenvectorsTypeeigenvectors () const
 Returns the eigenvectors of given matrix. More...
 
EIGEN_DEVICE_FUNC ComputationInfo info () const
 Reports whether previous computation was successful. More...
 
EIGEN_DEVICE_FUNC MatrixType operatorInverseSqrt () const
 Computes the inverse square root of the matrix. More...
 
EIGEN_DEVICE_FUNC MatrixType operatorSqrt () const
 Computes the positive-definite square root of the matrix. More...
 
EIGEN_DEVICE_FUNC SelfAdjointEigenSolver ()
 Default constructor for fixed-size matrices. More...
 
EIGEN_DEVICE_FUNC SelfAdjointEigenSolver (Index size)
 Constructor, pre-allocates memory for dynamic-size matrices. More...
 
template<typename InputType >
EIGEN_DEVICE_FUNC SelfAdjointEigenSolver (const EigenBase< InputType > &matrix, int options=ComputeEigenvectors)
 Constructor; computes eigendecomposition of given matrix. More...
 

Private Types

typedef SelfAdjointEigenSolver< _MatrixType > Base
 

Additional Inherited Members

- Static Public Attributes inherited from Eigen::SelfAdjointEigenSolver< _MatrixType >
static const int m_maxIterations = 30
 Maximum number of iterations. More...
 
- Static Protected Member Functions inherited from Eigen::SelfAdjointEigenSolver< _MatrixType >
static EIGEN_DEVICE_FUNC void check_template_parameters ()
 
- Protected Attributes inherited from Eigen::SelfAdjointEigenSolver< _MatrixType >
bool m_eigenvectorsOk
 
RealVectorType m_eivalues
 
EigenvectorsType m_eivec
 
TridiagonalizationType::CoeffVectorType m_hcoeffs
 
ComputationInfo m_info
 
bool m_isInitialized
 
TridiagonalizationType::SubDiagonalType m_subdiag
 

Detailed Description

template<typename _MatrixType>
class Eigen::GeneralizedSelfAdjointEigenSolver< _MatrixType >

Computes eigenvalues and eigenvectors of the generalized selfadjoint eigen problem.

Template Parameters
_MatrixTypethe 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.

See also
class SelfAdjointEigenSolver, class EigenSolver, class ComplexEigenSolver

Definition at line 48 of file GeneralizedSelfAdjointEigenSolver.h.

Member Typedef Documentation

◆ Base

template<typename _MatrixType>
typedef SelfAdjointEigenSolver<_MatrixType> Eigen::GeneralizedSelfAdjointEigenSolver< _MatrixType >::Base
private

Definition at line 50 of file GeneralizedSelfAdjointEigenSolver.h.

◆ MatrixType

template<typename _MatrixType>
typedef _MatrixType Eigen::GeneralizedSelfAdjointEigenSolver< _MatrixType >::MatrixType

Definition at line 53 of file GeneralizedSelfAdjointEigenSolver.h.

Constructor & Destructor Documentation

◆ GeneralizedSelfAdjointEigenSolver() [1/3]

template<typename _MatrixType>
Eigen::GeneralizedSelfAdjointEigenSolver< _MatrixType >::GeneralizedSelfAdjointEigenSolver ( )
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.

Definition at line 62 of file GeneralizedSelfAdjointEigenSolver.h.

◆ GeneralizedSelfAdjointEigenSolver() [2/3]

template<typename _MatrixType>
Eigen::GeneralizedSelfAdjointEigenSolver< _MatrixType >::GeneralizedSelfAdjointEigenSolver ( Index  size)
inlineexplicit

Constructor, pre-allocates memory for dynamic-size matrices.

Parameters
[in]sizePositive 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.

See also
compute() for an example

Definition at line 76 of file GeneralizedSelfAdjointEigenSolver.h.

◆ GeneralizedSelfAdjointEigenSolver() [3/3]

template<typename _MatrixType>
Eigen::GeneralizedSelfAdjointEigenSolver< _MatrixType >::GeneralizedSelfAdjointEigenSolver ( const MatrixType matA,
const MatrixType matB,
int  options = ComputeEigenvectors|Ax_lBx 
)
inline

Constructor; computes generalized eigendecomposition of given matrix pencil.

Parameters
[in]matASelfadjoint matrix in matrix pencil. Only the lower triangular part of the matrix is referenced.
[in]matBPositive-definite matrix in matrix pencil. Only the lower triangular part of the matrix is referenced.
[in]optionsA 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 $. 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:

MatrixXd X = MatrixXd::Random(5,5);
MatrixXd A = X + X.transpose();
cout << "Here is a random symmetric matrix, A:" << endl << A << endl;
X = MatrixXd::Random(5,5);
MatrixXd B = X * X.transpose();
cout << "and a random postive-definite matrix, B:" << endl << B << endl << endl;
GeneralizedSelfAdjointEigenSolver<MatrixXd> es(A,B);
cout << "The eigenvalues of the pencil (A,B) are:" << endl << es.eigenvalues() << endl;
cout << "The matrix of eigenvectors, V, is:" << endl << es.eigenvectors() << endl << endl;
double lambda = es.eigenvalues()[0];
cout << "Consider the first eigenvalue, lambda = " << lambda << endl;
VectorXd v = es.eigenvectors().col(0);
cout << "If v is the corresponding eigenvector, then A * v = " << endl << A * v << endl;
cout << "... and lambda * B * v = " << endl << lambda * B * v << endl << endl;

Output:

See also
compute(const MatrixType&, const MatrixType&, int)

Definition at line 106 of file GeneralizedSelfAdjointEigenSolver.h.

Member Function Documentation

◆ compute()

template<typename MatrixType >
GeneralizedSelfAdjointEigenSolver< MatrixType > & Eigen::GeneralizedSelfAdjointEigenSolver< MatrixType >::compute ( const MatrixType matA,
const MatrixType matB,
int  options = ComputeEigenvectors|Ax_lBx 
)

Computes generalized eigendecomposition of given matrix pencil.

Parameters
[in]matASelfadjoint matrix in matrix pencil. Only the lower triangular part of the matrix is referenced.
[in]matBPositive-definite matrix in matrix pencil. Only the lower triangular part of the matrix is referenced.
[in]optionsA or-ed set of flags {ComputeEigenvectors,EigenvaluesOnly} | {Ax_lBx,ABx_lx,BAx_lx}. Default is ComputeEigenvectors|Ax_lBx.
Returns
Reference to *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 $.

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:

MatrixXd X = MatrixXd::Random(5,5);
MatrixXd A = X * X.transpose();
X = MatrixXd::Random(5,5);
MatrixXd B = X * X.transpose();
GeneralizedSelfAdjointEigenSolver<MatrixXd> es(A,B,EigenvaluesOnly);
cout << "The eigenvalues of the pencil (A,B) are:" << endl << es.eigenvalues() << endl;
es.compute(B,A,false);
cout << "The eigenvalues of the pencil (B,A) are:" << endl << es.eigenvalues() << endl;

Output:

See also
GeneralizedSelfAdjointEigenSolver(const MatrixType&, const MatrixType&, int)

Definition at line 163 of file GeneralizedSelfAdjointEigenSolver.h.


The documentation for this class was generated from the following file:


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:41:40