Shapeworks Studio  2.1
Shape analysis software suite
List of all members | Public Types | Public Member Functions | Protected Attributes
Eigen::HessenbergDecomposition< _MatrixType > Class Template Reference

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

#include <HessenbergDecomposition.h>

+ 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 MatrixType::Index Index
 
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 >::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. More...
 
 HessenbergDecomposition (const MatrixType &matrix)
 Constructor; computes Hessenberg decomposition of given matrix. More...
 
HessenbergDecompositioncompute (const MatrixType &matrix)
 Computes Hessenberg decomposition of given matrix. More...
 
const CoeffVectorTypehouseholderCoefficients () const
 Returns the Householder coefficients. More...
 
const MatrixTypepackedMatrix () const
 Returns the internal representation of the decomposition. More...
 
HouseholderSequenceType matrixQ () const
 Reconstructs the orthogonal matrix Q in the decomposition. More...
 
MatrixHReturnType matrixH () const
 Constructs the Hessenberg matrix H in the decomposition. More...
 

Protected Attributes

MatrixType m_matrix
 
CoeffVectorType m_hCoeffs
 
VectorType m_temp
 
bool m_isInitialized
 

Detailed Description

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

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

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

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.

Constructor & Destructor Documentation

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

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.

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  }
EIGEN_STRONG_INLINE void resize(Index nbRows, Index nbCols)
template<typename _MatrixType>
Eigen::HessenbergDecomposition< _MatrixType >::HessenbergDecomposition ( const MatrixType matrix)
inline

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 118 of file HessenbergDecomposition.h.

119  : m_matrix(matrix),
120  m_temp(matrix.rows()),
121  m_isInitialized(false)
122  {
123  if(matrix.rows()<2)
124  {
125  m_isInitialized = true;
126  return;
127  }
128  m_hCoeffs.resize(matrix.rows()-1,1);
129  _compute(m_matrix, m_hCoeffs, m_temp);
130  m_isInitialized = true;
131  }
Definition: math3d.h:219
EIGEN_STRONG_INLINE void resize(Index nbRows, Index nbCols)

Member Function Documentation

template<typename _MatrixType>
HessenbergDecomposition& Eigen::HessenbergDecomposition< _MatrixType >::compute ( const MatrixType 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:

 

Definition at line 150 of file HessenbergDecomposition.h.

151  {
152  m_matrix = matrix;
153  if(matrix.rows()<2)
154  {
155  m_isInitialized = true;
156  return *this;
157  }
158  m_hCoeffs.resize(matrix.rows()-1,1);
159  _compute(m_matrix, m_hCoeffs, m_temp);
160  m_isInitialized = true;
161  return *this;
162  }
Definition: math3d.h:219
EIGEN_STRONG_INLINE void resize(Index nbRows, Index nbCols)
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 177 of file HessenbergDecomposition.h.

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

Definition at line 260 of file HessenbergDecomposition.h.

261  {
262  eigen_assert(m_isInitialized && "HessenbergDecomposition is not initialized.");
263  return MatrixHReturnType(*this);
264  }
template<typename _MatrixType>
HouseholderSequenceType Eigen::HessenbergDecomposition< _MatrixType >::matrixQ ( void  ) 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 232 of file HessenbergDecomposition.h.

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

Definition at line 212 of file HessenbergDecomposition.h.

213  {
214  eigen_assert(m_isInitialized && "HessenbergDecomposition is not initialized.");
215  return m_matrix;
216  }

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