Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Eigen::HessenbergDecomposition< _MatrixType > Class Template Reference

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

#include <src/eigen/Eigen/src/Eigenvalues/HessenbergDecomposition.h>

+ Inheritance diagram for Eigen::HessenbergDecomposition< _MatrixType >:
+ Collaboration diagram for Eigen::HessenbergDecomposition< _MatrixType >:

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 _MatrixType MatrixType
 Synonym for the template parameter _MatrixType.
 
typedef MatrixType::Scalar Scalar
 Scalar type for matrices of type MatrixType.
 
typedef Eigen::Index Index
 
typedef Matrix< Scalar, SizeMinusOne, 1, Options &~RowMajor, MaxSizeMinusOne, 1 > CoeffVectorType
 Type for vector of Householder coefficients.
 
typedef HouseholderSequence< MatrixType, typename internal::remove_all< typename CoeffVectorType::ConjugateReturnType >::type > HouseholderSequenceType
 Return type of matrixQ()
 
typedef internal::HessenbergDecompositionMatrixHReturnType< MatrixTypeMatrixHReturnType
 

Public Member Functions

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

Protected Attributes

MatrixType m_matrix
 
CoeffVectorType m_hCoeffs
 
VectorType m_temp
 
bool m_isInitialized
 

Private Types

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

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

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.

◆ HouseholderSequenceType

template<typename _MatrixType >
typedef HouseholderSequence<MatrixType,typename internal::remove_all<typename CoeffVectorType::ConjugateReturnType>::type> Eigen::HessenbergDecomposition< _MatrixType >::HouseholderSequenceType

Return type of matrixQ()

◆ Index

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

◆ MatrixHReturnType

template<typename _MatrixType >
typedef internal::HessenbergDecompositionMatrixHReturnType<MatrixType> Eigen::HessenbergDecomposition< _MatrixType >::MatrixHReturnType

◆ MatrixType

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

Synonym for the template parameter _MatrixType.

◆ RealScalar

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

◆ Scalar

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

Scalar type for matrices of type MatrixType.

◆ VectorType

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

Member Enumeration Documentation

◆ anonymous enum

template<typename _MatrixType >
anonymous enum
Enumerator
Size 
SizeMinusOne 
Options 
MaxSize 
MaxSizeMinusOne 
64 {
65 Size = MatrixType::RowsAtCompileTime,
67 Options = MatrixType::Options,
68 MaxSize = MatrixType::MaxRowsAtCompileTime,
70 };
@ MaxSizeMinusOne
Definition HessenbergDecomposition.h:69
@ Size
Definition HessenbergDecomposition.h:65
@ Options
Definition HessenbergDecomposition.h:67
@ SizeMinusOne
Definition HessenbergDecomposition.h:66
@ MaxSize
Definition HessenbergDecomposition.h:68
const int Dynamic
Definition Constants.h:21

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.
100 : Size)
101 : m_matrix(size,size),
102 m_temp(size),
103 m_isInitialized(false)
104 {
105 if(size>1)
106 m_hCoeffs.resize(size-1);
107 }
bool m_isInitialized
Definition HessenbergDecomposition.h:278
VectorType m_temp
Definition HessenbergDecomposition.h:277
CoeffVectorType m_hCoeffs
Definition HessenbergDecomposition.h:276
MatrixType m_matrix
Definition HessenbergDecomposition.h:275
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index rows, Index cols)
Definition PlainObjectBase.h:279
constexpr auto size(const C &c) -> decltype(c.size())
Definition span.hpp:183

References Eigen::HessenbergDecomposition< _MatrixType >::m_hCoeffs, and Eigen::PlainObjectBase< Derived >::resize().

+ Here is the call graph for this function:

◆ 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.
120 : m_matrix(matrix.derived()),
121 m_temp(matrix.rows()),
122 m_isInitialized(false)
123 {
124 if(matrix.rows()<2)
125 {
126 m_isInitialized = true;
127 return;
128 }
129 m_hCoeffs.resize(matrix.rows()-1,1);
131 m_isInitialized = true;
132 }
static void _compute(MatrixType &matA, CoeffVectorType &hCoeffs, VectorType &temp)
Definition HessenbergDecomposition.h:294

References Eigen::HessenbergDecomposition< _MatrixType >::_compute(), Eigen::HessenbergDecomposition< _MatrixType >::m_hCoeffs, Eigen::HessenbergDecomposition< _MatrixType >::m_isInitialized, Eigen::HessenbergDecomposition< _MatrixType >::m_matrix, Eigen::HessenbergDecomposition< _MatrixType >::m_temp, Eigen::PlainObjectBase< Derived >::resize(), and Eigen::EigenBase< Derived >::rows().

+ Here is the call graph for this function:

Member Function Documentation

◆ _compute()

