Class xlifepp::HessenbergDecomposition#
-
template<typename _MatrixType>
class HessenbergDecomposition#
-
Inheritence diagram for xlifepp::HessenbergDecomposition:
Collaboration diagram for xlifepp::HessenbergDecomposition:
Reduces a square matrix to Hessenberg form by an orthogonal similarity transformation.
This class performs an Hessenberg decomposition of a matrix \( A \). In the real case, the Hessenberg decomposition consists of an orthogonal matrix \( Q \) and a Hessenberg matrix \( H \) such that \( A = Q H Q^T \). An orthogonal matrix is a matrix whose inverse equals its transpose ( \( Q^{-1} = Q^T \)). A Hessenberg matrix has zeros below the subdiagonal, so it is almost upper triangular. The Hessenberg decomposition of a complex matrix is \( A = Q H Q^* \) with \( Q \) unitary (that is, \( Q^{-1} = Q^* \)).
Call the function compute() to compute the Hessenberg decomposition of a given matrix. Alternatively, you can use the HessenbergDecomposition(const MatrixType&) constructor which computes the Hessenberg decomposition at construction time. Once the decomposition is computed, you can use the matrixH() and matrixQ() functions to construct the matrices H and Q in the decomposition.
- Template Parameters:
-
_MatrixType – the type of the matrix of which we are computing the Hessenberg decomposition
Public Types
-
typedef VectorEigenDense<Scalar> CoeffVectorType#
-
Type for vector of Householder coefficients.
This is column vector with entries of type Scalar. The length of the vector is one less than the size of MatrixType,
-
typedef HouseholderSequence<MatrixType, CoeffVectorType>::ConjugateReturnType HouseholderSequenceType#
-
Return type of matrixQ()
-
typedef _MatrixType MatrixType#
-
Synonym for the template parameter
_MatrixType
.
-
typedef MatrixType::type_t Scalar#
-
Scalar type for matrices of type MatrixType.
Public Functions
-
inline HessenbergDecomposition(const MatrixType &matrix)#
-
Constructor; computes Hessenberg decomposition of given matrix.
This constructor calls compute() to compute the Hessenberg decomposition.
See also
matrixH() for an example.
- Parameters:
-
matrix – [in] Square matrix whose Hessenberg decomposition is to be computed.
-
inline HessenbergDecomposition(number_t size)#
-
Default constructor; the decomposition will be computed later.
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] The size of the matrix whose Hessenberg decomposition will be computed.
-
inline HessenbergDecomposition &compute(const MatrixType &matrix)#
-
Computes Hessenberg decomposition of given matrix.
The Hessenberg decomposition is computed by bringing the columns of the matrix successively in the required form using Householder reflections (see, e.g., Algorithm 7.4.2 in Golub & Van Loan, Matrix Computations). The cost is \( 10n^3/3 \) flops, where \( n \) denotes the size of the given matrix.
This method reuses of the allocated data in the HessenbergDecomposition object.
- Parameters:
-
matrix – [in] Square matrix whose Hessenberg decomposition is to be computed.
- Returns:
-
Reference to
*this
-
inline const CoeffVectorType &householderCoefficients() const#
-
Returns the Householder coefficients.
The Householder coefficients allow the reconstruction of the matrix \( Q \) in the Hessenberg decomposition from the packed data.
- Returns:
-
a const reference to the vector of Householder coefficients
- Pre:
-
Either the constructor HessenbergDecomposition(const MatrixType&) or the member function compute(const MatrixType&) has been called before to compute the Hessenberg decomposition of a matrix.
-
inline MatrixType matrixH() const#
-
Constructs the Hessenberg matrix H in the decomposition.
The object returned by this function constructs the Hessenberg matrix H when it is assigned to a matrix or otherwise evaluated. The matrix H is constructed from the packed matrix as returned by packedMatrix(): The upper part (including the subdiagonal) of the packed matrix contains the matrix H. It may sometimes be better to directly use the packed matrix instead of constructing the matrix H.
Example: \include test_EigenSolverDecomposition.cpp
See also
- Returns:
-
expression object representing the matrix H
- Pre:
-
Either the constructor HessenbergDecomposition(const MatrixType&) or the member function compute(const MatrixType&) has been called before to compute the Hessenberg decomposition of a matrix.
-
inline MatrixType matrixQ()#
-
Reconstructs the orthogonal 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.
- Returns:
-
object representing the matrix Q
- Pre:
-
Either the constructor HessenbergDecomposition(const MatrixType&) or the member function compute(const MatrixType&) has been called before to compute the Hessenberg decomposition of a matrix.
-
inline const MatrixType &packedMatrix() const#
-
Returns the internal representation of the decomposition.
The returned matrix contains the following information:
the upper part and lower sub-diagonal represent the Hessenberg matrix H
the rest of the lower part contains the Householder vectors that, combined with Householder coefficients returned by householderCoefficients(), allows to reconstruct the matrix Q as \( Q = H_{N-1} \ldots H_1 H_0 \). Here, the matrices \( H_i \) are the Householder transformations \( H_i = (I - h_i v_i v_i^T) \) where \( h_i \) is the \( i \)th Householder coefficient and \( v_i \) is the Householder vector defined by \( v_i = [ 0, \ldots, 0, 1, M(i+2,i), \ldots, M(N-1,i) ]^T \) with M the matrix returned by this function.
See LAPACK for further details on this packed storage.
- Returns:
-
a const reference to a matrix with the internal representation of the decomposition.
- Pre:
-
Either the constructor HessenbergDecomposition(const MatrixType&) or the member function compute(const MatrixType&) has been called before to compute the Hessenberg decomposition of a matrix.