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 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(),
internal::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