Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
 Eigen  3.3.9
Eigen::ComplexSchur< _MatrixType > Class Template Reference

## Detailed Description

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

Performs a complex Schur decomposition of a real or complex square matrix.

This is defined in the Eigenvalues module.

#include <Eigen/Eigenvalues>
Template Parameters
 _MatrixType the type of the matrix of which we are computing the Schur decomposition; this is expected to be an instantiation of the Matrix class template.

Given a real or complex square matrix A, this class computes the Schur decomposition: $$A = U T U^*$$ where U is a unitary complex matrix, and T is a complex upper triangular matrix. The diagonal of the matrix T corresponds to the eigenvalues of the matrix A.

Call the function compute() to compute the Schur decomposition of a given matrix. Alternatively, you can use the ComplexSchur(const MatrixType&, bool) constructor which computes the Schur decomposition at construction time. Once the decomposition is computed, you can use the matrixU() and matrixT() functions to retrieve the matrices U and V in the decomposition.

Note
This code is inspired from Jampack
class RealSchur, class EigenSolver, class ComplexEigenSolver

## Public Types

typedef Matrix< ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime > ComplexMatrixType
Type for the matrices in the Schur decomposition. More...

typedef std::complex< RealScalar > ComplexScalar
Complex scalar type for _MatrixType. More...

typedef Eigen::Index Index

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

## Public Member Functions

template<typename InputType >
ComplexSchur (const EigenBase< InputType > &matrix, bool computeU=true)
Constructor; computes Schur decomposition of given matrix. More...

ComplexSchur (Index size=RowsAtCompileTime==Dynamic ? 1 :RowsAtCompileTime)
Default constructor. More...

template<typename InputType >
ComplexSchurcompute (const EigenBase< InputType > &matrix, bool computeU=true)
Computes Schur decomposition of given matrix. More...

template<typename HessMatrixType , typename OrthMatrixType >
ComplexSchurcomputeFromHessenberg (const HessMatrixType &matrixH, const OrthMatrixType &matrixQ, bool computeU=true)
Compute Schur decomposition from a given Hessenberg matrix. More...

Index getMaxIterations ()
Returns the maximum number of iterations.

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

const ComplexMatrixTypematrixT () const
Returns the triangular matrix in the Schur decomposition. More...

const ComplexMatrixTypematrixU () const
Returns the unitary matrix in the Schur decomposition. More...

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

## Static Public Attributes

static const int m_maxIterationsPerRow
Maximum number of iterations per row. More...

## ◆ ComplexMatrixType

template<typename _MatrixType >
 typedef Matrix Eigen::ComplexSchur< _MatrixType >::ComplexMatrixType

Type for the matrices in the Schur decomposition.

This is a square matrix with entries of type ComplexScalar. The size is the same as the size of _MatrixType.

## ◆ ComplexScalar

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

## ◆ Index

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

## ◆ ComplexSchur() [1/2]

template<typename _MatrixType >
 Eigen::ComplexSchur< _MatrixType >::ComplexSchur ( Index size = RowsAtCompileTime==Dynamic ? 1 : RowsAtCompileTime )
inlineexplicit

Default constructor.

Parameters
 [in] size Positive integer, size of the matrix whose Schur decomposition will be computed.

The default constructor is useful in cases in which the user intends to perform decompositions via compute(). The size parameter is only used as a hint. It is not an error to give a wrong size, but it may impair performance.

compute() for an example.

## ◆ ComplexSchur() [2/2]

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

Constructor; computes Schur decomposition of given matrix.

Parameters
 [in] matrix Square matrix whose Schur decomposition is to be computed. [in] computeU If true, both T and U are computed; if false, only T is computed.

This constructor calls compute() to compute the Schur decomposition.

matrixT() and matrixU() for examples.

## ◆ compute()

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

Computes Schur decomposition of given matrix.

Parameters
 [in] matrix Square matrix whose Schur decomposition is to be computed. [in] computeU If true, both T and U are computed; if false, only T is computed.
Returns
Reference to *this

The Schur decomposition is computed by first reducing the matrix to Hessenberg form using the class HessenbergDecomposition. The Hessenberg matrix is then reduced to triangular form by performing QR iterations with a single shift. The cost of computing the Schur decomposition depends on the number of iterations; as a rough guide, it may be taken on the number of iterations; as a rough guide, it may be taken to be $$25n^3$$ complex flops, or $$10n^3$$ complex flops if computeU is false.

Example:

MatrixXcf A = MatrixXcf::Random(4,4);
ComplexSchur<MatrixXcf> schur(4);
schur.compute(A);
cout << "The matrix T in the decomposition of A is:" << endl << schur.matrixT() << endl;
schur.compute(A.inverse());
cout << "The matrix T in the decomposition of A^(-1) is:" << endl << schur.matrixT() << endl;

Output:

