Public Types | Public Member Functions | Protected Attributes | Private Types | Static Private Member Functions | List of all members
Eigen::HessenbergDecomposition< _MatrixType > Class Template Reference

Reduces a square matrix to Hessenberg form by an orthogonal similarity transformation. More...

#include <HessenbergDecomposition.h>

Public Types

enum  {
  Size = MatrixType::RowsAtCompileTime, SizeMinusOne = Size == Dynamic ? Dynamic : Size - 1, Options = MatrixType::Options, MaxSize = MatrixType::MaxRowsAtCompileTime,
  MaxSizeMinusOne = MaxSize == Dynamic ? Dynamic : MaxSize - 1
}
 
typedef Matrix< Scalar, SizeMinusOne, 1, Options &~RowMajor, MaxSizeMinusOne, 1 > CoeffVectorType
 Type for vector of Householder coefficients. More...
 
typedef HouseholderSequence< MatrixType, typename internal::remove_all< typename CoeffVectorType::ConjugateReturnType >::typeHouseholderSequenceType
 Return type of matrixQ() More...
 
typedef Eigen::Index Index
 
typedef internal::HessenbergDecompositionMatrixHReturnType< MatrixTypeMatrixHReturnType
 
typedef _MatrixType MatrixType
 Synonym for the template parameter _MatrixType. More...
 
typedef MatrixType::Scalar Scalar
 Scalar type for matrices of type MatrixType. More...
 

Public Member Functions

template<typename InputType >
HessenbergDecompositioncompute (const EigenBase< InputType > &matrix)
 Computes Hessenberg decomposition of given matrix. More...
 
template<typename InputType >
 HessenbergDecomposition (const EigenBase< InputType > &matrix)
 Constructor; computes Hessenberg decomposition of given matrix. More...
 
 HessenbergDecomposition (Index size=Size==Dynamic ? 2 :Size)
 Default constructor; the decomposition will be computed later. More...
 
const CoeffVectorTypehouseholderCoefficients () const
 Returns the Householder coefficients. More...
 
MatrixHReturnType matrixH () const
 Constructs the Hessenberg matrix H in the decomposition. More...
 
HouseholderSequenceType matrixQ () const
 Reconstructs the orthogonal matrix Q in the decomposition. More...
 
const MatrixTypepackedMatrix () const
 Returns the internal representation of the decomposition. More...
 

Protected Attributes

CoeffVectorType m_hCoeffs
 
bool m_isInitialized
 
MatrixType m_matrix
 
VectorType m_temp
 

Private Types

typedef NumTraits< Scalar >::Real RealScalar
 
typedef Matrix< Scalar, 1, Size, int(Options)|int(RowMajor), 1, MaxSizeVectorType
 

Static Private Member Functions

static void _compute (MatrixType &matA, CoeffVectorType &hCoeffs, VectorType &temp)
 

Detailed Description

template<typename _MatrixType>
class Eigen::HessenbergDecomposition< _MatrixType >

Reduces a square matrix to Hessenberg form by an orthogonal similarity transformation.

\eigenvalues_module

Template Parameters
_MatrixTypethe type of the matrix of which we are computing the Hessenberg decomposition

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.

The documentation for matrixH() contains an example of the typical use of this class.

See also
class ComplexSchur, class Tridiagonalization, QR Module

Definition at line 57 of file HessenbergDecomposition.h.

Member Typedef Documentation

◆ CoeffVectorType

template<typename _MatrixType >
typedef Matrix<Scalar, SizeMinusOne, 1, Options & ~RowMajor, MaxSizeMinusOne, 1> Eigen::HessenbergDecomposition< _MatrixType >::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, if it is a fixed-side type.

Definition at line 82 of file HessenbergDecomposition.h.

◆ HouseholderSequenceType

Return type of matrixQ()

Definition at line 85 of file HessenbergDecomposition.h.

◆ Index

template<typename _MatrixType >
typedef Eigen::Index Eigen::HessenbergDecomposition< _MatrixType >::Index
Deprecated:
since Eigen 3.3

Definition at line 74 of file HessenbergDecomposition.h.

◆ MatrixHReturnType

