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::RealSchur< _MatrixType > Class Template Reference

## Detailed Description

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

Performs a real Schur decomposition of a 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 real Schur decomposition; this is expected to be an instantiation of the Matrix class template.

Given a real square matrix A, this class computes the real Schur decomposition: $$A = U T U^T$$ where U is a real orthogonal matrix and T is a real quasi-triangular matrix. An orthogonal matrix is a matrix whose inverse is equal to its transpose, $$U^{-1} = U^T$$. A quasi-triangular matrix is a block-triangular matrix whose diagonal consists of 1-by-1 blocks and 2-by-2 blocks with complex eigenvalues. The eigenvalues of the blocks on the diagonal of T are the same as the eigenvalues of the matrix A, and thus the real Schur decomposition is used in EigenSolver to compute the eigendecomposition of a matrix.

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

The documentation of RealSchur(const MatrixType&, bool) contains an example of the typical use of this class.

Note
The implementation is adapted from JAMA (public domain). Their code is based on EISPACK.
See also
class ComplexSchur, class EigenSolver, class ComplexEigenSolver

## Public Types

typedef Eigen::Index Index

## Public Member Functions

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

template<typename HessMatrixType , typename OrthMatrixType >
RealSchurcomputeFromHessenberg (const HessMatrixType &matrixH, const OrthMatrixType &matrixQ, bool computeU)
Computes Schur decomposition of a Hessenberg matrix H = Z T Z^T. More...

Index getMaxIterations ()
Returns the maximum number of iterations.

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

const MatrixType & matrixT () const
Returns the quasi-triangular matrix in the Schur decomposition. More...

const MatrixType & matrixU () const
Returns the orthogonal matrix in the Schur decomposition. More...

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

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

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

## ◆ Index

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

## ◆ RealSchur() [1/2]

template<typename _MatrixType >
 Eigen::RealSchur< _MatrixType >::RealSchur ( 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.

See also
compute() for an example.

## ◆ RealSchur() [2/2]

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

Constructor; computes real 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.

Example:

MatrixXd A = MatrixXd::Random(6,6);
cout << "Here is a random 6x6 matrix, A:" << endl << A << endl << endl;
RealSchur<MatrixXd> schur(A);
cout << "The orthogonal matrix U is:" << endl << schur.matrixU() << endl;
cout << "The quasi-triangular matrix T is:" << endl << schur.matrixT() << endl << endl;
MatrixXd U = schur.matrixU();
MatrixXd T = schur.matrixT();
cout << "U * T * U^T = " << endl << U * T * U.transpose() << endl;

Output:

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

The orthogonal matrix U is:
0.786  0.0316  0.0437  0.0862   0.223   0.567
0.0307  -0.586   0.151   -0.79   0.019   0.091
-0.577  -0.109   0.176   0.169   0.536   0.556
-0.0523  0.0377  -0.944  -0.196   0.245  0.0767
0.169   0.197   0.184  -0.148   0.766  -0.538
-0.13   0.777   0.136  -0.529  -0.126   0.257
The quasi-triangular matrix T is:
-1.49    1.46   0.539   0.223   0.905  -0.232
0 -0.0663   -1.21   0.128   0.602  -0.305
0    1.13   0.219   0.184  -0.732  0.0897
0       0       0   0.733   0.532    1.24
0       0       0       0  -0.261   0.346
0       0       0       0  -0.355  -0.806

U * T * U^T =
-1  -0.906   0.662  -0.233   0.692   0.821
-0.737   0.358  -0.931  -0.866  0.0539   0.524
0.511   0.359  -0.893  -0.165  -0.816  -0.475
-0.0827   0.869  0.0594   0.374   0.308  -0.905
0.0655  -0.233   0.342   0.178  -0.168   0.472
-0.562  0.0388  -0.985   0.861   0.402  -0.344


## ◆ compute()

template<typename _MatrixType >
template<typename InputType >
 RealSchur& Eigen::RealSchur< _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 Francis QR iterations with implicit double shift. The cost of computing the Schur decomposition depends on the number of iterations; as a rough guide, it may be taken to be $$25n^3$$ flops if computeU is true and $$10n^3$$ flops if computeU is false.

Example:

MatrixXf A = MatrixXf::Random(4,4);
RealSchur<MatrixXf> schur(4);
schur.compute(A, /* computeU = */ false);
cout << "The matrix T in the decomposition of A is:" << endl << schur.matrixT() << endl;
schur.compute(A.inverse(), /* computeU = */ false);
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:
-0.274   0.689   -1.03   0.281
-1.48  -0.305 -0.0119  -0.844
0       0   -1.04   0.576
0       0       0  -0.115
The matrix T in the decomposition of A^(-1) is:
-8.71 -0.138   5.05   5.17
0  0.098   1.29   1.55
0 -0.746 -0.622   -0.9
0      0      0  -0.96

See also
compute(const MatrixType&, bool, Index)

## ◆ computeFromHessenberg()

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

Computes Schur decomposition of a Hessenberg matrix H = Z T Z^T.

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())

See also
compute(const MatrixType&, bool)

## ◆ info()

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

Reports whether previous computation was successful.

Returns
Success if computation was succesful, NoConvergence otherwise.

## ◆ matrixT()

template<typename _MatrixType >
 const MatrixType& Eigen::RealSchur< _MatrixType >::matrixT ( ) const
inline

Returns the quasi-triangular matrix in the Schur decomposition.

Returns
A const reference to the matrix T.
Precondition
Either the constructor RealSchur(const MatrixType&, bool) or the member function compute(const MatrixType&, bool) has been called before to compute the Schur decomposition of a matrix.
See also
RealSchur(const MatrixType&, bool) for an example

## ◆ matrixU()

template<typename _MatrixType >
 const MatrixType& Eigen::RealSchur< _MatrixType >::matrixU ( ) const
inline

Returns the orthogonal matrix in the Schur decomposition.

Returns
A const reference to the matrix U.
Precondition
Either the constructor RealSchur(const MatrixType&, bool) or the member function compute(const MatrixType&, bool) has been called before to compute the Schur decomposition of a matrix, and computeU was set to true (the default value).
See also
RealSchur(const MatrixType&, bool) for an example

## ◆ setMaxIterations()

template<typename _MatrixType >
 RealSchur& Eigen::RealSchur< _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::RealSchur< _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 40.

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