Computes eigenvalues and eigenvectors of general matrices. More...
#include <EigenSolver.h>
Public Types | |
enum | { RowsAtCompileTime = MatrixType::RowsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime, Options = MatrixType::Options, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime } |
typedef std::complex< RealScalar > | ComplexScalar |
Complex scalar type for MatrixType. More... | |
typedef Matrix< ComplexScalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > | EigenvalueType |
Type for vector of eigenvalues as returned by eigenvalues(). More... | |
typedef Matrix< ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime > | EigenvectorsType |
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... | |
Public Member Functions | |
template<typename InputType > | |
EigenSolver & | compute (const EigenBase< InputType > &matrix, bool computeEigenvectors=true) |
Computes eigendecomposition of given matrix. More... | |
template<typename InputType > | |
EigenSolver< MatrixType > & | compute (const EigenBase< InputType > &matrix, bool computeEigenvectors) |
EigenSolver () | |
Default constructor. More... | |
EigenSolver (Index size) | |
Default constructor with memory preallocation. More... | |
template<typename InputType > | |
EigenSolver (const EigenBase< InputType > &matrix, bool computeEigenvectors=true) | |
Constructor; computes eigendecomposition of given matrix. More... | |
const EigenvalueType & | eigenvalues () const |
Returns the eigenvalues of given matrix. More... | |
EigenvectorsType | eigenvectors () const |
Returns the eigenvectors of given matrix. More... | |
Index | getMaxIterations () |
Returns the maximum number of iterations. More... | |
ComputationInfo | info () const |
MatrixType | pseudoEigenvalueMatrix () const |
Returns the block-diagonal matrix in the pseudo-eigendecomposition. More... | |
const MatrixType & | pseudoEigenvectors () const |
Returns the pseudo-eigenvectors of given matrix. More... | |
EigenSolver & | setMaxIterations (Index maxIters) |
Sets the maximum number of iterations allowed. More... | |
Protected Types | |
typedef Matrix< Scalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > | ColumnVectorType |
Static Protected Member Functions | |
static void | check_template_parameters () |
Protected Attributes | |
bool | m_eigenvectorsOk |
EigenvalueType | m_eivalues |
MatrixType | m_eivec |
ComputationInfo | m_info |
bool | m_isInitialized |
MatrixType | m_matT |
RealSchur< MatrixType > | m_realSchur |
ColumnVectorType | m_tmp |
Private Member Functions | |
void | doComputeEigenvectors () |
Computes eigenvalues and eigenvectors of general matrices.
_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. Currently, only real matrices are supported. |
The eigenvalues and eigenvectors of a matrix are scalars and vectors such that . If is a diagonal matrix with the eigenvalues on the diagonal, and is a matrix with the eigenvectors as its columns, then . The matrix is almost always invertible, in which case we have . This is called the eigendecomposition.
The eigenvalues and eigenvectors of a matrix may be complex, even when the matrix is real. However, we can choose real matrices and satisfying , just like the eigendecomposition, if the matrix is not required to be diagonal, but if it is allowed to have blocks of the form
(where and are real numbers) on the diagonal. These blocks correspond to complex eigenvalue pairs . We call this variant of the eigendecomposition the pseudo-eigendecomposition.
Call the function compute() to compute the eigenvalues and eigenvectors of a given matrix. Alternatively, you can use the EigenSolver(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. The pseudoEigenvalueMatrix() and pseudoEigenvectors() methods allow the construction of the pseudo-eigendecomposition.
The documentation for EigenSolver(const MatrixType&, bool) contains an example of the typical use of this class.
Definition at line 64 of file EigenSolver.h.
|
protected |
Definition at line 319 of file EigenSolver.h.
typedef std::complex<RealScalar> Eigen::EigenSolver< _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 90 of file EigenSolver.h.
typedef Matrix<ComplexScalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> Eigen::EigenSolver< _MatrixType >::EigenvalueType |
Type for vector of eigenvalues as returned by eigenvalues().
This is a column vector with entries of type ComplexScalar. The length of the vector is the size of MatrixType.
Definition at line 97 of file EigenSolver.h.
typedef Matrix<ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime> Eigen::EigenSolver< _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 104 of file EigenSolver.h.
typedef Eigen::Index Eigen::EigenSolver< _MatrixType >::Index |
Definition at line 82 of file EigenSolver.h.
typedef _MatrixType Eigen::EigenSolver< _MatrixType >::MatrixType |
Synonym for the template parameter _MatrixType
.
Definition at line 69 of file EigenSolver.h.
typedef NumTraits<Scalar>::Real Eigen::EigenSolver< _MatrixType >::RealScalar |
Definition at line 81 of file EigenSolver.h.
typedef MatrixType::Scalar Eigen::EigenSolver< _MatrixType >::Scalar |
Scalar type for matrices of type MatrixType.
Definition at line 80 of file EigenSolver.h.
anonymous enum |
Enumerator | |
---|---|
RowsAtCompileTime | |
ColsAtCompileTime | |
Options | |
MaxRowsAtCompileTime | |
MaxColsAtCompileTime |
Definition at line 71 of file EigenSolver.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 113 of file EigenSolver.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 121 of file EigenSolver.h.
|
inlineexplicit |
Constructor; computes eigendecomposition of given matrix.
[in] | matrix | 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 eigenvalues and eigenvectors.
Example:
Output:
Definition at line 147 of file EigenSolver.h.
|
inlinestaticprotected |
Definition at line 305 of file EigenSolver.h.
EigenSolver& Eigen::EigenSolver< _MatrixType >::compute | ( | const EigenBase< InputType > & | matrix, |
bool | computeEigenvectors = true |
||
) |
Computes eigendecomposition of given matrix.
[in] | matrix | 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 Schur form using the RealSchur class. The Schur decomposition is then used to compute the eigenvalues and eigenvectors.
The cost of the computation is dominated by the cost of the Schur decomposition, which is very approximately (where is the size of the matrix) if computeEigenvectors
is true, and if computeEigenvectors
is false.
This method reuses of the allocated data in the EigenSolver object.
Example:
Output:
EigenSolver<MatrixType>& Eigen::EigenSolver< _MatrixType >::compute | ( | const EigenBase< InputType > & | matrix, |
bool | computeEigenvectors | ||
) |
Definition at line 379 of file EigenSolver.h.
|
private |
Definition at line 458 of file EigenSolver.h.
|
inline |
Returns the eigenvalues of given matrix.
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.
Example:
Output:
Definition at line 244 of file EigenSolver.h.
EigenSolver< MatrixType >::EigenvectorsType Eigen::EigenSolver< MatrixType >::eigenvectors | ( | ) | const |
Returns the eigenvectors of given matrix.
computeEigenvectors
was set to true (the default).Column of the returned matrix is an eigenvector corresponding to eigenvalue number as returned by eigenvalues(). The eigenvectors are normalized to have (Euclidean) norm equal to one. The matrix returned by this function is the matrix in the eigendecomposition , if it exists.
Example:
Output:
Definition at line 345 of file EigenSolver.h.
|
inline |
Returns the maximum number of iterations.
Definition at line 295 of file EigenSolver.h.
|
inline |
Definition at line 281 of file EigenSolver.h.
MatrixType Eigen::EigenSolver< MatrixType >::pseudoEigenvalueMatrix | ( | ) | const |
Returns the block-diagonal matrix in the pseudo-eigendecomposition.
The matrix returned by this function is real and block-diagonal. The blocks on the diagonal are either 1-by-1 or 2-by-2 blocks of the form . These blocks are not sorted in any particular order. The matrix and the matrix returned by pseudoEigenvectors() satisfy .
Definition at line 324 of file EigenSolver.h.
|
inline |
Returns the pseudo-eigenvectors of given matrix.
computeEigenvectors
was set to true (the default).The real matrix returned by this function and the block-diagonal matrix returned by pseudoEigenvalueMatrix() satisfy .
Example:
Output:
Definition at line 199 of file EigenSolver.h.
|
inline |
Sets the maximum number of iterations allowed.
Definition at line 288 of file EigenSolver.h.
|
protected |
Definition at line 314 of file EigenSolver.h.
|
protected |
Definition at line 312 of file EigenSolver.h.
|
protected |
Definition at line 311 of file EigenSolver.h.
|
protected |
Definition at line 315 of file EigenSolver.h.
|
protected |
Definition at line 313 of file EigenSolver.h.
|
protected |
Definition at line 317 of file EigenSolver.h.
|
protected |
Definition at line 316 of file EigenSolver.h.
|
protected |
Definition at line 320 of file EigenSolver.h.