template<typename MatrixType >
void Eigen::HessenbergDecomposition< MatrixType >::_compute ( MatrixType matA,
CoeffVectorType hCoeffs,
VectorType temp 
)
staticprivate
295{
296 eigen_assert(matA.rows()==matA.cols());
297 Index n = matA.rows();
298 temp.resize(n);
299 for (Index i = 0; i<n-1; ++i)
300 {
301 // let's consider the vector v = i-th column starting at position i+1
302 Index remainingSize = n-i-1;
303 RealScalar beta;
304 Scalar h;
305 matA.col(i).tail(remainingSize).makeHouseholderInPlace(h, beta);
306 matA.col(i).coeffRef(i+1) = beta;
307 hCoeffs.coeffRef(i) = h;
308
309 // Apply similarity transformation to remaining columns,
310 // i.e., compute A = H A H'
311
312 // A = H A
313 matA.bottomRightCorner(remainingSize, remainingSize)
314 .applyHouseholderOnTheLeft(matA.col(i).tail(remainingSize-1), h, &temp.coeffRef(0));
315
316 // A = A H'
317 matA.rightCols(remainingSize)
318 .applyHouseholderOnTheRight(matA.col(i).tail(remainingSize-1).conjugate(), numext::conj(h), &temp.coeffRef(0));
319 }
320}
#define eigen_assert(x)
Definition Macros.h:579
Eigen::Index Index
Definition HessenbergDecomposition.h:74
MatrixType::Scalar Scalar
Scalar type for matrices of type MatrixType.
Definition HessenbergDecomposition.h:73
NumTraits< Scalar >::Real RealScalar
Definition HessenbergDecomposition.h:271

References Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols >::coeffRef(), eigen_assert, and Eigen::PlainObjectBase< Derived >::resize().

Referenced by Eigen::HessenbergDecomposition< _MatrixType >::HessenbergDecomposition(), and Eigen::HessenbergDecomposition< _MatrixType >::compute().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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:

Output:

 
153 {
154 m_matrix = matrix.derived();
155 if(matrix.rows()<2)
156 {
157 m_isInitialized = true;
158 return *this;
159 }
160 m_hCoeffs.resize(matrix.rows()-1,1);
162 m_isInitialized = true;
163 return *this;
164 }

References Eigen::HessenbergDecomposition< _MatrixType >::_compute(), Eigen::EigenBase< Derived >::derived(), Eigen::HessenbergDecomposition< _MatrixType >::m_hCoeffs, Eigen::HessenbergDecomposition< _MatrixType >::m_isInitialized, Eigen::HessenbergDecomposition< _MatrixType >::m_matrix, Eigen::HessenbergDecomposition< _MatrixType >::m_temp, Eigen::PlainObjectBase< Derived >::resize(), and Eigen::EigenBase< Derived >::rows().

Referenced by Eigen::internal::complex_schur_reduce_to_hessenberg< MatrixType, IsComplex >::run(), and Eigen::internal::complex_schur_reduce_to_hessenberg< MatrixType, false >::run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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
180 {
181 eigen_assert(m_isInitialized && "HessenbergDecomposition is not initialized.");
182 return m_hCoeffs;
183 }

References eigen_assert, Eigen::HessenbergDecomposition< _MatrixType >::m_hCoeffs, and Eigen::HessenbergDecomposition< _MatrixType >::m_isInitialized.

◆ 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:

Output:

See also
matrixQ(), packedMatrix()
263 {
264 eigen_assert(m_isInitialized && "HessenbergDecomposition is not initialized.");
265 return MatrixHReturnType(*this);
266 }
internal::HessenbergDecompositionMatrixHReturnType< MatrixType > MatrixHReturnType
Definition HessenbergDecomposition.h:87

References eigen_assert, and Eigen::HessenbergDecomposition< _MatrixType >::m_isInitialized.

Referenced by Eigen::internal::complex_schur_reduce_to_hessenberg< MatrixType, IsComplex >::run(), and Eigen::internal::complex_schur_reduce_to_hessenberg< MatrixType, false >::run().

+ Here is the caller graph for this function:

◆ 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
235 {
236 eigen_assert(m_isInitialized && "HessenbergDecomposition is not initialized.");
237 return HouseholderSequenceType(m_matrix, m_hCoeffs.conjugate())
238 .setLength(m_matrix.rows() - 1)
239 .setShift(1);
240 }
HouseholderSequence< MatrixType, typename internal::remove_all< typename CoeffVectorType::ConjugateReturnType >::type > HouseholderSequenceType
Return type of matrixQ()
Definition HessenbergDecomposition.h:85

References eigen_assert, Eigen::HessenbergDecomposition< _MatrixType >::m_hCoeffs, Eigen::HessenbergDecomposition< _MatrixType >::m_isInitialized, and Eigen::HessenbergDecomposition< _MatrixType >::m_matrix.

Referenced by Eigen::internal::complex_schur_reduce_to_hessenberg< MatrixType, IsComplex >::run(), and Eigen::internal::complex_schur_reduce_to_hessenberg< MatrixType, false >::run().

+ Here is the caller graph for this function:

◆ 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:

Output:

See also
householderCoefficients()
215 {
216 eigen_assert(m_isInitialized && "HessenbergDecomposition is not initialized.");
217 return m_matrix;
218 }

References eigen_assert, Eigen::HessenbergDecomposition< _MatrixType >::m_isInitialized, and Eigen::HessenbergDecomposition< _MatrixType >::m_matrix.

Referenced by Eigen::internal::HessenbergDecompositionMatrixHReturnType< MatrixType >::cols(), Eigen::internal::HessenbergDecompositionMatrixHReturnType< MatrixType >::evalTo(), and Eigen::internal::HessenbergDecompositionMatrixHReturnType< MatrixType >::rows().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_hCoeffs

◆ m_isInitialized

◆ m_matrix

◆ m_temp


The documentation for this class was generated from the following file: