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

Tridiagonal decomposition of a selfadjoint matrix. More...

#include <src/eigen/Eigen/src/Eigenvalues/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 Eigen::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< typenameMatrixType::RealReturnType >::type MatrixTypeRealView
 
typedef internal::TridiagonalizationMatrixTReturnType< MatrixTypeRealViewMatrixTReturnType
 
typedef internal::conditional< NumTraits< Scalar >::IsComplex, typenameinternal::add_const_on_value_type< typenameDiagonal< constMatrixType >::RealReturnType >::type, constDiagonal< constMatrixType > >::type DiagonalReturnType
 
typedef internal::conditional< NumTraits< Scalar >::IsComplex, typenameinternal::add_const_on_value_type< typenameDiagonal< constMatrixType,-1 >::RealReturnType >::type, constDiagonal< constMatrixType,-1 > >::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.
 
template<typename InputType >
 Tridiagonalization (const EigenBase< InputType > &matrix)
 Constructor; computes tridiagonal decomposition of given matrix.
 
template<typename InputType >
Tridiagonalizationcompute (const EigenBase< InputType > &matrix)
 Computes tridiagonal decomposition of given matrix.
 
CoeffVectorType householderCoefficients () const
 Returns the Householder coefficients.
 
const MatrixTypepackedMatrix () const
 Returns the internal representation of the decomposition.
 
HouseholderSequenceType matrixQ () const
 Returns the unitary matrix Q in the decomposition.
 
MatrixTReturnType matrixT () const
 Returns an expression of the tridiagonal matrix T in the decomposition.
 
DiagonalReturnType diagonal () const
 Returns the diagonal of the tridiagonal matrix T in the decomposition.
 
SubDiagonalReturnType subDiagonal () const
 Returns the subdiagonal of the tridiagonal matrix T in the decomposition.
 

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.

\eigenvalues_module

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

Member Typedef Documentation

◆ CoeffVectorType

template<typename _MatrixType >
typedef Matrix<Scalar, SizeMinusOne, 1, Options & ~RowMajor, MaxSizeMinusOne, 1> Eigen::Tridiagonalization< _MatrixType >::CoeffVectorType

◆ DiagonalReturnType

template<typename _MatrixType >
typedef internal::conditional<NumTraits<Scalar>::IsComplex,typenameinternal::add_const_on_value_type<typenameDiagonal<constMatrixType>::RealReturnType>::type,constDiagonal<constMatrixType>>::type Eigen::Tridiagonalization< _MatrixType >::DiagonalReturnType

◆ DiagonalType

template<typename _MatrixType >
typedef internal::plain_col_type<MatrixType,RealScalar>::type Eigen::Tridiagonalization< _MatrixType >::DiagonalType

◆ HouseholderSequenceType

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

Return type of matrixQ()

◆ Index

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

◆ MatrixTReturnType

template<typename _MatrixType >
typedef internal::TridiagonalizationMatrixTReturnType<MatrixTypeRealView> Eigen::Tridiagonalization< _MatrixType >::MatrixTReturnType

◆ MatrixType

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

Synonym for the template parameter _MatrixType.

◆ MatrixTypeRealView

template<typename _MatrixType >
typedef internal::remove_all<typenameMatrixType::RealReturnType>::type Eigen::Tridiagonalization< _MatrixType >::MatrixTypeRealView

◆ RealScalar

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

◆ Scalar

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

◆ SubDiagonalReturnType

template<typename _MatrixType >
typedef internal::conditional<NumTraits<Scalar>::IsComplex,typenameinternal::add_const_on_value_type<typenameDiagonal<constMatrixType,-1>::RealReturnType>::type,constDiagonal<constMatrixType,-1>>::type Eigen::Tridiagonalization< _MatrixType >::SubDiagonalReturnType

◆ SubDiagonalType

template<typename _MatrixType >
typedef Matrix<RealScalar, SizeMinusOne, 1, Options & ~RowMajor, MaxSizeMinusOne, 1> Eigen::Tridiagonalization< _MatrixType >::SubDiagonalType

Member Enumeration Documentation

◆ anonymous enum

template<typename _MatrixType >
anonymous enum
Enumerator
Size 
SizeMinusOne 
Options 
MaxSize 
MaxSizeMinusOne 
74 {
75 Size = MatrixType::RowsAtCompileTime,
76 SizeMinusOne = Size == Dynamic ? Dynamic : (Size > 1 ? Size - 1 : 1),
77 Options = MatrixType::Options,
78 MaxSize = MatrixType::MaxRowsAtCompileTime,
79 MaxSizeMinusOne = MaxSize == Dynamic ? Dynamic : (MaxSize > 1 ? MaxSize - 1 : 1)
80 };
@ Size
Definition Tridiagonalization.h:75
@ MaxSize
Definition Tridiagonalization.h:78
@ MaxSizeMinusOne
Definition Tridiagonalization.h:79
@ SizeMinusOne
Definition Tridiagonalization.h:76
@ Options
Definition Tridiagonalization.h:77
const int Dynamic
Definition Constants.h:21