The matrix T in the decomposition of A is:
(-1.1,-1.04)  (-0.575,-0.764) (-0.858,-0.0311)      (-0.1,0.43)
(0,0)   (0.567,-0.864)      (1.26,1.08)  (-0.134,0.0777)
(0,0)            (0,0)     (0.322,1.19)   (-0.859,0.369)
(0,0)            (0,0)            (0,0)   (-0.366,0.914)
The matrix T in the decomposition of A^(-1) is:
(0.531,0.809)   (0.524,-0.315)    (-1.37,-0.93)    (1.51,-0.665)
(0,0)   (-0.481,0.454)     (0.513,0.49) (-0.486,-0.0144)
(0,0)            (0,0)  (-0.377,-0.943)    (0.486,0.598)
(0,0)            (0,0)            (0,0)   (0.213,-0.784)

compute(const MatrixType&, bool, Index)

## ◆ computeFromHessenberg()

template<typename _MatrixType >
template<typename HessMatrixType , typename OrthMatrixType >
 ComplexSchur& Eigen::ComplexSchur< _MatrixType >::computeFromHessenberg ( const HessMatrixType & matrixH, const OrthMatrixType & matrixQ, bool computeU = true )

Compute Schur decomposition from a given Hessenberg matrix.

Parameters
 [in] matrixH Matrix in Hessenberg form H [in] matrixQ orthogonal matrix Q that transform a matrix A to H : A = Q H Q^T computeU Computes the matriX U of the Schur vectors
Returns
Reference to *this

This routine assumes that the matrix is already reduced in Hessenberg form matrixH using either the class HessenbergDecomposition or another mean. It computes the upper quasi-triangular matrix T of the Schur decomposition of H When computeU is true, this routine computes the matrix U such that A = U T U^T = (QZ) T (QZ)^T = Q H Q^T where A is the initial matrix

NOTE Q is referenced if computeU is true; so, if the initial orthogonal matrix is not available, the user should give an identity matrix (Q.setIdentity())

compute(const MatrixType&, bool)

## ◆ info()

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

Reports whether previous computation was successful.

Returns
Success if computation was succesful, NoConvergence otherwise.

## ◆ matrixT()

template<typename _MatrixType >
 const ComplexMatrixType& Eigen::ComplexSchur< _MatrixType >::matrixT ( ) const
inline

Returns the triangular matrix in the Schur decomposition.

Returns
A const reference to the matrix T.

It is assumed that either the constructor ComplexSchur(const MatrixType& matrix, bool computeU) or the member function compute(const MatrixType& matrix, bool computeU) has been called before to compute the Schur decomposition of a matrix.

Note that this function returns a plain square matrix. If you want to reference only the upper triangular part, use:

schur.matrixT().triangularView<Upper>()

Example:

MatrixXcf A = MatrixXcf::Random(4,4);
cout << "Here is a random 4x4 matrix, A:" << endl << A << endl << endl;
ComplexSchur<MatrixXcf> schurOfA(A, false); // false means do not compute U
cout << "The triangular matrix T is:" << endl << schurOfA.matrixT() << endl;

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 triangular matrix T is:
(-1.1,-1.04)  (-0.575,-0.764) (-0.858,-0.0311)      (-0.1,0.43)
(0,0)   (0.567,-0.864)      (1.26,1.08)  (-0.134,0.0777)
(0,0)            (0,0)     (0.322,1.19)   (-0.859,0.369)
(0,0)            (0,0)            (0,0)   (-0.366,0.914)


## ◆ matrixU()

template<typename _MatrixType >
 const ComplexMatrixType& Eigen::ComplexSchur< _MatrixType >::matrixU ( ) const
inline

Returns the unitary matrix in the Schur decomposition.

Returns
A const reference to the matrix U.

It is assumed that either the constructor ComplexSchur(const MatrixType& matrix, bool computeU) or the member function compute(const MatrixType& matrix, bool computeU) has been called before to compute the Schur decomposition of a matrix, and that computeU was set to true (the default value).

Example:

MatrixXcf A = MatrixXcf::Random(4,4);
cout << "Here is a random 4x4 matrix, A:" << endl << A << endl << endl;
ComplexSchur<MatrixXcf> schurOfA(A);
cout << "The unitary matrix U is:" << endl << schurOfA.matrixU() << endl;

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 unitary matrix U is:
(-0.852,0.3) (-0.307,-0.00588)   (-0.199,-0.196) (-0.0793,-0.0805)
(0.206,-0.268)    (-0.178,0.452)   (-0.356,-0.319)   (-0.566,-0.317)
(0.000899,-0.059)      (-0.4,0.465)    (0.487,-0.222)    (0.0198,0.577)
(-0.0861,0.244)    (0.529,-0.117)    (0.516,-0.376)  (-0.476,-0.0772)


## ◆ setMaxIterations()

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

Sets the maximum number of iterations allowed.

If not specified by the user, the maximum number of iterations is m_maxIterationsPerRow times the size of the matrix.

## ◆ m_maxIterationsPerRow

template<typename _MatrixType >
 const int Eigen::ComplexSchur< _MatrixType >::m_maxIterationsPerRow
static

Maximum number of iterations per row.

If not otherwise specified, the maximum number of iterations is this number times the size of the matrix. It is currently set to 30.

The documentation for this class was generated from the following file:
Eigen::Upper
@ Upper
Definition: Constants.h:206
Eigen::DenseBase::Random
static const RandomReturnType Random()
Definition: Random.h:113