Computes the generalized eigenvalues and eigenvectors of a pair of general matrices. More...
Public Member Functions | |
const ComplexVectorType & | alphas () const |
const VectorType & | betas () const |
GeneralizedEigenSolver & | compute (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 |
GeneralizedEigenSolver & | setMaxIterations (Index maxIters) |
Protected Attributes | |
ComplexVectorType | m_alphas |
VectorType | m_betas |
bool | m_computeEigenvectors |
EigenvectorsType | m_eivec |
bool | m_isInitialized |
RealQZ< MatrixType > | m_realQZ |
ComplexVectorType | m_tmp |
Computes the generalized eigenvalues and eigenvectors of a pair of general matrices.
This is defined in the Eigenvalues module.
MatrixType_ | the 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:
Output:
The (complex) numerators of the generalzied eigenvalues are: (-0.126,0.569) (-0.126,-0.569) (-0.398,0) (-1.12,0) The (real) denominatore of the generalzied eigenvalues are: -1.56 -1.56 -1.25 0.746 The (complex) generalzied eigenvalues are (alphas./beta): (0.081,-0.365) (0.081,0.365) (0.318,-0) (-1.5,0)
Definition at line 60 of file GeneralizedEigenSolver.h.
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 86 of file GeneralizedEigenSolver.h.
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 100 of file GeneralizedEigenSolver.h.
typedef CwiseBinaryOp<internal::scalar_quotient_op<ComplexScalar,Scalar>,ComplexVectorType,VectorType> Eigen::GeneralizedEigenSolver< MatrixType_ >::EigenvalueType |
Expression type for the eigenvalues as returned by eigenvalues().
Definition at line 104 of file GeneralizedEigenSolver.h.
typedef Matrix<ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime> Eigen::GeneralizedEigenSolver< MatrixType_ >::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 111 of file GeneralizedEigenSolver.h.
typedef Eigen::Index Eigen::GeneralizedEigenSolver< MatrixType_ >::Index |
Definition at line 78 of file GeneralizedEigenSolver.h.
typedef MatrixType_ Eigen::GeneralizedEigenSolver< MatrixType_ >::MatrixType |
Synonym for the template parameter MatrixType_
.
Definition at line 65 of file GeneralizedEigenSolver.h.
typedef NumTraits<Scalar>::Real Eigen::GeneralizedEigenSolver< MatrixType_ >::RealScalar |
Definition at line 77 of file GeneralizedEigenSolver.h.
typedef MatrixType::Scalar Eigen::GeneralizedEigenSolver< MatrixType_ >::Scalar |
Scalar type for matrices of type MatrixType.
Definition at line 76 of file GeneralizedEigenSolver.h.
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 93 of file GeneralizedEigenSolver.h.
anonymous enum |
Enumerator | |
---|---|
RowsAtCompileTime | |
ColsAtCompileTime | |
Options | |
MaxRowsAtCompileTime | |
MaxColsAtCompileTime |
Definition at line 67 of file GeneralizedEigenSolver.h.
|
inline |
Default constructor.
The default constructor is useful in cases in which the user intends to perform decompositions via EigenSolver::compute(const MatrixType&, bool).
Definition at line 120 of file GeneralizedEigenSolver.h.
|
inlineexplicit |
Default constructor with memory preallocation.
Like the default constructor but with preallocation of the internal data according to the specified problem size.
Definition at line 135 of file GeneralizedEigenSolver.h.
|
inline |
Constructor; computes the generalized eigendecomposition of given matrix pair.
[in] | A | Square matrix whose eigendecomposition is to be computed. |
[in] | B | Square matrix whose eigendecomposition is to be computed. |
[in] | computeEigenvectors | If 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.
Definition at line 157 of file GeneralizedEigenSolver.h.
|
inline |
This vector permits to reconstruct the j-th eigenvalues as alphas(i)/betas(j).
Definition at line 216 of file GeneralizedEigenSolver.h.
|
inline |
This vector permits to reconstruct the j-th eigenvalues as alphas(i)/betas(j).
Definition at line 227 of file GeneralizedEigenSolver.h.
GeneralizedEigenSolver< MatrixType > & Eigen::GeneralizedEigenSolver< MatrixType >::compute | ( | const MatrixType & | A, |
const MatrixType & | B, | ||
bool | computeEigenvectors = true |
||
) |
Computes generalized eigendecomposition of given matrix.
[in] | A | Square matrix whose eigendecomposition is to be computed. |
[in] | B | Square matrix whose eigendecomposition is to be computed. |
[in] | computeEigenvectors | If true, both the eigenvectors and the eigenvalues are computed; if false, only the eigenvalues are computed. |
*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 288 of file GeneralizedEigenSolver.h.
|
inline |
Returns an expression of the computed generalized eigenvalues.
It is a shortcut for
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.
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.
Definition at line 205 of file GeneralizedEigenSolver.h.
|
inline |
Definition at line 181 of file GeneralizedEigenSolver.h.
|
inline |
Definition at line 258 of file GeneralizedEigenSolver.h.
|
inline |
Sets the maximal number of iterations allowed.
Definition at line 266 of file GeneralizedEigenSolver.h.
|
protected |
Definition at line 278 of file GeneralizedEigenSolver.h.
|
protected |
Definition at line 279 of file GeneralizedEigenSolver.h.
|
protected |
Definition at line 280 of file GeneralizedEigenSolver.h.
|
protected |
Definition at line 277 of file GeneralizedEigenSolver.h.
|
protected |
Definition at line 281 of file GeneralizedEigenSolver.h.
|
protected |
Definition at line 282 of file GeneralizedEigenSolver.h.
|
protected |
Definition at line 283 of file GeneralizedEigenSolver.h.