Shapeworks Studio  2.1
Shape analysis software suite
List of all members | Public Types | Public Member Functions | Protected Attributes
Eigen::ComplexEigenSolver< _MatrixType > Class Template Reference

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

#include <ComplexEigenSolver.h>

+ Collaboration diagram for Eigen::ComplexEigenSolver< _MatrixType >:

Public Types

enum  {
  RowsAtCompileTime = MatrixType::RowsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime, Options = MatrixType::Options, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
  MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
}
 
typedef _MatrixType MatrixType
 Synonym for the template parameter _MatrixType.
 
typedef MatrixType::Scalar Scalar
 Scalar type for matrices of type MatrixType.
 
typedef NumTraits< Scalar >::Real RealScalar
 
typedef MatrixType::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 > EigenvectorType
 Type for matrix of eigenvectors as returned by eigenvectors(). More...
 

Public Member Functions

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

Protected Attributes

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

Detailed Description

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

Computes eigenvalues and eigenvectors of general complex matrices.

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

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.

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.

template<typename _MatrixType>
typedef Matrix<ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime> Eigen::ComplexEigenSolver< _MatrixType >::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.

Constructor & Destructor Documentation

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.

93  : m_eivec(),
94  m_eivalues(),
95  m_schur(),
96  m_isInitialized(false),
97  m_eigenvectorsOk(false),
98  m_matX()
99  {}
template<typename _MatrixType>
Eigen::ComplexEigenSolver< _MatrixType >::ComplexEigenSolver ( Index  size)
inline

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.

108  : m_eivec(size, size),
109  m_eivalues(size),
110  m_schur(size),
111  m_isInitialized(false),
112  m_eigenvectorsOk(false),
113  m_matX(size, size)
114  {}
template<typename _MatrixType>
Eigen::ComplexEigenSolver< _MatrixType >::ComplexEigenSolver ( const MatrixType matrix,
bool  computeEigenvectors = true 
)
inline

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 125 of file ComplexEigenSolver.h.

126  : m_eivec(matrix.rows(),matrix.cols()),
127  m_eivalues(matrix.cols()),
128  m_schur(matrix.rows()),
129  m_isInitialized(false),
130  m_eigenvectorsOk(false),
131  m_matX(matrix.rows(),matrix.cols())
132  {
133  compute(matrix, computeEigenvectors);
134  }
Definition: math3d.h:219
ComplexEigenSolver & compute(const MatrixType &matrix, bool computeEigenvectors=true)
Computes eigendecomposition of given matrix.

Member Function Documentation

template<typename MatrixType >
ComplexEigenSolver< MatrixType > & Eigen::ComplexEigenSolver< MatrixType >::compute ( const MatrixType 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:

Output:

 

Definition at line 252 of file ComplexEigenSolver.h.

253 {
254  // this code is inspired from Jampack
255  eigen_assert(matrix.cols() == matrix.rows());
256 
257  // Do a complex Schur decomposition, A = U T U^*
258  // The eigenvalues are on the diagonal of T.
259  m_schur.compute(matrix, computeEigenvectors);
260 
261  if(m_schur.info() == Success)
262  {
263  m_eivalues = m_schur.matrixT().diagonal();
264  if(computeEigenvectors)
265  doComputeEigenvectors(matrix.norm());
266  sortEigenvalues(computeEigenvectors);
267  }
268 
269  m_isInitialized = true;
270  m_eigenvectorsOk = computeEigenvectors;
271  return *this;
272 }
Definition: math3d.h:219
ComplexSchur & compute(const MatrixType &matrix, bool computeU=true)
Computes Schur decomposition of given matrix.
Definition: ComplexSchur.h:316
const ComplexMatrixType & matrixT() const
Returns the triangular matrix in the Schur decomposition.
Definition: ComplexSchur.h:161
ComputationInfo info() const
Reports whether previous computation was successful.
Definition: ComplexSchur.h:215
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:

Output:

 

Definition at line 181 of file ComplexEigenSolver.h.

182  {
183  eigen_assert(m_isInitialized && "ComplexEigenSolver is not initialized.");
184  return m_eivalues;
185  }
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:

Output:

 

Definition at line 156 of file ComplexEigenSolver.h.

157  {
158  eigen_assert(m_isInitialized && "ComplexEigenSolver is not initialized.");
159  eigen_assert(m_eigenvectorsOk && "The eigenvectors have not been computed together with the eigenvalues.");
160  return m_eivec;
161  }
template<typename _MatrixType>
ComputationInfo Eigen::ComplexEigenSolver< _MatrixType >::info ( ) const
inline

Reports whether previous computation was successful.

Returns
Success if computation was succesful, NoConvergence otherwise.

Definition at line 217 of file ComplexEigenSolver.h.

218  {
219  eigen_assert(m_isInitialized && "ComplexEigenSolver is not initialized.");
220  return m_schur.info();
221  }
ComputationInfo info() const
Reports whether previous computation was successful.
Definition: ComplexSchur.h:215

The documentation for this class was generated from the following file: