11 #ifndef EIGEN_HESSENBERGDECOMPOSITION_H 12 #define EIGEN_HESSENBERGDECOMPOSITION_H 19 template<
typename MatrixType>
65 Size = MatrixType::RowsAtCompileTime,
68 MaxSize = MatrixType::MaxRowsAtCompileTime,
73 typedef typename MatrixType::Scalar
Scalar;
74 typedef typename MatrixType::Index
Index;
101 : m_matrix(size,size),
103 m_isInitialized(false)
106 m_hCoeffs.resize(size-1);
120 m_temp(matrix.rows()),
121 m_isInitialized(false)
125 m_isInitialized =
true;
128 m_hCoeffs.resize(matrix.rows()-1,1);
129 _compute(m_matrix, m_hCoeffs, m_temp);
130 m_isInitialized =
true;
155 m_isInitialized =
true;
158 m_hCoeffs.resize(matrix.rows()-1,1);
159 _compute(m_matrix, m_hCoeffs, m_temp);
160 m_isInitialized =
true;
179 eigen_assert(m_isInitialized &&
"HessenbergDecomposition is not initialized.");
214 eigen_assert(m_isInitialized &&
"HessenbergDecomposition is not initialized.");
234 eigen_assert(m_isInitialized &&
"HessenbergDecomposition is not initialized.");
235 return HouseholderSequenceType(m_matrix, m_hCoeffs.conjugate())
236 .setLength(m_matrix.rows() - 1)
262 eigen_assert(m_isInitialized &&
"HessenbergDecomposition is not initialized.");
263 return MatrixHReturnType(*
this);
270 static void _compute(MatrixType& matA, CoeffVectorType& hCoeffs, VectorType& temp);
291 template<
typename MatrixType>
295 Index n = matA.rows();
297 for (
Index i = 0; i<n-1; ++i)
300 Index remainingSize = n-i-1;
303 matA.col(i).tail(remainingSize).makeHouseholderInPlace(h, beta);
304 matA.col(i).coeffRef(i+1) = beta;
311 matA.bottomRightCorner(remainingSize, remainingSize)
312 .applyHouseholderOnTheLeft(matA.col(i).tail(remainingSize-1), h, &temp.
coeffRef(0));
315 matA.rightCols(remainingSize)
316 .applyHouseholderOnTheRight(matA.col(i).tail(remainingSize-1).conjugate(),
numext::conj(h), &temp.
coeffRef(0));
337 template<
typename MatrixType>
struct HessenbergDecompositionMatrixHReturnType
338 :
public ReturnByValue<HessenbergDecompositionMatrixHReturnType<MatrixType> >
340 typedef typename MatrixType::Index
Index;
353 template <
typename ResultType>
354 inline void evalTo(ResultType& result)
const 356 result = m_hess.packedMatrix();
357 Index n = result.rows();
359 result.bottomLeftCorner(n-2, n-2).template triangularView<Lower>().setZero();
362 Index
rows()
const {
return m_hess.packedMatrix().rows(); }
363 Index
cols()
const {
return m_hess.packedMatrix().cols(); }
373 #endif // EIGEN_HESSENBERGDECOMPOSITION_H
const MatrixType & packedMatrix() const
Returns the internal representation of the decomposition.
HouseholderSequenceType matrixQ() const
Reconstructs the orthogonal matrix Q in the decomposition.
const AutoDiffScalar< DerType > & conj(const AutoDiffScalar< DerType > &x)
MatrixHReturnType matrixH() const
Constructs the Hessenberg matrix H in the decomposition.
static void _compute(MatrixType &matA, CoeffVectorType &hCoeffs, VectorType &temp)
CoeffVectorType m_hCoeffs
iterative scaling algorithm to equilibrate rows and column norms in matrices
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
internal::HessenbergDecompositionMatrixHReturnType< MatrixType > MatrixHReturnType
_MatrixType MatrixType
Synonym for the template parameter _MatrixType.
MatrixType::Scalar Scalar
Scalar type for matrices of type MatrixType.
Sequence of Householder reflections acting on subspaces with decreasing size.
Matrix< Scalar, 1, Size, Options|RowMajor, 1, MaxSize > VectorType
void evalTo(ResultType &result) const
Hessenberg matrix in decomposition.
NumTraits< Scalar >::Real RealScalar
HessenbergDecomposition & compute(const MatrixType &matrix)
Computes Hessenberg decomposition of given matrix.
EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
HessenbergDecompositionMatrixHReturnType(const HessenbergDecomposition< MatrixType > &hess)
Constructor.
EIGEN_STRONG_INLINE void resize(Index nbRows, Index nbCols)
Provides a generic way to set and pass user-specified options.
const HessenbergDecomposition< MatrixType > & m_hess
HessenbergDecomposition(const MatrixType &matrix)
Constructor; computes Hessenberg decomposition of given matrix.
Expression type for return value of HessenbergDecomposition::matrixH()
HessenbergDecomposition(Index size=Size==Dynamic?2:Size)
Default constructor; the decomposition will be computed later.
Reduces a square matrix to Hessenberg form by an orthogonal similarity transformation.
HouseholderSequence< MatrixType, typename internal::remove_all< typename CoeffVectorType::ConjugateReturnType >::type > HouseholderSequenceType
Return type of matrixQ()
Matrix< Scalar, SizeMinusOne, 1, Options &~RowMajor, MaxSizeMinusOne, 1 > CoeffVectorType
Type for vector of Householder coefficients.
const CoeffVectorType & householderCoefficients() const
Returns the Householder coefficients.