Performs a real Schur decomposition of a square matrix. More...
#include <RealSchur.h>
Public Types | |
enum | { RowsAtCompileTime = MatrixType::RowsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime, Options = MatrixType::Options, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime } |
typedef Matrix< Scalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > | ColumnVectorType |
typedef std::complex< typename NumTraits< Scalar >::Real > | ComplexScalar |
typedef Matrix< ComplexScalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > | EigenvalueType |
typedef MatrixType::Index | Index |
typedef _MatrixType | MatrixType |
typedef MatrixType::Scalar | Scalar |
Public Member Functions | |
RealSchur & | compute (const MatrixType &matrix, bool computeU=true) |
Computes Schur decomposition of given matrix. | |
ComputationInfo | info () const |
Reports whether previous computation was successful. | |
const MatrixType & | matrixT () const |
Returns the quasi-triangular matrix in the Schur decomposition. | |
const MatrixType & | matrixU () const |
Returns the orthogonal matrix in the Schur decomposition. | |
RealSchur (Index size=RowsAtCompileTime==Dynamic?1:RowsAtCompileTime) | |
Default constructor. | |
RealSchur (const MatrixType &matrix, bool computeU=true) | |
Constructor; computes real Schur decomposition of given matrix. | |
Static Public Attributes | |
static const int | m_maxIterations = 40 |
Maximum number of iterations. | |
Private Types | |
typedef Matrix< Scalar, 3, 1 > | Vector3s |
Private Member Functions | |
Scalar | computeNormOfT () |
void | computeShift (Index iu, Index iter, Scalar &exshift, Vector3s &shiftInfo) |
Index | findSmallSubdiagEntry (Index iu, Scalar norm) |
void | initFrancisQRStep (Index il, Index iu, const Vector3s &shiftInfo, Index &im, Vector3s &firstHouseholderVector) |
void | performFrancisQRStep (Index il, Index im, Index iu, bool computeU, const Vector3s &firstHouseholderVector, Scalar *workspace) |
void | splitOffTwoRows (Index iu, bool computeU, Scalar exshift) |
Private Attributes | |
HessenbergDecomposition < MatrixType > | m_hess |
ComputationInfo | m_info |
bool | m_isInitialized |
MatrixType | m_matT |
MatrixType | m_matU |
bool | m_matUisUptodate |
ColumnVectorType | m_workspaceVector |
Performs a real Schur decomposition of a square matrix.
_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: 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.
Definition at line 68 of file RealSchur.h.
typedef Matrix<Scalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> RealSchur< _MatrixType >::ColumnVectorType |
Definition at line 84 of file RealSchur.h.
typedef std::complex<typename NumTraits<Scalar>::Real> RealSchur< _MatrixType >::ComplexScalar |
Definition at line 80 of file RealSchur.h.
typedef Matrix<ComplexScalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> RealSchur< _MatrixType >::EigenvalueType |
Definition at line 83 of file RealSchur.h.
typedef MatrixType::Index RealSchur< _MatrixType >::Index |
Definition at line 81 of file RealSchur.h.
typedef _MatrixType RealSchur< _MatrixType >::MatrixType |
Definition at line 71 of file RealSchur.h.
typedef MatrixType::Scalar RealSchur< _MatrixType >::Scalar |
Definition at line 79 of file RealSchur.h.
typedef Matrix<Scalar,3,1> RealSchur< _MatrixType >::Vector3s [private] |
Definition at line 206 of file RealSchur.h.
anonymous enum |
Definition at line 72 of file RealSchur.h.
RealSchur< _MatrixType >::RealSchur | ( | Index | size = RowsAtCompileTime==Dynamic ? 1 : RowsAtCompileTime | ) | [inline] |
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.
Definition at line 97 of file RealSchur.h.
RealSchur< _MatrixType >::RealSchur | ( | const MatrixType & | matrix, |
bool | computeU = true |
||
) | [inline] |
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:
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:
Definition at line 116 of file RealSchur.h.
RealSchur& RealSchur< _MatrixType >::compute | ( | const MatrixType & | 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 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:
Scalar RealSchur< _MatrixType >::computeNormOfT | ( | ) | [private] |
void RealSchur< _MatrixType >::computeShift | ( | Index | iu, |
Index | iter, | ||
Scalar & | exshift, | ||
Vector3s & | shiftInfo | ||
) | [private] |
Index RealSchur< _MatrixType >::findSmallSubdiagEntry | ( | Index | iu, |
Scalar | norm | ||
) | [private] |
ComputationInfo RealSchur< _MatrixType >::info | ( | ) | const [inline] |
Reports whether previous computation was successful.
Success
if computation was succesful, NoConvergence
otherwise. Definition at line 184 of file RealSchur.h.
void RealSchur< _MatrixType >::initFrancisQRStep | ( | Index | il, |
Index | iu, | ||
const Vector3s & | shiftInfo, | ||
Index & | im, | ||
Vector3s & | firstHouseholderVector | ||
) | [private] |
const MatrixType& RealSchur< _MatrixType >::matrixT | ( | ) | const [inline] |
Returns the quasi-triangular matrix in the Schur decomposition.
Definition at line 155 of file RealSchur.h.
const MatrixType& RealSchur< _MatrixType >::matrixU | ( | ) | const [inline] |
Returns the orthogonal matrix in the Schur decomposition.
computeU
was set to true (the default value).Definition at line 138 of file RealSchur.h.
void RealSchur< _MatrixType >::performFrancisQRStep | ( | Index | il, |
Index | im, | ||
Index | iu, | ||
bool | computeU, | ||
const Vector3s & | firstHouseholderVector, | ||
Scalar * | workspace | ||
) | [private] |
void RealSchur< _MatrixType >::splitOffTwoRows | ( | Index | iu, |
bool | computeU, | ||
Scalar | exshift | ||
) | [private] |
HessenbergDecomposition<MatrixType> RealSchur< _MatrixType >::m_hess [private] |
Definition at line 201 of file RealSchur.h.
ComputationInfo RealSchur< _MatrixType >::m_info [private] |
Definition at line 202 of file RealSchur.h.
bool RealSchur< _MatrixType >::m_isInitialized [private] |
Definition at line 203 of file RealSchur.h.
MatrixType RealSchur< _MatrixType >::m_matT [private] |
Definition at line 198 of file RealSchur.h.
MatrixType RealSchur< _MatrixType >::m_matU [private] |
Definition at line 199 of file RealSchur.h.
bool RealSchur< _MatrixType >::m_matUisUptodate [private] |
Definition at line 204 of file RealSchur.h.
const int RealSchur< _MatrixType >::m_maxIterations = 40 [static] |
Maximum number of iterations.
Maximum number of iterations allowed for an eigenvalue to converge.
Definition at line 194 of file RealSchur.h.
ColumnVectorType RealSchur< _MatrixType >::m_workspaceVector [private] |
Definition at line 200 of file RealSchur.h.