11 #ifndef EIGEN_HESSENBERGDECOMPOSITION_H
12 #define EIGEN_HESSENBERGDECOMPOSITION_H
18 template<
typename MatrixType>
struct HessenbergDecompositionMatrixHReturnType;
19 template<
typename MatrixType>
20 struct traits<HessenbergDecompositionMatrixHReturnType<MatrixType> >
22 typedef MatrixType ReturnType;
65 Size = MatrixType::RowsAtCompileTime,
67 Options = MatrixType::Options,
68 MaxSize = MatrixType::MaxRowsAtCompileTime,
73 typedef typename MatrixType::Scalar
Scalar;
74 typedef typename MatrixType::Index Index;
87 typedef internal::HessenbergDecompositionMatrixHReturnType<MatrixType> MatrixHReturnType;
101 : m_matrix(size,size),
103 m_isInitialized(false)
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.");
236 .setLength(m_matrix.rows() - 1)
262 eigen_assert(m_isInitialized &&
"HessenbergDecomposition is not initialized.");
263 return MatrixHReturnType(*
this);
276 bool m_isInitialized;
291 template<
typename MatrixType>
292 void HessenbergDecomposition<MatrixType>::_compute(MatrixType& matA, CoeffVectorType& hCoeffs, VectorType& temp)
294 eigen_assert(matA.rows()==matA.cols());
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;
305 hCoeffs.coeffRef(i) = h;
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;
346 HessenbergDecompositionMatrixHReturnType(
const HessenbergDecomposition<MatrixType>& hess) : m_hess(hess) { }
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(); }
366 const HessenbergDecomposition<MatrixType>& m_hess;
373 #endif // EIGEN_HESSENBERGDECOMPOSITION_H
Matrix< Scalar, SizeMinusOne, 1, Options &~RowMajor, MaxSizeMinusOne, 1 > CoeffVectorType
Type for vector of Householder coefficients.
Definition: HessenbergDecomposition.h:82
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:88
const int Dynamic
Definition: Constants.h:21
Sequence of Householder reflections acting on subspaces with decreasing size.
Definition: ForwardDeclarations.h:227
_MatrixType MatrixType
Synonym for the template parameter _MatrixType.
Definition: HessenbergDecomposition.h:62
MatrixHReturnType matrixH() const
Constructs the Hessenberg matrix H in the decomposition.
Definition: HessenbergDecomposition.h:260
HessenbergDecomposition(const MatrixType &matrix)
Constructor; computes Hessenberg decomposition of given matrix.
Definition: HessenbergDecomposition.h:118
MatrixType::Scalar Scalar
Scalar type for matrices of type MatrixType.
Definition: HessenbergDecomposition.h:73
HouseholderSequenceType matrixQ() const
Reconstructs the orthogonal matrix Q in the decomposition.
Definition: HessenbergDecomposition.h:232
HouseholderSequence< MatrixType, typename internal::remove_all< typename CoeffVectorType::ConjugateReturnType >::type > HouseholderSequenceType
Return type of matrixQ()
Definition: HessenbergDecomposition.h:85
HessenbergDecomposition(Index size=Size==Dynamic?2:Size)
Default constructor; the decomposition will be computed later.
Definition: HessenbergDecomposition.h:100
const MatrixType & packedMatrix() const
Returns the internal representation of the decomposition.
Definition: HessenbergDecomposition.h:212
Reduces a square matrix to Hessenberg form by an orthogonal similarity transformation.
Definition: HessenbergDecomposition.h:57
const CoeffVectorType & householderCoefficients() const
Returns the Householder coefficients.
Definition: HessenbergDecomposition.h:177
void resize(Index nbRows, Index nbCols)
Definition: PlainObjectBase.h:235
HessenbergDecomposition & compute(const MatrixType &matrix)
Computes Hessenberg decomposition of given matrix.
Definition: HessenbergDecomposition.h:150