Tridiagonal decomposition of a selfadjoint matrix. More...
#include <Tridiagonalization.h>
Public Types | |
enum | { Size = MatrixType::RowsAtCompileTime, SizeMinusOne = Size == Dynamic ? Dynamic : (Size > 1 ? Size - 1 : 1), Options = MatrixType::Options, MaxSize = MatrixType::MaxRowsAtCompileTime, MaxSizeMinusOne = MaxSize == Dynamic ? Dynamic : (MaxSize > 1 ? MaxSize - 1 : 1) } |
typedef Matrix< Scalar, SizeMinusOne, 1, Options &~RowMajor, MaxSizeMinusOne, 1 > | CoeffVectorType |
typedef internal::conditional < NumTraits< Scalar > ::IsComplex, const typename Diagonal< const MatrixType > ::RealReturnType, const Diagonal< const MatrixType > >::type | DiagonalReturnType |
typedef internal::plain_col_type < MatrixType, RealScalar > ::type | DiagonalType |
typedef HouseholderSequence < MatrixType, CoeffVectorType > ::ConjugateReturnType | HouseholderSequenceType |
Return type of matrixQ() | |
typedef MatrixType::Index | Index |
typedef internal::TridiagonalizationMatrixTReturnType < MatrixTypeRealView > | MatrixTReturnType |
typedef _MatrixType | MatrixType |
Synonym for the template parameter _MatrixType . | |
typedef internal::remove_all < typename MatrixType::RealReturnType > ::type | MatrixTypeRealView |
typedef NumTraits< Scalar >::Real | RealScalar |
typedef MatrixType::Scalar | Scalar |
typedef internal::conditional < NumTraits< Scalar > ::IsComplex, const typename Diagonal< Block< const MatrixType, SizeMinusOne, SizeMinusOne > >::RealReturnType, const Diagonal< Block< const MatrixType, SizeMinusOne, SizeMinusOne > > >::type | SubDiagonalReturnType |
typedef Matrix< RealScalar, SizeMinusOne, 1, Options &~RowMajor, MaxSizeMinusOne, 1 > | SubDiagonalType |
Public Member Functions | |
Tridiagonalization & | compute (const MatrixType &matrix) |
Computes tridiagonal decomposition of given matrix. | |
DiagonalReturnType | diagonal () const |
Returns the diagonal of the tridiagonal matrix T in the decomposition. | |
CoeffVectorType | householderCoefficients () const |
Returns the Householder coefficients. | |
HouseholderSequenceType | matrixQ () const |
Returns the unitary matrix Q in the decomposition. | |
MatrixTReturnType | matrixT () const |
Returns an expression of the tridiagonal matrix T in the decomposition. | |
const MatrixType & | packedMatrix () const |
Returns the internal representation of the decomposition. | |
SubDiagonalReturnType | subDiagonal () const |
Returns the subdiagonal of the tridiagonal matrix T in the decomposition. | |
Tridiagonalization (Index size=Size==Dynamic?2:Size) | |
Default constructor. | |
Tridiagonalization (const MatrixType &matrix) | |
Constructor; computes tridiagonal decomposition of given matrix. | |
Protected Attributes | |
CoeffVectorType | m_hCoeffs |
bool | m_isInitialized |
MatrixType | m_matrix |
Tridiagonal decomposition of a selfadjoint matrix.
_MatrixType | the type of the matrix of which we are computing the tridiagonal decomposition; this is expected to be an instantiation of the Matrix class template. |
This class performs a tridiagonal decomposition of a selfadjoint matrix such that: where is unitary and a real symmetric tridiagonal matrix.
A tridiagonal matrix is a matrix which has nonzero elements only on the main diagonal and the first diagonal below and above it. The Hessenberg decomposition of a selfadjoint matrix is in fact a tridiagonal decomposition. This class is used in SelfAdjointEigenSolver to compute the eigenvalues and eigenvectors of a selfadjoint matrix.
Call the function compute() to compute the tridiagonal decomposition of a given matrix. Alternatively, you can use the Tridiagonalization(const MatrixType&) constructor which computes the tridiagonal Schur decomposition at construction time. Once the decomposition is computed, you can use the matrixQ() and matrixT() functions to retrieve the matrices Q and T in the decomposition.
The documentation of Tridiagonalization(const MatrixType&) contains an example of the typical use of this class.
Definition at line 74 of file Tridiagonalization.h.
typedef Matrix<Scalar, SizeMinusOne, 1, Options & ~RowMajor, MaxSizeMinusOne, 1> Tridiagonalization< _MatrixType >::CoeffVectorType |
Definition at line 93 of file Tridiagonalization.h.
typedef internal::conditional<NumTraits<Scalar>::IsComplex, const typename Diagonal<const MatrixType>::RealReturnType, const Diagonal<const MatrixType> >::type Tridiagonalization< _MatrixType >::DiagonalReturnType |
Definition at line 102 of file Tridiagonalization.h.
typedef internal::plain_col_type<MatrixType, RealScalar>::type Tridiagonalization< _MatrixType >::DiagonalType |
Definition at line 94 of file Tridiagonalization.h.
typedef HouseholderSequence<MatrixType,CoeffVectorType>::ConjugateReturnType Tridiagonalization< _MatrixType >::HouseholderSequenceType |
Return type of matrixQ()
Definition at line 112 of file Tridiagonalization.h.
typedef MatrixType::Index Tridiagonalization< _MatrixType >::Index |
Definition at line 83 of file Tridiagonalization.h.
typedef internal::TridiagonalizationMatrixTReturnType<MatrixTypeRealView> Tridiagonalization< _MatrixType >::MatrixTReturnType |
Definition at line 97 of file Tridiagonalization.h.
typedef _MatrixType Tridiagonalization< _MatrixType >::MatrixType |
Synonym for the template parameter _MatrixType
.
Definition at line 79 of file Tridiagonalization.h.
typedef internal::remove_all<typename MatrixType::RealReturnType>::type Tridiagonalization< _MatrixType >::MatrixTypeRealView |
Definition at line 96 of file Tridiagonalization.h.
typedef NumTraits<Scalar>::Real Tridiagonalization< _MatrixType >::RealScalar |
Definition at line 82 of file Tridiagonalization.h.
typedef MatrixType::Scalar Tridiagonalization< _MatrixType >::Scalar |
Definition at line 81 of file Tridiagonalization.h.
typedef internal::conditional<NumTraits<Scalar>::IsComplex, const typename Diagonal< Block<const MatrixType,SizeMinusOne,SizeMinusOne> >::RealReturnType, const Diagonal< Block<const MatrixType,SizeMinusOne,SizeMinusOne> > >::type Tridiagonalization< _MatrixType >::SubDiagonalReturnType |
Definition at line 109 of file Tridiagonalization.h.
typedef Matrix<RealScalar, SizeMinusOne, 1, Options & ~RowMajor, MaxSizeMinusOne, 1> Tridiagonalization< _MatrixType >::SubDiagonalType |
Definition at line 95 of file Tridiagonalization.h.
anonymous enum |
Definition at line 85 of file Tridiagonalization.h.
Tridiagonalization< _MatrixType >::Tridiagonalization | ( | Index | size = Size==Dynamic ? 2 : Size | ) | [inline] |
Default constructor.
[in] | size | Positive integer, size of the matrix whose tridiagonal 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 126 of file Tridiagonalization.h.
Tridiagonalization< _MatrixType >::Tridiagonalization | ( | const MatrixType & | matrix | ) | [inline] |
Constructor; computes tridiagonal decomposition of given matrix.
[in] | matrix | Selfadjoint matrix whose tridiagonal decomposition is to be computed. |
This constructor calls compute() to compute the tridiagonal decomposition.
Example:
MatrixXd X = MatrixXd::Random(5,5); MatrixXd A = X + X.transpose(); cout << "Here is a random symmetric 5x5 matrix:" << endl << A << endl << endl; Tridiagonalization<MatrixXd> triOfA(A); MatrixXd Q = triOfA.matrixQ(); cout << "The orthogonal matrix Q is:" << endl << Q << endl; MatrixXd T = triOfA.matrixT(); cout << "The tridiagonal matrix T is:" << endl << T << endl << endl; cout << "Q * T * Q^T = " << endl << Q * T * Q.transpose() << endl;
Output:
Definition at line 142 of file Tridiagonalization.h.
Tridiagonalization& Tridiagonalization< _MatrixType >::compute | ( | const MatrixType & | matrix | ) | [inline] |
Computes tridiagonal decomposition of given matrix.
[in] | matrix | Selfadjoint matrix whose tridiagonal decomposition is to be computed. |
*this
The tridiagonal decomposition is computed by bringing the columns of the matrix successively in the required form using Householder reflections. The cost is flops, where denotes the size of the given matrix.
This method reuses of the allocated data in the Tridiagonalization object, if the size of the matrix does not change.
Example:
Tridiagonalization<MatrixXf> tri; MatrixXf X = MatrixXf::Random(4,4); MatrixXf A = X + X.transpose(); tri.compute(A); cout << "The matrix T in the tridiagonal decomposition of A is: " << endl; cout << tri.matrixT() << endl; tri.compute(2*A); // re-use tri to compute eigenvalues of 2A cout << "The matrix T in the tridiagonal decomposition of 2A is: " << endl; cout << tri.matrixT() << endl;
Output:
Definition at line 168 of file Tridiagonalization.h.
Tridiagonalization< MatrixType >::DiagonalReturnType Tridiagonalization< MatrixType >::diagonal | ( | ) | const |
Returns the diagonal of the tridiagonal matrix T in the decomposition.
Example:
MatrixXcd X = MatrixXcd::Random(4,4); MatrixXcd A = X + X.adjoint(); cout << "Here is a random self-adjoint 4x4 matrix:" << endl << A << endl << endl; Tridiagonalization<MatrixXcd> triOfA(A); MatrixXd T = triOfA.matrixT(); cout << "The tridiagonal matrix T is:" << endl << T << endl << endl; cout << "We can also extract the diagonals of T directly ..." << endl; VectorXd diag = triOfA.diagonal(); cout << "The diagonal is:" << endl << diag << endl; VectorXd subdiag = triOfA.subDiagonal(); cout << "The subdiagonal is:" << endl << subdiag << endl;
Output:
Definition at line 318 of file Tridiagonalization.h.
CoeffVectorType Tridiagonalization< _MatrixType >::householderCoefficients | ( | ) | const [inline] |
Returns the Householder coefficients.
The Householder coefficients allow the reconstruction of the matrix in the tridiagonal decomposition from the packed data.
Example:
Matrix4d X = Matrix4d::Random(4,4); Matrix4d A = X + X.transpose(); cout << "Here is a random symmetric 4x4 matrix:" << endl << A << endl; Tridiagonalization<Matrix4d> triOfA(A); Vector3d hc = triOfA.householderCoefficients(); cout << "The vector of Householder coefficients is:" << endl << hc << endl;
Output:
Definition at line 193 of file Tridiagonalization.h.
HouseholderSequenceType Tridiagonalization< _MatrixType >::matrixQ | ( | void | ) | const [inline] |
Returns the unitary matrix Q in the decomposition.
This function returns a light-weight object of template class HouseholderSequence. You can either apply it directly to a matrix or you can convert it to a matrix of type MatrixType.
Definition at line 251 of file Tridiagonalization.h.
MatrixTReturnType Tridiagonalization< _MatrixType >::matrixT | ( | ) | const [inline] |
Returns an expression of the tridiagonal matrix T in the decomposition.
Currently, this function can be used to extract the matrix T from internal data and copy it to a dense matrix object. In most cases, it may be sufficient to directly use the packed matrix or the vector expressions returned by diagonal() and subDiagonal() instead of creating a new dense copy matrix with this function.
Definition at line 276 of file Tridiagonalization.h.
const MatrixType& Tridiagonalization< _MatrixType >::packedMatrix | ( | ) | const [inline] |
Returns the internal representation of the decomposition.
The returned matrix contains the following information:
See LAPACK for further details on this packed storage.
Example:
Matrix4d X = Matrix4d::Random(4,4); Matrix4d A = X + X.transpose(); cout << "Here is a random symmetric 4x4 matrix:" << endl << A << endl; Tridiagonalization<Matrix4d> triOfA(A); Matrix4d pm = triOfA.packedMatrix(); cout << "The packed matrix M is:" << endl << pm << endl; cout << "The diagonal and subdiagonal corresponds to the matrix T, which is:" << endl << triOfA.matrixT() << endl;
Output:
Definition at line 230 of file Tridiagonalization.h.
Tridiagonalization< MatrixType >::SubDiagonalReturnType Tridiagonalization< MatrixType >::subDiagonal | ( | ) | const |
Returns the subdiagonal of the tridiagonal matrix T in the decomposition.
Definition at line 326 of file Tridiagonalization.h.
CoeffVectorType Tridiagonalization< _MatrixType >::m_hCoeffs [protected] |
Definition at line 312 of file Tridiagonalization.h.
bool Tridiagonalization< _MatrixType >::m_isInitialized [protected] |
Definition at line 313 of file Tridiagonalization.h.
MatrixType Tridiagonalization< _MatrixType >::m_matrix [protected] |
Definition at line 311 of file Tridiagonalization.h.