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

Computes eigenvalues and eigenvectors of general complex matrices. More...

#include <ComplexEigenSolver.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 > EigenvalueType
 Type for vector of eigenvalues as returned by eigenvalues(). More...
 
typedef Matrix< ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTimeEigenvectorType
 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

 ComplexEigenSolver ()
 Default constructor. More...
 
template<typename InputType >
 ComplexEigenSolver (const EigenBase< InputType > &matrix, bool computeEigenvectors=true)
 Constructor; computes eigendecomposition of given matrix. More...
 
 ComplexEigenSolver (Index size)
 Default Constructor with memory preallocation. More...
 
template<typename InputType >
ComplexEigenSolver< MatrixType > & compute (const EigenBase< InputType > &matrix, bool computeEigenvectors)
 
template<typename InputType >
ComplexEigenSolvercompute (const EigenBase< InputType > &matrix, bool computeEigenvectors=true)
 Computes eigendecomposition of given matrix. More...
 
const EigenvalueTypeeigenvalues () const
 Returns the eigenvalues of given matrix. More...
 
const EigenvectorTypeeigenvectors () const
 Returns the eigenvectors of given matrix. More...
 
Index getMaxIterations ()
 Returns the maximum number of iterations. More...
 
ComputationInfo info () const
 Reports whether previous computation was successful. More...
 
ComplexEigenSolversetMaxIterations (Index maxIters)
 Sets the maximum number of iterations allowed. More...
 

Static Protected Member Functions

static void check_template_parameters ()
 

Protected Attributes

bool m_eigenvectorsOk
 
EigenvalueType m_eivalues
 
EigenvectorType m_eivec
 
bool m_isInitialized
 
EigenvectorType m_matX
 
ComplexSchur< MatrixTypem_schur
 

Private Member Functions

void doComputeEigenvectors (RealScalar matrixnorm)
 
void sortEigenvalues (bool computeEigenvectors)
 

Detailed Description

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

Computes eigenvalues and eigenvectors of general complex matrices.

\eigenvalues_module

Template Parameters
_MatrixTypethe type of the matrix of which we are computing the eigendecomposition; this is expected to be an instantiation of the Matrix class template.

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

Definition at line 45 of file ComplexEigenSolver.h.

Member Typedef Documentation

◆ ComplexScalar

template<typename _MatrixType >
typedef std::complex<RealScalar> Eigen::ComplexEigenSolver< _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 71 of file ComplexEigenSolver.h.

◆ EigenvalueType

template<typename _MatrixType >
typedef Matrix<ComplexScalar, ColsAtCompileTime, 1, Options&(~RowMajor), MaxColsAtCompileTime, 1> Eigen::ComplexEigenSolver< _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 78 of file ComplexEigenSolver.h.

◆ 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.

Definition at line 85 of file ComplexEigenSolver.h.

◆ Index

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

Definition at line 63 of file ComplexEigenSolver.h.

◆ MatrixType

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

Synonym for the template parameter _MatrixType.

Definition at line 50 of file ComplexEigenSolver.h.

◆ RealScalar

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

Definition at line 62 of file ComplexEigenSolver.h.

◆ Scalar

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

Scalar type for matrices of type MatrixType.

Definition at line 61 of file ComplexEigenSolver.h.

Member Enumeration Documentation

◆ anonymous enum

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

Definition at line 52 of file ComplexEigenSolver.h.

Constructor & Destructor Documentation

◆ ComplexEigenSolver() [1/3]

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

Default constructor.

The default constructor is useful in cases in which the user intends to perform decompositions via compute().

Definition at line 92 of file ComplexEigenSolver.h.

◆ ComplexEigenSolver() [2/3]

