template<typename _MatrixType>
RealSchur class
Performs a real Schur decomposition of a square matrix.
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. |
Contents
This is defined in the Eigenvalues module. #include <Eigen/Eigenvalues>
Given a real square matrix A, this class computes the real Schur decomposition: 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, . 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.
Public types
-
using Index = Eigen::
Index deprecated
Public static variables
- static const int m_maxIterationsPerRow
- Maximum number of iterations per row.
Constructors, destructors, conversion operators
Public functions
-
template<typename InputType>auto compute(const EigenBase<InputType>& matrix, bool computeU = true) -> RealSchur&
- Computes Schur decomposition of given matrix.
-
template<typename HessMatrixType, typename OrthMatrixType>auto computeFromHessenberg(const HessMatrixType& matrixH, const OrthMatrixType& matrixQ, bool computeU) -> RealSchur&
- Computes Schur decomposition of a Hessenberg matrix H = Z T Z^T.
- auto getMaxIterations() -> Index
- Returns the maximum number of iterations.
- auto info() const -> ComputationInfo
- Reports whether previous computation was successful.
- auto matrixT() const -> const MatrixType&
- Returns the quasi-triangular matrix in the Schur decomposition.
- auto matrixU() const -> const MatrixType&
- Returns the orthogonal matrix in the Schur decomposition.
- auto setMaxIterations(Index maxIters) -> RealSchur&
- Sets the maximum number of iterations allowed.
Typedef documentation
template<typename _MatrixType>
typedef Eigen:: Index Eigen:: RealSchur<_MatrixType>:: Index
Function documentation
template<typename _MatrixType>
Eigen:: RealSchur<_MatrixType>:: RealSchur(Index size = RowsAtCompileTime==Dynamic ? 1 :RowsAtCompileTime) explicit
Default constructor.
Parameters | |
---|---|
size in | 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.
template<typename _MatrixType>
template<typename InputType>
Eigen:: RealSchur<_MatrixType>:: RealSchur(const EigenBase<InputType>& matrix,
bool computeU = true) explicit
Constructor; computes real Schur decomposition of given matrix.
Parameters | |
---|---|
matrix in | Square matrix whose Schur decomposition is to be computed. |
computeU in | 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: 0.68 -0.33 -0.27 -0.717 -0.687 0.0259 -0.211 0.536 0.0268 0.214 -0.198 0.678 0.566 -0.444 0.904 -0.967 -0.74 0.225 0.597 0.108 0.832 -0.514 -0.782 -0.408 0.823 -0.0452 0.271 -0.726 0.998 0.275 -0.605 0.258 0.435 0.608 -0.563 0.0486 The orthogonal matrix U is: 0.348 -0.754 0.00435 -0.351 0.0146 0.432 -0.16 -0.266 -0.747 0.457 -0.366 0.0571 0.505 -0.157 0.0746 0.644 0.518 -0.177 0.703 0.324 -0.409 -0.349 -0.187 -0.275 0.296 0.372 0.24 0.324 -0.379 0.684 -0.126 0.305 -0.46 -0.161 0.647 0.485 The quasi-triangular matrix T is: -0.2 -1.83 0.864 0.271 1.09 0.139 0.647 0.298 -0.0536 0.676 -0.288 0.0231 0 0 0.967 -0.201 -0.429 0.847 0 0 0 0.353 0.603 0.694 0 0 0 0 0.572 -1.03 0 0 0 0 0.0184 0.664 U * T * U^T = 0.68 -0.33 -0.27 -0.717 -0.687 0.0259 -0.211 0.536 0.0268 0.214 -0.198 0.678 0.566 -0.444 0.904 -0.967 -0.74 0.225 0.597 0.108 0.832 -0.514 -0.782 -0.408 0.823 -0.0452 0.271 -0.726 0.998 0.275 -0.605 0.258 0.435 0.608 -0.563 0.0486
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 | |
---|---|
matrix in | Square matrix whose Schur decomposition is to be computed. |
computeU in | 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 flops if computeU is true and 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.523 -0.698 0.148 0.742 0.475 0.986 -0.793 0.721 0 0 -0.28 -0.77 0 0 0.0145 -0.367 The matrix T in the decomposition of A^(-1) is: -3.06 -4.57 -5.97 5.48 0.168 -2.62 -3.27 3.9 0 0 0.427 0.573 0 0 -1.05 1.35
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 | |
---|---|
matrixH in | Matrix in Hessenberg form H |
matrixQ in | 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())
template<typename _MatrixType>
ComputationInfo Eigen:: RealSchur<_MatrixType>:: info() const
Reports whether previous computation was successful.
Returns | Success if computation was successful, NoConvergence otherwise. |
---|
template<typename _MatrixType>
const MatrixType& Eigen:: RealSchur<_MatrixType>:: matrixT() const
Returns the quasi-triangular matrix in the Schur decomposition.
Returns | A const reference to the matrix T. |
---|
template<typename _MatrixType>
const MatrixType& Eigen:: RealSchur<_MatrixType>:: matrixU() const
Returns the orthogonal matrix in the Schur decomposition.
Returns | A const reference to the matrix U. |
---|
template<typename _MatrixType>
RealSchur& Eigen:: RealSchur<_MatrixType>:: setMaxIterations(Index maxIters)
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.
Variable documentation
template<typename _MatrixType>
static const int Eigen:: RealSchur<_MatrixType>:: m_maxIterationsPerRow
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.