Public Types | Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Eigen::GeneralizedEigenSolver< _MatrixType > Class Template Reference

Computes the generalized eigenvalues and eigenvectors of a pair of general matrices. More...

#include <GeneralizedEigenSolver.h>

Public Types

enum  {
  RowsAtCompileTime = MatrixType::RowsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime, Options = MatrixType::Options, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
  MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
}
 
typedef std::complex< RealScalarComplexScalar
 Complex scalar type for MatrixType. More...
 
typedef Matrix< ComplexScalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > ComplexVectorType
 Type for vector of complex scalar values eigenvalues as returned by alphas(). More...
 
typedef CwiseBinaryOp< internal::scalar_quotient_op< ComplexScalar, Scalar >, ComplexVectorType, VectorTypeEigenvalueType
 Expression type for the eigenvalues as returned by eigenvalues(). More...
 
typedef Matrix< ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTimeEigenvectorsType
 Type for matrix of eigenvectors as returned by eigenvectors(). More...
 
typedef Eigen::Index Index
 
typedef _MatrixType MatrixType
 Synonym for the template parameter _MatrixType. More...
 
typedef NumTraits< Scalar >::Real RealScalar
 
typedef MatrixType::Scalar Scalar
 Scalar type for matrices of type MatrixType. More...
 
typedef Matrix< Scalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > VectorType
 Type for vector of real scalar values eigenvalues as returned by betas(). More...
 

Public Member Functions

ComplexVectorType alphas () const
 
VectorType betas () const
 
GeneralizedEigenSolvercompute (const MatrixType &A, const MatrixType &B, bool computeEigenvectors=true)
 Computes generalized eigendecomposition of given matrix. More...
 
EigenvalueType eigenvalues () const
 Returns an expression of the computed generalized eigenvalues. More...
 
EigenvectorsType eigenvectors () const
 
 GeneralizedEigenSolver ()
 Default constructor. More...
 
 GeneralizedEigenSolver (const MatrixType &A, const MatrixType &B, bool computeEigenvectors=true)
 Constructor; computes the generalized eigendecomposition of given matrix pair. More...
 
 GeneralizedEigenSolver (Index size)
 Default constructor with memory preallocation. More...
 
ComputationInfo info () const
 
GeneralizedEigenSolversetMaxIterations (Index maxIters)
 

Static Protected Member Functions

static void check_template_parameters ()
 

Protected Attributes

ComplexVectorType m_alphas
 
VectorType m_betas
 
EigenvectorsType m_eivec
 
RealQZ< MatrixTypem_realQZ
 
ComplexVectorType m_tmp
 
bool m_valuesOkay
 
bool m_vectorsOkay
 

Detailed Description

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

Computes the generalized eigenvalues and eigenvectors of a pair of general matrices.

\eigenvalues_module

Template Parameters
_MatrixTypethe type of the matrices of which we are computing the eigen-decomposition; this is expected to be an instantiation of the Matrix class template. Currently, only real matrices are supported.

The generalized eigenvalues and eigenvectors of a matrix pair $ A $ and $ B $ are scalars $ \lambda $ and vectors $ v $ such that $ Av = \lambda Bv $. If $ D $ is a diagonal matrix with the eigenvalues on the diagonal, and $ V $ is a matrix with the eigenvectors as its columns, then $ A V = B V D $. The matrix $ V $ is almost always invertible, in which case we have $ A = B V D V^{-1} $. This is called the generalized eigen-decomposition.

The generalized eigenvalues and eigenvectors of a matrix pair may be complex, even when the matrices are real. Moreover, the generalized eigenvalue might be infinite if the matrix B is singular. To workaround this difficulty, the eigenvalues are provided as a pair of complex $ \alpha $ and real $ \beta $ such that: $ \lambda_i = \alpha_i / \beta_i $. If $ \beta_i $ is (nearly) zero, then one can consider the well defined left eigenvalue $ \mu = \beta_i / \alpha_i$ such that: $ \mu_i A v_i = B v_i $, or even $ \mu_i u_i^T A = u_i^T B $ where $ u_i $ is called the left eigenvector.

Call the function compute() to compute the generalized eigenvalues and eigenvectors of a given matrix pair. Alternatively, you can use the GeneralizedEigenSolver(const MatrixType&, const MatrixType&, bool) 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.

Here is an usage example of this class: Example:

GeneralizedEigenSolver<MatrixXf> ges;
MatrixXf A = MatrixXf::Random(4,4);
MatrixXf B = MatrixXf::Random(4,4);
ges.compute(A, B);
cout << "The (complex) numerators of the generalzied eigenvalues are: " << ges.alphas().transpose() << endl;
cout << "The (real) denominatore of the generalzied eigenvalues are: " << ges.betas().transpose() << endl;
cout << "The (complex) generalzied eigenvalues are (alphas./beta): " << ges.eigenvalues().transpose() << endl;

Output:

See also
MatrixBase::eigenvalues(), class ComplexEigenSolver, class SelfAdjointEigenSolver

Definition at line 58 of file GeneralizedEigenSolver.h.

Member Typedef Documentation

◆ ComplexScalar

template<typename _MatrixType >
typedef std::complex<RealScalar> Eigen::GeneralizedEigenSolver< _MatrixType >::ComplexScalar

Complex scalar type for MatrixType.

This is std::complex<Scalar> if Scalar is real (e.g., float or double) and just Scalar if Scalar is complex.

Definition at line 84 of file GeneralizedEigenSolver.h.

◆ ComplexVectorType

template<typename _MatrixType >
typedef Matrix<ComplexScalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> Eigen::GeneralizedEigenSolver< _MatrixType >::ComplexVectorType

Type for vector of complex scalar values eigenvalues as returned by alphas().

This is a column vector with entries of type ComplexScalar. The length of the vector is the size of MatrixType.

Definition at line 98 of file GeneralizedEigenSolver.h.

◆ EigenvalueType

Expression type for the eigenvalues as returned by eigenvalues().

Definition at line 102 of file GeneralizedEigenSolver.h.

◆ EigenvectorsType

Type for matrix of eigenvectors as returned by eigenvectors().

This is a square matrix with entries of type ComplexScalar. The size is the same as the size of MatrixType.

Definition at line 109 of file GeneralizedEigenSolver.h.

◆ Index

template<typename _MatrixType >
typedef Eigen::Index Eigen::GeneralizedEigenSolver< _MatrixType >::Index
Deprecated:
since Eigen 3.3

Definition at line 76 of file GeneralizedEigenSolver.h.

◆ MatrixType

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

Synonym for the template parameter _MatrixType.

Definition at line 63 of file GeneralizedEigenSolver.h.

◆ RealScalar

template<typename _MatrixType >
typedef NumTraits<Scalar>::Real Eigen::GeneralizedEigenSolver< _MatrixType >::RealScalar

Definition at line 75 of file GeneralizedEigenSolver.h.

◆ Scalar

template<typename _MatrixType >
typedef MatrixType::Scalar Eigen::GeneralizedEigenSolver< _MatrixType >::Scalar

Scalar type for matrices of type MatrixType.

Definition at line 74 of file GeneralizedEigenSolver.h.

◆ VectorType

template<typename _MatrixType >
typedef Matrix<Scalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> Eigen::GeneralizedEigenSolver< _MatrixType >::VectorType

Type for vector of real scalar values eigenvalues as returned by betas().

This is a column vector with entries of type Scalar. The length of the vector is the size of MatrixType.

Definition at line 91 of file GeneralizedEigenSolver.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename _MatrixType >
anonymous enum
Enumerator
RowsAtCompileTime 
ColsAtCompileTime 
Options 
MaxRowsAtCompileTime 
MaxColsAtCompileTime 