template<typename _MatrixType >
Eigen::ComplexEigenSolver< _MatrixType >::ComplexEigenSolver ( 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
ComplexEigenSolver()

Definition at line 107 of file ComplexEigenSolver.h.

◆ ComplexEigenSolver() [3/3]

template<typename _MatrixType >
template<typename InputType >
Eigen::ComplexEigenSolver< _MatrixType >::ComplexEigenSolver ( const EigenBase< InputType > &  matrix,
bool  computeEigenvectors = true 
)
inlineexplicit

Constructor; computes eigendecomposition of given matrix.

Parameters
[in]matrixSquare 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 eigendecomposition.

Definition at line 126 of file ComplexEigenSolver.h.

Member Function Documentation

◆ check_template_parameters()

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

Definition at line 240 of file ComplexEigenSolver.h.

◆ compute() [1/2]

template<typename _MatrixType >
template<typename InputType >
ComplexEigenSolver<MatrixType>& Eigen::ComplexEigenSolver< _MatrixType >::compute ( const EigenBase< InputType > &  matrix,
bool  computeEigenvectors 
)

Definition at line 261 of file ComplexEigenSolver.h.

◆ compute() [2/2]

template<typename _MatrixType >
template<typename InputType >
ComplexEigenSolver& Eigen::ComplexEigenSolver< _MatrixType >::compute ( const EigenBase< InputType > &  matrix,
bool  computeEigenvectors = true 
)

Computes eigendecomposition of given matrix.

Parameters
[in]matrixSquare 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 complex 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 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:

MatrixXcf A = MatrixXcf::Random(4,4);
cout << "Here is a random 4x4 matrix, A:" << endl << A << endl << endl;
ComplexEigenSolver<MatrixXcf> ces;
ces.compute(A);
cout << "The eigenvalues of A are:" << endl << ces.eigenvalues() << endl;
cout << "The matrix of eigenvectors, V, is:" << endl << ces.eigenvectors() << endl << endl;
complex<float> lambda = ces.eigenvalues()[0];
cout << "Consider the first eigenvalue, lambda = " << lambda << endl;
VectorXcf v = ces.eigenvectors().col(0);
cout << "If v is the corresponding eigenvector, then lambda * v = " << endl << lambda * v << endl;
cout << "... and A * v = " << endl << A * v << endl << endl;
cout << "Finally, V * D * V^(-1) = " << endl
<< ces.eigenvectors() * ces.eigenvalues().asDiagonal() * ces.eigenvectors().inverse() << endl;

Output:

 

◆ doComputeEigenvectors()

template<typename MatrixType >
void Eigen::ComplexEigenSolver< MatrixType >::doComputeEigenvectors ( RealScalar  matrixnorm)
private

Definition at line 287 of file ComplexEigenSolver.h.

◆ eigenvalues()

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

Returns the eigenvalues of given matrix.

Returns
A const reference to the column vector containing the eigenvalues.
Precondition
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.

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:

MatrixXcf ones = MatrixXcf::Ones(3,3);
ComplexEigenSolver<MatrixXcf> ces(ones, /* computeEigenvectors = */ false);
cout << "The eigenvalues of the 3x3 matrix of ones are:"
<< endl << ces.eigenvalues() << endl;

Output:

 

Definition at line 182 of file ComplexEigenSolver.h.

◆ eigenvectors()

template<typename _MatrixType >
const EigenvectorType& Eigen::ComplexEigenSolver< _MatrixType >::eigenvectors ( ) const
inline

Returns the eigenvectors of given matrix.

Returns
A const reference to the matrix whose columns are the eigenvectors.
Precondition
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).

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:

MatrixXcf ones = MatrixXcf::Ones(3,3);
ComplexEigenSolver<MatrixXcf> ces(ones);
cout << "The first eigenvector of the 3x3 matrix of ones is:"
<< endl << ces.eigenvectors().col(0) << endl;

Output:

 

Definition at line 157 of file ComplexEigenSolver.h.

◆ getMaxIterations()

template<typename _MatrixType >
Index Eigen::ComplexEigenSolver< _MatrixType >::getMaxIterations ( )
inline

Returns the maximum number of iterations.

Definition at line 233 of file ComplexEigenSolver.h.

◆ info()

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

Reports whether previous computation was successful.

Returns
Success if computation was successful, NoConvergence otherwise.

Definition at line 219 of file ComplexEigenSolver.h.

◆ setMaxIterations()

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

Sets the maximum number of iterations allowed.

Definition at line 226 of file ComplexEigenSolver.h.

◆ sortEigenvalues()

template<typename MatrixType >
void Eigen::ComplexEigenSolver< MatrixType >::sortEigenvalues ( bool  computeEigenvectors)
private

Definition at line 327 of file ComplexEigenSolver.h.

Member Data Documentation

◆ m_eigenvectorsOk

template<typename _MatrixType >
bool Eigen::ComplexEigenSolver< _MatrixType >::m_eigenvectorsOk
protected

Definition at line 249 of file ComplexEigenSolver.h.

◆ m_eivalues

template<typename _MatrixType >
EigenvalueType Eigen::ComplexEigenSolver< _MatrixType >::m_eivalues
protected

Definition at line 246 of file ComplexEigenSolver.h.

◆ m_eivec

template<typename _MatrixType >
EigenvectorType Eigen::ComplexEigenSolver< _MatrixType >::m_eivec
protected

Definition at line 245 of file ComplexEigenSolver.h.

◆ m_isInitialized

template<typename _MatrixType >
bool Eigen::ComplexEigenSolver< _MatrixType >::m_isInitialized
protected

Definition at line 248 of file ComplexEigenSolver.h.

◆ m_matX

template<typename _MatrixType >
EigenvectorType Eigen::ComplexEigenSolver< _MatrixType >::m_matX
protected

Definition at line 250 of file ComplexEigenSolver.h.

◆ m_schur

template<typename _MatrixType >
ComplexSchur<MatrixType> Eigen::ComplexEigenSolver< _MatrixType >::m_schur
protected

Definition at line 247 of file ComplexEigenSolver.h.


The documentation for this class was generated from the following file:
ces
cout<< "Here is a random 4x4 matrix, A:"<< endl<< A<< endl<< endl;ComplexEigenSolver< MatrixXcf > ces
Definition: ComplexEigenSolver_compute.cpp:4
A
Definition: test_numpy_dtypes.cpp:298
lambda
static double lambda[]
Definition: jv.c:524
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
complex
Definition: datatypes.h:12
ones
MatrixXcf ones
Definition: ComplexEigenSolver_eigenvalues.cpp:1


gtsam
Author(s):
autogenerated on Thu Dec 19 2024 04:09:34