![]() |
|
Computes eigenvalues and eigenvectors of general matrices. More...
#include <EigenSolver.h>
Public Types | |
enum | { RowsAtCompileTime = MatrixType::RowsAtCompileTime , ColsAtCompileTime = MatrixType::ColsAtCompileTime , Options = internal::traits<MatrixType>::Options , MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime , MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime } |
typedef MatrixType_ | MatrixType |
Synonym for the template parameter MatrixType_ . More... | |
typedef MatrixType::Scalar | Scalar |
Scalar type for matrices of type MatrixType. More... | |
typedef NumTraits< Scalar >::Real | RealScalar |
typedef Eigen::Index | Index |
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... | |
Public Member Functions | |
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... | |
EigenvectorsType | eigenvectors () const |
Returns the eigenvectors of given matrix. More... | |
const MatrixType & | pseudoEigenvectors () const |
Returns the pseudo-eigenvectors of given matrix. More... | |
MatrixType | pseudoEigenvalueMatrix () const |
Returns the block-diagonal matrix in the pseudo-eigendecomposition. More... | |
const EigenvalueType & | eigenvalues () const |
Returns the eigenvalues of given matrix. More... | |
template<typename InputType > | |
EigenSolver & | compute (const EigenBase< InputType > &matrix, bool computeEigenvectors=true) |
Computes eigendecomposition of given matrix. More... | |
ComputationInfo | info () const |
EigenSolver & | setMaxIterations (Index maxIters) |
Sets the maximum number of iterations allowed. More... | |
Index | getMaxIterations () |
Returns the maximum number of iterations. More... | |
template<typename InputType > | |
EigenSolver< MatrixType > & | compute (const EigenBase< InputType > &matrix, bool computeEigenvectors) |
Protected Types | |
typedef Matrix< Scalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > | ColumnVectorType |
Static Protected Member Functions | |
static void | check_template_parameters () |
Private Member Functions | |
void | doComputeEigenvectors () |
Computes eigenvalues and eigenvectors of general matrices.
\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. Currently, only real matrices are supported. |
The eigenvalues and eigenvectors of a matrix \( A \) are scalars \( \lambda \) and vectors \( v \) such that \( Av = \lambda v \). 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 = V D \). The matrix \( V \) is almost always invertible, in which case we have \( A = V D V^{-1} \). 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 \( V \) and \( D \) satisfying \( A V = V D \), just like the eigendecomposition, if the matrix \( D \) is not required to be diagonal, but if it is allowed to have blocks of the form
\[ \begin{bmatrix} u & v \\ -v & u \end{bmatrix} \]
(where \( u \) and \( v \) are real numbers) on the diagonal. These blocks correspond to complex eigenvalue pairs \( u \pm iv \). 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.
|
protected |
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.
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.
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.
typedef Eigen::Index Eigen::EigenSolver< MatrixType_ >::Index |
typedef MatrixType_ Eigen::EigenSolver< MatrixType_ >::MatrixType |
Synonym for the template parameter MatrixType_
.
typedef NumTraits<Scalar>::Real Eigen::EigenSolver< MatrixType_ >::RealScalar |
typedef MatrixType::Scalar Eigen::EigenSolver< MatrixType_ >::Scalar |
Scalar type for matrices of type MatrixType.
anonymous enum |
|
inline |
Default constructor.
The default constructor is useful in cases in which the user intends to perform decompositions via EigenSolver::compute(const MatrixType&, bool).
|
inlineexplicit |
Default constructor with memory preallocation.
Like the default constructor but with preallocation of the internal data according to the specified problem size.
|
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:
References Eigen::EigenSolver< MatrixType_ >::compute(), and matrix().
|
inlinestaticprotected |
References EIGEN_STATIC_ASSERT, and EIGEN_STATIC_ASSERT_NON_INTEGER.
EigenSolver<MatrixType>& Eigen::EigenSolver< MatrixType_ >::compute | ( | const EigenBase< InputType > & | matrix, |
bool | computeEigenvectors | ||
) |
References abs(), eigen_assert, i, Eigen::numext::isfinite(), isfinite, matrix(), Eigen::NumericalIssue, p, p0, sqrt(), and Eigen::Success.
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 \( 25n^3 \) (where \( n \) is the size of the matrix) if computeEigenvectors
is true, and \( 10n^3 \) if computeEigenvectors
is false.
This method reuses of the allocated data in the EigenSolver object.
Example:
Output:
Referenced by __attribute__(), ctms_decompositions(), Eigen::EigenSolver< MatrixType_ >::EigenSolver(), eigensolver(), and eigensolver_verify_assert().
|
private |
References abs(), eigen_assert, CRBond_Bessel::eps, oomph::SarahBL::epsilon, i, imag(), j, max, n, p, Eigen::numext::q, UniformPSDSelfTest::r, size, plotPSD::t, w, plotDoE::x, and y.
|
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:
References eigen_assert, Eigen::EigenSolver< MatrixType_ >::m_eivalues, and Eigen::EigenSolver< MatrixType_ >::m_isInitialized.
Referenced by eigensolver(), eigensolver_generic_extra(), eigensolver_verify_assert(), and Eigen::internal::eigenvalues_selector< Derived, false >::run().
EigenSolver< MatrixType >::EigenvectorsType Eigen::EigenSolver< MatrixType >::eigenvectors |
Returns the eigenvectors of given matrix.
computeEigenvectors
was set to true (the default).Column \( k \) of the returned matrix is an eigenvector corresponding to eigenvalue number \( k \) as returned by eigenvalues(). The eigenvectors are normalized to have (Euclidean) norm equal to one. The matrix returned by this function is the matrix \( V \) in the eigendecomposition \( A = V D V^{-1} \), if it exists.
Example:
Output:
References Eigen::Matrix< Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_ >::coeffRef(), eigen_assert, oomph::SarahBL::epsilon, i, imag(), Eigen::internal::isMuchSmallerThan(), j, and n.
Referenced by __attribute__(), eigensolver(), eigensolver_generic_extra(), and eigensolver_verify_assert().
|
inline |
Returns the maximum number of iterations.
References Eigen::RealSchur< MatrixType_ >::getMaxIterations(), and Eigen::EigenSolver< MatrixType_ >::m_realSchur.
Referenced by eigensolver().
|
inline |
References eigen_assert, Eigen::EigenSolver< MatrixType_ >::m_info, and Eigen::EigenSolver< MatrixType_ >::m_isInitialized.
Referenced by eigensolver().
MatrixType Eigen::EigenSolver< MatrixType >::pseudoEigenvalueMatrix |
Returns the block-diagonal matrix in the pseudo-eigendecomposition.
The matrix \( D \) 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 \( \begin{bmatrix} u & v \\ -v & u \end{bmatrix} \). These blocks are not sorted in any particular order. The matrix \( D \) and the matrix \( V \) returned by pseudoEigenvectors() satisfy \( AV = VD \).
References eigen_assert, oomph::SarahBL::epsilon, i, imag(), Eigen::imag(), Eigen::internal::isMuchSmallerThan(), n, Eigen::real(), and oomph::PseudoSolidHelper::Zero.
Referenced by eigensolver(), eigensolver_generic_extra(), and eigensolver_verify_assert().
|
inline |
Returns the pseudo-eigenvectors of given matrix.
computeEigenvectors
was set to true (the default).The real matrix \( V \) returned by this function and the block-diagonal matrix \( D \) returned by pseudoEigenvalueMatrix() satisfy \( AV = VD \).
Example:
Output:
References eigen_assert, Eigen::EigenSolver< MatrixType_ >::m_eigenvectorsOk, Eigen::EigenSolver< MatrixType_ >::m_eivec, and Eigen::EigenSolver< MatrixType_ >::m_isInitialized.
Referenced by eigensolver(), eigensolver_generic_extra(), and eigensolver_verify_assert().
|
inline |
Sets the maximum number of iterations allowed.
References Eigen::EigenSolver< MatrixType_ >::m_realSchur, and Eigen::RealSchur< MatrixType_ >::setMaxIterations().
Referenced by eigensolver().
|
protected |
Referenced by Eigen::EigenSolver< MatrixType_ >::pseudoEigenvectors().
|
protected |
Referenced by Eigen::EigenSolver< MatrixType_ >::eigenvalues().
|
protected |
Referenced by Eigen::EigenSolver< MatrixType_ >::pseudoEigenvectors().
|
protected |
Referenced by Eigen::EigenSolver< MatrixType_ >::info().
|
protected |
|
protected |
|
protected |
|
protected |