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

Tridiagonal decomposition of a selfadjoint matrix. More...

#include <Tridiagonalization.h>

+ Collaboration diagram for Eigen::Tridiagonalization< _MatrixType >:

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 _MatrixType MatrixType
 Synonym for the template parameter _MatrixType.
 
typedef MatrixType::Scalar Scalar
 
typedef NumTraits< Scalar >::Real RealScalar
 
typedef MatrixType::Index Index
 
typedef Matrix< Scalar, SizeMinusOne, 1, Options &~RowMajor, MaxSizeMinusOne, 1 > CoeffVectorType
 
typedef internal::plain_col_type< MatrixType, RealScalar >::type DiagonalType
 
typedef Matrix< RealScalar, SizeMinusOne, 1, Options &~RowMajor, MaxSizeMinusOne, 1 > SubDiagonalType
 
typedef internal::remove_all< typename MatrixType::RealReturnType >::type MatrixTypeRealView
 
typedef internal::TridiagonalizationMatrixTReturnType< MatrixTypeRealView > MatrixTReturnType
 
typedef internal::conditional< NumTraits< Scalar >::IsComplex, typename internal::add_const_on_value_type< typename Diagonal< const MatrixType >::RealReturnType >::type, const Diagonal< const MatrixType > >::type DiagonalReturnType
 
typedef internal::conditional< NumTraits< Scalar >::IsComplex, typename internal::add_const_on_value_type< typename Diagonal< Block< const MatrixType, SizeMinusOne, SizeMinusOne > >::RealReturnType >::type, const Diagonal< Block< const MatrixType, SizeMinusOne, SizeMinusOne > > >::type SubDiagonalReturnType
 
typedef HouseholderSequence< MatrixType, typename internal::remove_all< typename CoeffVectorType::ConjugateReturnType >::type > HouseholderSequenceType
 Return type of matrixQ()
 

Public Member Functions

 Tridiagonalization (Index size=Size==Dynamic?2:Size)
 Default constructor. More...
 
 Tridiagonalization (const MatrixType &matrix)
 Constructor; computes tridiagonal decomposition of given matrix. More...
 
Tridiagonalizationcompute (const MatrixType &matrix)
 Computes tridiagonal decomposition of given matrix. More...
 
CoeffVectorType householderCoefficients () const
 Returns the Householder coefficients. More...
 
const MatrixTypepackedMatrix () const
 Returns the internal representation of the decomposition. More...
 
HouseholderSequenceType matrixQ () const
 Returns the unitary matrix Q in the decomposition. More...
 
MatrixTReturnType matrixT () const
 Returns an expression of the tridiagonal matrix T in the decomposition. More...
 
DiagonalReturnType diagonal () const
 Returns the diagonal of the tridiagonal matrix T in the decomposition. More...
 
SubDiagonalReturnType subDiagonal () const
 Returns the subdiagonal of the tridiagonal matrix T in the decomposition. More...
 

Protected Attributes

MatrixType m_matrix
 
CoeffVectorType m_hCoeffs
 
bool m_isInitialized
 

Detailed Description

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

Tridiagonal decomposition of a selfadjoint matrix.

Template Parameters
_MatrixTypethe 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 $ A $ such that: $ A = Q T Q^* $ where $ Q $ is unitary and $ T $ 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.

See also
class HessenbergDecomposition, class SelfAdjointEigenSolver

Definition at line 61 of file Tridiagonalization.h.

Constructor & Destructor Documentation

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

Default constructor.

Parameters
[in]sizePositive 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.

See also
compute() for an example.

Definition at line 113 of file Tridiagonalization.h.

113  : Size)
114  : m_matrix(size,size),
115  m_hCoeffs(size > 1 ? size-1 : 1),
116  m_isInitialized(false)
117  {}
template<typename _MatrixType >
Eigen::Tridiagonalization< _MatrixType >::Tridiagonalization ( const MatrixType matrix)
inline

Constructor; computes tridiagonal decomposition of given matrix.

Parameters
[in]matrixSelfadjoint matrix whose tridiagonal decomposition is to be computed.

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

Example:

Output:

 

Definition at line 129 of file Tridiagonalization.h.

130  : m_matrix(matrix),
131  m_hCoeffs(matrix.cols() > 1 ? matrix.cols()-1 : 1),
132  m_isInitialized(false)
133  {
134  internal::tridiagonalization_inplace(m_matrix, m_hCoeffs);
135  m_isInitialized = true;
136  }
Definition: math3d.h:219

Member Function Documentation

template<typename _MatrixType >
Tridiagonalization& Eigen::Tridiagonalization< _MatrixType >::compute ( const MatrixType matrix)
inline

Computes tridiagonal decomposition of given matrix.

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

The tridiagonal decomposition is computed by bringing the columns of the matrix successively in the required form using Householder reflections. The cost is $ 4n^3/3 $ flops, where $ n $ 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:

Output:

 

Definition at line 155 of file Tridiagonalization.h.