Definition at line 87 of file HessenbergDecomposition.h.

◆ MatrixType

template<typename _MatrixType >
typedef _MatrixType Eigen::HessenbergDecomposition< _MatrixType >::MatrixType

Synonym for the template parameter _MatrixType.

Definition at line 62 of file HessenbergDecomposition.h.

◆ RealScalar

template<typename _MatrixType >
typedef NumTraits<Scalar>::Real Eigen::HessenbergDecomposition< _MatrixType >::RealScalar
private

Definition at line 271 of file HessenbergDecomposition.h.

◆ Scalar

template<typename _MatrixType >
typedef MatrixType::Scalar Eigen::HessenbergDecomposition< _MatrixType >::Scalar

Scalar type for matrices of type MatrixType.

Definition at line 73 of file HessenbergDecomposition.h.

◆ VectorType

template<typename _MatrixType >
typedef Matrix<Scalar, 1, Size, int(Options) | int(RowMajor), 1, MaxSize> Eigen::HessenbergDecomposition< _MatrixType >::VectorType
private

Definition at line 270 of file HessenbergDecomposition.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename _MatrixType >
anonymous enum
Enumerator
Size 
SizeMinusOne 
Options 
MaxSize 
MaxSizeMinusOne 

Definition at line 64 of file HessenbergDecomposition.h.

Constructor & Destructor Documentation

◆ HessenbergDecomposition() [1/2]

template<typename _MatrixType >
Eigen::HessenbergDecomposition< _MatrixType >::HessenbergDecomposition ( Index  size = Size==Dynamic ? 2 : Size)
inlineexplicit

Default constructor; the decomposition will be computed later.

Parameters
[in]sizeThe size of the matrix whose Hessenberg 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.

See also
compute() for an example.

Definition at line 100 of file HessenbergDecomposition.h.

◆ HessenbergDecomposition() [2/2]

template<typename _MatrixType >
template<typename InputType >
Eigen::HessenbergDecomposition< _MatrixType >::HessenbergDecomposition ( const EigenBase< InputType > &  matrix)
inlineexplicit

Constructor; computes Hessenberg decomposition of given matrix.

Parameters
[in]matrixSquare matrix whose Hessenberg decomposition is to be computed.

This constructor calls compute() to compute the Hessenberg decomposition.

See also
matrixH() for an example.

Definition at line 119 of file HessenbergDecomposition.h.

Member Function Documentation

◆ _compute()

template<typename MatrixType >
void Eigen::HessenbergDecomposition< MatrixType >::_compute ( MatrixType matA,
CoeffVectorType hCoeffs,
VectorType temp 
)
staticprivate

Definition at line 294 of file HessenbergDecomposition.h.

◆ compute()

template<typename _MatrixType >
template<typename InputType >
HessenbergDecomposition& Eigen::HessenbergDecomposition< _MatrixType >::compute ( const EigenBase< InputType > &  matrix)
inline

Computes Hessenberg decomposition of given matrix.

Parameters
[in]matrixSquare matrix whose Hessenberg decomposition is to be computed.
Returns
Reference to *this

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.

Example:

MatrixXcf A = MatrixXcf::Random(4,4);
HessenbergDecomposition<MatrixXcf> hd(4);
hd.compute(A);
cout << "The matrix H in the decomposition of A is:" << endl << hd.matrixH() << endl;
hd.compute(2*A); // re-use hd to compute and store decomposition of 2A
cout << "The matrix H in the decomposition of 2A is:" << endl << hd.matrixH() << endl;

Output:

 

Definition at line 152 of file HessenbergDecomposition.h.

◆ householderCoefficients()

template<typename _MatrixType >
const CoeffVectorType& Eigen::HessenbergDecomposition< _MatrixType >::householderCoefficients ( ) const
inline

Returns the Householder coefficients.

Returns
a const reference to the vector of Householder coefficients
Precondition
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.

The Householder coefficients allow the reconstruction of the matrix $ Q $ in the Hessenberg decomposition from the packed data.

See also
packedMatrix(), Householder module

Definition at line 179 of file HessenbergDecomposition.h.

◆ matrixH()

