Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
 Eigen  3.4.99 (git rev 10c77b0ff44d0b9cb0b252cfa0ccaaa39d3c5da4)
Eigen::ComplexEigenSolver< _MatrixType > Class Template Reference

## Detailed Description

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

Computes eigenvalues and eigenvectors of general complex matrices.

This is defined in the Eigenvalues module.

#include <Eigen/Eigenvalues>
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.

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.

## Public Types

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

typedef Eigen::Index Index

typedef _MatrixType MatrixType
Synonym for the template parameter _MatrixType.

typedef MatrixType::Scalar Scalar
Scalar type for matrices of type MatrixType.

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

ComputationInfo info () const
Reports whether previous computation was successful. More...

ComplexEigenSolversetMaxIterations (Index maxIters)
Sets the maximum number of iterations allowed.

## ◆ ComplexScalar

template<typename _MatrixType >
 typedef std::complex 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.

## ◆ EigenvalueType

template<typename _MatrixType >
 typedef Matrix 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.

## ◆ EigenvectorType

template<typename _MatrixType >
 typedef Matrix 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.

## ◆ Index

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

## ◆ 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().

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

ComplexEigenSolver()

## ◆ 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] 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 eigendecomposition.

## ◆ compute()

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] 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.
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;
static const RandomReturnType Random()
Definition: Random.h:113

Output:

Here is a random 4x4 matrix, A:
(-1,-0.737)   (0.359,0.869)  (0.342,-0.985)  (0.692,0.0539)
(0.511,-0.0827) (-0.233,0.0388) (-0.233,-0.866)  (-0.816,0.308)
(0.0655,-0.562)  (0.662,-0.931)  (-0.165,0.374)  (-0.168,0.402)
(-0.906,0.358) (-0.893,0.0594)   (0.178,0.861)   (0.821,0.524)

The eigenvalues of A are:
(-0.366,0.914)
(0.567,-0.864)
(0.322,1.19)
(-1.1,-1.04)
The matrix of eigenvectors, V, is:
(-0.523,-0.173)      (0.13,0.203)   (-0.152,-0.377)      (-0.852,0.3)
(-0.143,-0.16)    (-0.321,0.408)   (-0.0448,0.138)    (0.206,-0.268)
(0.408,0.00767)    (-0.369,0.424)     (0.455,0.192) (0.000899,-0.059)
(-0.448,-0.532)    (0.577,-0.153)    (0.405,-0.637)   (-0.0861,0.244)

Consider the first eigenvalue, lambda = (-0.366,0.914)
If v is the corresponding eigenvector, then lambda * v =
(0.349,-0.415)
(0.199,-0.0722)
(-0.156,0.37)
(0.65,-0.215)
... and A * v =
(0.349,-0.415)
(0.199,-0.0722)
(-0.156,0.37)
(0.65,-0.215)

Finally, V * D * V^(-1) =
(-1,-0.737)   (0.359,0.869)  (0.342,-0.985)  (0.692,0.0539)
(0.511,-0.0827) (-0.233,0.0388) (-0.233,-0.866)  (-0.816,0.308)
(0.0655,-0.562)  (0.662,-0.931)  (-0.165,0.374)  (-0.168,0.402)
(-0.906,0.358) (-0.893,0.0594)   (0.178,0.861)   (0.821,0.524)


## ◆ 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;
static const ConstantReturnType Ones()
Definition: CwiseNullaryOp.h:670

Output:

The eigenvalues of the 3x3 matrix of ones are:
(0,-0)
(0,0)
(3,0)


## ◆ 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(1) << endl;

Output:

The first eigenvector of the 3x3 matrix of ones is:
(0.154,0)
(-0.772,0)
(0.617,0)


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

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