Constructor & Destructor Documentation

◆ Tridiagonalization() [1/2]

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

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.
113 : Size)
114 : m_matrix(size,size),
115 m_hCoeffs(size > 1 ? size-1 : 1),
116 m_isInitialized(false)
117 {}
CoeffVectorType m_hCoeffs
Definition Tridiagonalization.h:301
bool m_isInitialized
Definition Tridiagonalization.h:302
MatrixType m_matrix
Definition Tridiagonalization.h:300
constexpr auto size(const C &c) -> decltype(c.size())
Definition span.hpp:183

◆ Tridiagonalization() [2/2]

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

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:

 
131 : m_matrix(matrix.derived()),
132 m_hCoeffs(matrix.cols() > 1 ? matrix.cols()-1 : 1),
133 m_isInitialized(false)
134 {
136 m_isInitialized = true;
137 }
void tridiagonalization_inplace(MatrixType &matA, CoeffVectorType &hCoeffs)
Definition Tridiagonalization.h:347

References Eigen::Tridiagonalization< _MatrixType >::m_hCoeffs, Eigen::Tridiagonalization< _MatrixType >::m_isInitialized, Eigen::Tridiagonalization< _MatrixType >::m_matrix, and Eigen::internal::tridiagonalization_inplace().

+ Here is the call graph for this function:

Member Function Documentation

◆ compute()

template<typename _MatrixType >
template<typename InputType >
Tridiagonalization & Eigen::Tridiagonalization< _MatrixType >::compute ( const EigenBase< InputType > &  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:

 
158 {
159 m_matrix = matrix.derived();
160 m_hCoeffs.resize(matrix.rows()-1, 1);
162 m_isInitialized = true;
163 return *this;
164 }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index rows, Index cols)
Definition PlainObjectBase.h:279

References Eigen::EigenBase< Derived >::derived(), Eigen::Tridiagonalization< _MatrixType >::m_hCoeffs, Eigen::Tridiagonalization< _MatrixType >::m_isInitialized, Eigen::Tridiagonalization< _MatrixType >::m_matrix, Eigen::PlainObjectBase< Derived >::resize(), Eigen::EigenBase< Derived >::rows(), and Eigen::internal::tridiagonalization_inplace().

+ Here is the call graph for this function:

◆ diagonal()

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()
308{
309 eigen_assert(m_isInitialized && "Tridiagonalization is not initialized.");
310 return m_matrix.diagonal().real();
311}
#define eigen_assert(x)
Definition Macros.h:579

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

Referenced by Eigen::Tridiagonalization< _MatrixType >::subDiagonal().

+ Here is the caller graph for this function:

◆ householderCoefficients()

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
183 {
184 eigen_assert(m_isInitialized && "Tridiagonalization is not initialized.");
185 return m_hCoeffs;
186 }

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

◆ matrixQ()

template<typename _MatrixType >
HouseholderSequenceType Eigen::Tridiagonalization< _MatrixType >::matrixQ ( ) 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
241 {
242 eigen_assert(m_isInitialized && "Tridiagonalization is not initialized.");
243 return HouseholderSequenceType(m_matrix, m_hCoeffs.conjugate())
244 .setLength(m_matrix.rows() - 1)
245 .setShift(1);
246 }
HouseholderSequence< MatrixType, typename internal::remove_all< typename CoeffVectorType::ConjugateReturnType >::type > HouseholderSequenceType
Return type of matrixQ()
Definition Tridiagonalization.h:99

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

◆ matrixT()

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()
266 {
267 eigen_assert(m_isInitialized && "Tridiagonalization is not initialized.");
268 return MatrixTReturnType(m_matrix.real());
269 }
internal::TridiagonalizationMatrixTReturnType< MatrixTypeRealView > MatrixTReturnType
Definition Tridiagonalization.h:86

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

◆ packedMatrix()

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()
220 {
221 eigen_assert(m_isInitialized && "Tridiagonalization is not initialized.");
222 return m_matrix;
223 }

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

◆ subDiagonal()

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()
316{
317 eigen_assert(m_isInitialized && "Tridiagonalization is not initialized.");
318 return m_matrix.template diagonal<-1>().real();
319}
EIGEN_DEVICE_FUNC RealReturnType real() const
Definition CommonCwiseUnaryOps.h:86
DiagonalReturnType diagonal() const
Returns the diagonal of the tridiagonal matrix T in the decomposition.
Definition Tridiagonalization.h:307

References Eigen::Tridiagonalization< _MatrixType >::diagonal(), eigen_assert, Eigen::Tridiagonalization< _MatrixType >::m_isInitialized, Eigen::Tridiagonalization< _MatrixType >::m_matrix, and real().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_hCoeffs

◆ m_isInitialized

◆ m_matrix


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