template<typename _MatrixType >
MatrixHReturnType Eigen::HessenbergDecomposition< _MatrixType >::matrixH ( ) const
inline

Constructs the Hessenberg matrix H in the decomposition.

Returns
expression object representing the matrix H
Precondition
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.

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:

Matrix4f A = MatrixXf::Random(4,4);
cout << "Here is a random 4x4 matrix:" << endl << A << endl;
HessenbergDecomposition<MatrixXf> hessOfA(A);
MatrixXf H = hessOfA.matrixH();
cout << "The Hessenberg matrix H is:" << endl << H << endl;
MatrixXf Q = hessOfA.matrixQ();
cout << "The orthogonal matrix Q is:" << endl << Q << endl;
cout << "Q H Q^T is:" << endl << Q * H * Q.transpose() << endl;

Output:

See also
matrixQ(), packedMatrix()

Definition at line 262 of file HessenbergDecomposition.h.

◆ matrixQ()

template<typename _MatrixType >
HouseholderSequenceType Eigen::HessenbergDecomposition< _MatrixType >::matrixQ ( ) const
inline

Reconstructs the orthogonal matrix Q in the decomposition.

Returns
object representing the matrix Q
Precondition
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.

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.

See also
matrixH() for an example, class HouseholderSequence

Definition at line 234 of file HessenbergDecomposition.h.

◆ packedMatrix()

template<typename _MatrixType >
const MatrixType& Eigen::HessenbergDecomposition< _MatrixType >::packedMatrix ( ) const
inline

Returns the internal representation of the decomposition.

Returns
a const reference to a matrix with the internal representation of the decomposition.
Precondition
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.

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.

Example:

Matrix4d A = Matrix4d::Random(4,4);
cout << "Here is a random 4x4 matrix:" << endl << A << endl;
HessenbergDecomposition<Matrix4d> hessOfA(A);
Matrix4d pm = hessOfA.packedMatrix();
cout << "The packed matrix M is:" << endl << pm << endl;
cout << "The upper Hessenberg part corresponds to the matrix H, which is:"
<< endl << hessOfA.matrixH() << endl;
Vector3d hc = hessOfA.householderCoefficients();
cout << "The vector of Householder coefficients is:" << endl << hc << endl;

Output:

See also
householderCoefficients()

Definition at line 214 of file HessenbergDecomposition.h.

Member Data Documentation

◆ m_hCoeffs

template<typename _MatrixType >
CoeffVectorType Eigen::HessenbergDecomposition< _MatrixType >::m_hCoeffs
protected

Definition at line 276 of file HessenbergDecomposition.h.

◆ m_isInitialized

template<typename _MatrixType >
bool Eigen::HessenbergDecomposition< _MatrixType >::m_isInitialized
protected

Definition at line 278 of file HessenbergDecomposition.h.

◆ m_matrix

template<typename _MatrixType >
MatrixType Eigen::HessenbergDecomposition< _MatrixType >::m_matrix
protected

Definition at line 275 of file HessenbergDecomposition.h.

◆ m_temp

template<typename _MatrixType >
VectorType Eigen::HessenbergDecomposition< _MatrixType >::m_temp
protected

Definition at line 277 of file HessenbergDecomposition.h.


The documentation for this class was generated from the following file:
H
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate set rrange[*:*] noreverse nowriteback set trange[*:*] noreverse nowriteback set urange[*:*] noreverse nowriteback set vrange[*:*] noreverse nowriteback set xlabel matrix size set x2label set timefmt d m y n H
Definition: gnuplot_common_settings.hh:74
hc
Vector3d hc
Definition: Tridiagonalization_householderCoefficients.cpp:5
A
Definition: test_numpy_dtypes.cpp:298
Eigen::Quaternion
The quaternion class used to represent 3D orientations and rotations.
Definition: ForwardDeclarations.h:293
hessOfA
cout<< "Here is a random 4x4 matrix:"<< endl<< A<< endl;HessenbergDecomposition< MatrixXf > hessOfA(A)
hd
HessenbergDecomposition< MatrixXcf > hd(4)
pm
Matrix4d pm
Definition: HessenbergDecomposition_packedMatrix.cpp:4


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:10:52