Class xlifepp::RealSchur#
-
template<typename _MatrixType>
class RealSchur#
-
Inheritence diagram for xlifepp::RealSchur:
Collaboration diagram for xlifepp::RealSchur:
Performs a real Schur decomposition of a square matrix.
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.
- 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.
Note
The implementation is adapted from JAMA (public domain). Their code is based on EISPACK.
Public Functions
-
inline RealSchur(const MatrixType &matrix, bool computeU = true)#
-
Constructor; computes real Schur decomposition of given matrix.
This constructor calls compute() to compute the Schur decomposition.
- 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.
-
inline RealSchur(Index size)#
-
Default constructor.
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 wrongsize
, but it may impair performance.See also
compute() for an example.
- Parameters:
-
size – [in] Positive integer, size of the matrix whose Schur decomposition will be computed.
-
RealSchur<MatrixType> &compute(const MatrixType &matrix, bool computeU = true)#
-
Computes Schur decomposition of given matrix.
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.
- 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
-
inline ComputationInfo info() const#
-
Reports whether previous computation was successful.
- Returns:
-
Success
if computation was succesful,NoConvergence
otherwise.
-
inline const MatrixType &matrixT() const#
-
Returns the quasi-triangular matrix in the Schur decomposition.
- Returns:
-
A const reference to the matrix T.
- Pre:
-
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.
-
inline const MatrixType &matrixU() const#
-
Returns the orthogonal matrix in the Schur decomposition.
See also
RealSchur(const MatrixType&, bool) for an example
- Returns:
-
A const reference to the matrix U.
- Pre:
-
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).
-
void swapSchur(unsigned int ifst, unsigned int ilst, bool computeU)#
-
Reorder block diagonal of quasi-triagular from row ifst to row with index ilst.