![]() |
Eigen
5.0.1
|
#include <Eigen/src/Eigenvalues/RealSchur.h>
Performs a real Schur decomposition of a square matrix.
This is defined in the Eigenvalues module.
| 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.
Public Types | |
| using | Index |
| using | MatrixUType |
Type of the matrix returned by matrixU(): a plain matrix with the shape and storage options of MatrixType_, and MatrixType_ itself unless that is a Ref<>. | |
Public Member Functions | |
| template<typename InputType> | |
| RealSchur & | compute (const EigenBase< InputType > &matrix, bool computeU=true) |
| Computes Schur decomposition of given matrix. | |
| template<typename HessMatrixType, typename OrthMatrixType> | |
| RealSchur & | computeFromHessenberg (const HessMatrixType &matrixH, const OrthMatrixType &matrixQ, bool computeU) |
| Computes Schur decomposition of a Hessenberg matrix H = Z T Z^T. | |
| Index | getMaxIterations () const |
| Returns the maximum number of iterations. | |
| ComputationInfo | info () const |
| Reports whether previous computation was successful. | |
| const MatrixType & | matrixT () const |
| Returns the quasi-triangular matrix in the Schur decomposition. | |
| const MatrixUType & | matrixU () const |
| Returns the orthogonal matrix in the Schur decomposition. | |
| template<typename InputType> | |
| RealSchur (const EigenBase< InputType > &matrix, bool computeU=true) | |
| Constructor; computes real Schur decomposition of given matrix. | |
| template<typename InputType, bool IsRef = internal::is_ref<MatrixType>::value, std::enable_if_t< IsRef, int > = 0> | |
| RealSchur (EigenBase< InputType > &matrix, bool computeU=true) | |
| Constructor for inplace decomposition . | |
| RealSchur (Index size=RowsAtCompileTime==Dynamic ? 1 :RowsAtCompileTime) | |
| Default constructor. | |
| RealSchur & | setMaxIterations (Index maxIters) |
| Sets the maximum number of iterations allowed. | |
Static Public Attributes | |
| static const int | m_maxIterationsPerRow |
| Maximum number of iterations per row. | |
| using Eigen::RealSchur< MatrixType_ >::Index |
|
inlineexplicit |
Default constructor.
| [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.
|
inlineexplicit |
Constructor; computes real Schur decomposition of given matrix.
| [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:
Output:
Here is a random 6x6 matrix, A:
-0.211 0.0268 -0.198 0.946 0.899 0.941
0.597 0.832 -0.782 0.543 -0.828 0.702
-0.605 0.435 -0.563 0.54 0.326 0.0795
0.536 0.214 0.678 0.783 -0.302 0.52
0.108 -0.514 -0.408 -0.295 -0.96 0.335
0.258 0.608 0.0486 0.838 -0.874 -0.921
The orthogonal matrix U is:
-0.331 0.669 0.345 0.44 0.153 0.326
-0.653 0.148 -0.692 0.0398 -0.0654 -0.257
-0.142 -0.594 0.0246 0.757 -0.197 0.12
-0.54 -0.218 0.625 -0.217 0.00338 -0.472
0.134 0.293 0.0952 0.0414 -0.922 -0.189
-0.366 -0.21 0.0264 -0.427 -0.289 0.745
The quasi-triangular matrix T is:
1.98 -0.0511 -0.408 0.5 -0.385 0.195
0 0.0609 0.381 -0.44 -0.391 0.761
0 -0.631 0.625 0.41 -0.751 -0.0225
0 0 0 -1.25 -1.13 -0.0843
0 0 0 0.355 -1.3 -0.247
0 0 0 0 0 -1.15
U * T * U^T =
-0.211 0.0268 -0.198 0.946 0.899 0.941
0.597 0.832 -0.782 0.543 -0.828 0.702
-0.605 0.435 -0.563 0.54 0.326 0.0795
0.536 0.214 0.678 0.783 -0.302 0.52
0.108 -0.514 -0.408 -0.295 -0.96 0.335
0.258 0.608 0.0486 0.838 -0.874 -0.921
|
inlineexplicit |
Constructor for inplace decomposition .
| [in,out] | 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. |
When MatrixType is a Ref<>, matrix holds the quasi-triangular matrix T returned by matrixT(); U is stored in the decomposition object. For an n-by-n matrix with n >= 128 and an outer stride in bytes divisible by 1024, the computation uses a temporary padded workspace of n*(n+1) coefficients and copies T back to matrix. Otherwise, it computes directly in the bound storage.
To avoid padding, bind a Ref<> whose outer stride in bytes is not divisible by 1024. EIGEN_NO_MALLOC, or disabling allocation or deallocation through EIGEN_RUNTIME_NO_MALLOC, also suppresses padding, which may reduce performance. These controls do not remove other allocations, such as solver storage or Schur vectors; the inplace constructor is not guaranteed to be allocation-free.
This overload is only available for Ref<>; owning matrix types use the constructor taking a const input.
| RealSchur & Eigen::RealSchur< MatrixType_ >::compute | ( | const EigenBase< InputType > & | matrix, |
| bool | computeU = true ) |
Computes Schur decomposition of given matrix.
| [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 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.
To avoid cache-conflicting strides, this routine may allocate a temporary padded workspace even when the solver was constructed with the correct size. With EIGEN_NO_MALLOC, or when allocation or deallocation is disabled through EIGEN_RUNTIME_NO_MALLOC, it uses the unpadded workspace instead, which may be slower. This only suppresses padding; resizing solver storage and constructing Schur vectors may still allocate.
Example:
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.41 6.03
0.168 -2.62 -2.88 4.2
0 0 0.389 0.667
0 0 -0.956 1.39
| 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.
| [in] | matrixH | Matrix in Hessenberg form H |
| [in] | matrixQ | orthogonal matrix Q that transforms a matrix A to H : A = Q H Q^T |
| computeU | Computes the matrix U of the Schur vectors |
*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())
This routine may allocate a temporary padded workspace to avoid cache-conflicting strides. With EIGEN_NO_MALLOC, or when allocation or deallocation is disabled through EIGEN_RUNTIME_NO_MALLOC, it uses the unpadded workspace instead, which may be slower. Other allocations, such as resizing solver storage or evaluating input expressions, are unaffected.
|
inline |
Reports whether previous computation was successful.
Success if computation was successful, NoConvergence otherwise.
|
inline |
Returns the quasi-triangular matrix in the Schur decomposition.
|
inline |
Returns the orthogonal matrix in the Schur decomposition.
computeU was set to true (the default value).
|
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.
|
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.