Class xlifepp::ComplexEigenSolver#
-
template<typename _MatrixType>
class ComplexEigenSolver#
-
Collaboration diagram for xlifepp::ComplexEigenSolver:
Computes eigenvalues and eigenvectors of general complex matrices.
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 main function in this class is compute(), which computes the eigenvalues and eigenvectors of a given function. The documentation for that function contains an example showing the main features of the class.
See also
class EigenSolver, class SelfAdjointEigenSolver
- Template Parameters:
-
_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.
Public Types
-
typedef VectorEigenDense<ComplexScalar> 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 MatrixEigenDense<ComplexScalar> EigenvectorType#
-
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 _MatrixType MatrixType#
-
Synonym for the template parameter
_MatrixType
.
-
typedef MatrixType::Scalar Scalar#
-
Scalar type for matrices of type MatrixType.
Public Functions
-
inline ComplexEigenSolver()#
-
Default constructor.
The default constructor is useful in cases in which the user intends to perform decompositions via compute().
-
inline ComplexEigenSolver(const MatrixType &matrix, bool computeEigenvectors = true, bool sorted = false)#
-
Constructor; computes eigendecomposition of given matrix.
This constructor calls compute() to compute the eigendecomposition.
- Parameters:
-
matrix – [in] Square matrix whose eigendecomposition is to be computed.
computeEigenvectors – [in] If true, both the eigenvectors and the eigenvalues are computed; if false, only the eigenvalues are computed.
sorted –
-
inline ComplexEigenSolver(Index size)#
-
Default Constructor with memory preallocation.
Like the default constructor but with preallocation of the internal data according to the specified problem size.
See also
-
ComplexEigenSolver &compute(const MatrixType &matrix, bool computeEigenvectors = true, bool sorted = false)#
-
Computes eigendecomposition of given matrix.
This function computes the eigenvalues of the complex matrix
matrix
. The eigenvalues() function can be used to retrieve them. IfcomputeEigenvectors
is true, then the eigenvectors are also computed and can be retrieved by calling eigenvectors().The matrix is first reduced to Schur form using the ComplexSchur 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 \( O(n^3) \) where \( n \) is the size of the matrix.
Example: \include ComplexEigenSolver_compute.cpp Output: \verbinclude ComplexEigenSolver_compute.out
- Parameters:
-
matrix – [in] Square matrix whose eigendecomposition is to be computed.
computeEigenvectors – [in] If true, both the eigenvectors and the eigenvalues are computed; if false, only the eigenvalues are computed.
sorted –
- Returns:
-
Reference to
*this
-
inline const EigenvalueType &eigenvalues() const#
-
Returns the eigenvalues of given matrix.
This function returns a column vector containing the eigenvalues. 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: \include ComplexEigenSolver_eigenvalues.cpp Output: \verbinclude ComplexEigenSolver_eigenvalues.out
- Returns:
-
A const reference to the column vector containing the eigenvalues.
- Pre:
-
Either the constructor ComplexEigenSolver(const MatrixType& matrix, bool) or the member function compute(const MatrixType& matrix, bool) has been called before to compute the eigendecomposition of a matrix.
-
inline const EigenvectorType &eigenvectors() const#
-
Returns the eigenvectors of given matrix.
This function returns a matrix whose columns are the eigenvectors. Column \( k \) 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: \include ComplexEigenSolver_eigenvectors.cpp Output: \verbinclude ComplexEigenSolver_eigenvectors.out
- Returns:
-
A const reference to the matrix whose columns are the eigenvectors.
- Pre:
-
Either the constructor ComplexEigenSolver(const MatrixType& matrix, bool) or the member function compute(const MatrixType& matrix, bool) has been called before to compute the eigendecomposition of a matrix, and
computeEigenvectors
was set to true (the default).
-
inline ComputationInfo info() const#
-
Reports whether previous computation was successful.
- Returns:
-
_success
if computation was succesful,NoConvergence
otherwise.