Definition at line 65 of file GeneralizedEigenSolver.h.

Constructor & Destructor Documentation

◆ GeneralizedEigenSolver() [1/3]

template<typename _MatrixType >
Eigen::GeneralizedEigenSolver< _MatrixType >::GeneralizedEigenSolver ( )
inline

Default constructor.

The default constructor is useful in cases in which the user intends to perform decompositions via EigenSolver::compute(const MatrixType&, bool).

See also
compute() for an example.

Definition at line 118 of file GeneralizedEigenSolver.h.

◆ GeneralizedEigenSolver() [2/3]

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

Default constructor with memory preallocation.

Like the default constructor but with preallocation of the internal data according to the specified problem size.

See also
GeneralizedEigenSolver()

Definition at line 133 of file GeneralizedEigenSolver.h.

◆ GeneralizedEigenSolver() [3/3]

template<typename _MatrixType >
Eigen::GeneralizedEigenSolver< _MatrixType >::GeneralizedEigenSolver ( const MatrixType A,
const MatrixType B,
bool  computeEigenvectors = true 
)
inline

Constructor; computes the generalized eigendecomposition of given matrix pair.

Parameters
[in]ASquare matrix whose eigendecomposition is to be computed.
[in]BSquare matrix whose eigendecomposition is to be computed.
[in]computeEigenvectorsIf true, both the eigenvectors and the eigenvalues are computed; if false, only the eigenvalues are computed.

This constructor calls compute() to compute the generalized eigenvalues and eigenvectors.

See also
compute()

Definition at line 155 of file GeneralizedEigenSolver.h.

Member Function Documentation

◆ alphas()

template<typename _MatrixType >
ComplexVectorType Eigen::GeneralizedEigenSolver< _MatrixType >::alphas ( ) const
inline
Returns
A const reference to the vectors containing the alpha values

This vector permits to reconstruct the j-th eigenvalues as alphas(i)/betas(j).

See also
betas(), eigenvalues()

Definition at line 213 of file GeneralizedEigenSolver.h.

◆ betas()

template<typename _MatrixType >
VectorType Eigen::GeneralizedEigenSolver< _MatrixType >::betas ( ) const
inline
Returns
A const reference to the vectors containing the beta values

This vector permits to reconstruct the j-th eigenvalues as alphas(i)/betas(j).

See also
alphas(), eigenvalues()

Definition at line 224 of file GeneralizedEigenSolver.h.

◆ check_template_parameters()

template<typename _MatrixType >
static void Eigen::GeneralizedEigenSolver< _MatrixType >::check_template_parameters ( )
inlinestaticprotected

Definition at line 271 of file GeneralizedEigenSolver.h.

◆ compute()

template<typename MatrixType >
GeneralizedEigenSolver< MatrixType > & Eigen::GeneralizedEigenSolver< MatrixType >::compute ( const MatrixType A,
const MatrixType B,
bool  computeEigenvectors = true 
)

Computes generalized eigendecomposition of given matrix.

Parameters
[in]ASquare matrix whose eigendecomposition is to be computed.
[in]BSquare matrix whose eigendecomposition is to be computed.
[in]computeEigenvectorsIf true, both the eigenvectors and the eigenvalues are computed; if false, only the eigenvalues are computed.
Returns
Reference to *this

This function computes the eigenvalues of the real matrix matrix. The eigenvalues() function can be used to retrieve them. If computeEigenvectors is true, then the eigenvectors are also computed and can be retrieved by calling eigenvectors().

The matrix is first reduced to real generalized Schur form using the RealQZ class. The generalized Schur decomposition is then used to compute the eigenvalues and eigenvectors.

The cost of the computation is dominated by the cost of the generalized Schur decomposition.

This method reuses of the allocated data in the GeneralizedEigenSolver object.

Definition at line 287 of file GeneralizedEigenSolver.h.

◆ eigenvalues()

template<typename _MatrixType >
EigenvalueType Eigen::GeneralizedEigenSolver< _MatrixType >::eigenvalues ( ) const
inline

Returns an expression of the computed generalized eigenvalues.

Returns
An expression of the column vector containing the eigenvalues.

It is a shortcut for

this->alphas().cwiseQuotient(this->betas());

Not that betas might contain zeros. It is therefore not recommended to use this function, but rather directly deal with the alphas and betas vectors.

Precondition
Either the constructor GeneralizedEigenSolver(const MatrixType&,const MatrixType&,bool) or the member function compute(const MatrixType&,const MatrixType&,bool) has been called before.

The eigenvalues are repeated according to their algebraic multiplicity, so there are as many eigenvalues as rows in the matrix. The eigenvalues are not sorted in any particular order.

See also
alphas(), betas(), eigenvectors()

Definition at line 202 of file GeneralizedEigenSolver.h.

◆ eigenvectors()

template<typename _MatrixType >
EigenvectorsType Eigen::GeneralizedEigenSolver< _MatrixType >::eigenvectors ( ) const
inline

Definition at line 179 of file GeneralizedEigenSolver.h.

◆ info()

template<typename _MatrixType >
ComputationInfo Eigen::GeneralizedEigenSolver< _MatrixType >::info ( ) const
inline

Definition at line 255 of file GeneralizedEigenSolver.h.

◆ setMaxIterations()

template<typename _MatrixType >
GeneralizedEigenSolver& Eigen::GeneralizedEigenSolver< _MatrixType >::setMaxIterations ( Index  maxIters)
inline

Sets the maximal number of iterations allowed.

Definition at line 263 of file GeneralizedEigenSolver.h.

Member Data Documentation

◆ m_alphas

template<typename _MatrixType >
ComplexVectorType Eigen::GeneralizedEigenSolver< _MatrixType >::m_alphas
protected

Definition at line 278 of file GeneralizedEigenSolver.h.

◆ m_betas

template<typename _MatrixType >
VectorType Eigen::GeneralizedEigenSolver< _MatrixType >::m_betas
protected

Definition at line 279 of file GeneralizedEigenSolver.h.

◆ m_eivec

template<typename _MatrixType >
EigenvectorsType Eigen::GeneralizedEigenSolver< _MatrixType >::m_eivec
protected

Definition at line 277 of file GeneralizedEigenSolver.h.

◆ m_realQZ

template<typename _MatrixType >
RealQZ<MatrixType> Eigen::GeneralizedEigenSolver< _MatrixType >::m_realQZ
protected

Definition at line 281 of file GeneralizedEigenSolver.h.

◆ m_tmp

template<typename _MatrixType >
ComplexVectorType Eigen::GeneralizedEigenSolver< _MatrixType >::m_tmp
protected

Definition at line 282 of file GeneralizedEigenSolver.h.

◆ m_valuesOkay

template<typename _MatrixType >
bool Eigen::GeneralizedEigenSolver< _MatrixType >::m_valuesOkay
protected

Definition at line 280 of file GeneralizedEigenSolver.h.

◆ m_vectorsOkay

template<typename _MatrixType >
bool Eigen::GeneralizedEigenSolver< _MatrixType >::m_vectorsOkay
protected

Definition at line 280 of file GeneralizedEigenSolver.h.


The documentation for this class was generated from the following file:
Eigen::GeneralizedEigenSolver::alphas
ComplexVectorType alphas() const
Definition: GeneralizedEigenSolver.h:213
B
Definition: test_numpy_dtypes.cpp:299
A
Definition: test_numpy_dtypes.cpp:298
ges
GeneralizedEigenSolver< MatrixXf > ges
Definition: GeneralizedEigenSolver.cpp:1
Eigen::GeneralizedEigenSolver::betas
VectorType betas() const
Definition: GeneralizedEigenSolver.h:224


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:44:45