156  {
157  m_matrix = matrix;
158  m_hCoeffs.resize(matrix.rows()-1, 1);
159  internal::tridiagonalization_inplace(m_matrix, m_hCoeffs);
160  m_isInitialized = true;
161  return *this;
162  }
Definition: math3d.h:219
EIGEN_STRONG_INLINE void resize(Index nbRows, Index nbCols)
template<typename MatrixType >
Tridiagonalization< MatrixType >::DiagonalReturnType Eigen::Tridiagonalization< MatrixType >::diagonal ( ) const

Returns the diagonal of the tridiagonal matrix T in the decomposition.

Returns
expression representing the diagonal of T
Precondition
Either the constructor Tridiagonalization(const MatrixType&) or the member function compute(const MatrixType&) has been called before to compute the tridiagonal decomposition of a matrix.

Example:

Output:

See also
matrixT(), subDiagonal()

Definition at line 305 of file Tridiagonalization.h.

306 {
307  eigen_assert(m_isInitialized && "Tridiagonalization is not initialized.");
308  return m_matrix.diagonal();
309 }
template<typename _MatrixType >
CoeffVectorType Eigen::Tridiagonalization< _MatrixType >::householderCoefficients ( ) const
inline

Returns the Householder coefficients.

Returns
a const reference to the vector of Householder coefficients
Precondition
Either the constructor Tridiagonalization(const MatrixType&) or the member function compute(const MatrixType&) has been called before to compute the tridiagonal decomposition of a matrix.

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

Example:

Output:

See also
packedMatrix(), Householder module

Definition at line 180 of file Tridiagonalization.h.

181  {
182  eigen_assert(m_isInitialized && "Tridiagonalization is not initialized.");
183  return m_hCoeffs;
184  }
template<typename _MatrixType >
HouseholderSequenceType Eigen::Tridiagonalization< _MatrixType >::matrixQ ( void  ) const
inline

Returns the unitary matrix Q in the decomposition.

Returns
object representing the matrix Q
Precondition
Either the constructor Tridiagonalization(const MatrixType&) or the member function compute(const MatrixType&) has been called before to compute the tridiagonal 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
Tridiagonalization(const MatrixType&) for an example, matrixT(), class HouseholderSequence

Definition at line 238 of file Tridiagonalization.h.

239  {
240  eigen_assert(m_isInitialized && "Tridiagonalization is not initialized.");
241  return HouseholderSequenceType(m_matrix, m_hCoeffs.conjugate())
242  .setLength(m_matrix.rows() - 1)
243  .setShift(1);
244  }
HouseholderSequence< MatrixType, typename internal::remove_all< typename CoeffVectorType::ConjugateReturnType >::type > HouseholderSequenceType
Return type of matrixQ()
template<typename _MatrixType >
MatrixTReturnType Eigen::Tridiagonalization< _MatrixType >::matrixT ( ) const
inline

Returns an expression of the tridiagonal matrix T in the decomposition.

Returns
expression object representing the matrix T
Precondition
Either the constructor Tridiagonalization(const MatrixType&) or the member function compute(const MatrixType&) has been called before to compute the tridiagonal decomposition of a matrix.

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.

See also
Tridiagonalization(const MatrixType&) for an example, matrixQ(), packedMatrix(), diagonal(), subDiagonal()

Definition at line 263 of file Tridiagonalization.h.

264  {
265  eigen_assert(m_isInitialized && "Tridiagonalization is not initialized.");
266  return MatrixTReturnType(m_matrix.real());
267  }
template<typename _MatrixType >
const MatrixType& Eigen::Tridiagonalization< _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 Tridiagonalization(const MatrixType&) or the member function compute(const MatrixType&) has been called before to compute the tridiagonal decomposition of a matrix.

The returned matrix contains the following information:

  • the strict upper triangular part is equal to the input matrix A.
  • the diagonal and lower sub-diagonal represent the real tridiagonal symmetric matrix T.
  • 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 217 of file Tridiagonalization.h.

218  {
219  eigen_assert(m_isInitialized && "Tridiagonalization is not initialized.");
220  return m_matrix;
221  }
template<typename MatrixType >
Tridiagonalization< MatrixType >::SubDiagonalReturnType Eigen::Tridiagonalization< MatrixType >::subDiagonal ( ) const

Returns the subdiagonal of the tridiagonal matrix T in the decomposition.

Returns
expression representing the subdiagonal of T
Precondition
Either the constructor Tridiagonalization(const MatrixType&) or the member function compute(const MatrixType&) has been called before to compute the tridiagonal decomposition of a matrix.
See also
diagonal() for an example, matrixT()

Definition at line 313 of file Tridiagonalization.h.

314 {
315  eigen_assert(m_isInitialized && "Tridiagonalization is not initialized.");
316  Index n = m_matrix.rows();
317  return Block<const MatrixType,SizeMinusOne,SizeMinusOne>(m_matrix, 1, 0, n-1,n-1).diagonal();
318 }
DiagonalReturnType diagonal() const
Returns the diagonal of the tridiagonal matrix T in the decomposition.

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