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;
87 typedef internal::HessenbergDecompositionMatrixHReturnType<MatrixType> MatrixHReturnType;
101 : m_matrix(size,size),
103 m_isInitialized(false)
118 template<
typename InputType>
120 : m_matrix(matrix.derived()),
121 m_temp(matrix.rows()),
122 m_isInitialized(false)
126 m_isInitialized =
true;
130 _compute(m_matrix, m_hCoeffs, m_temp);
131 m_isInitialized =
true;
151 template<
typename InputType>
157 m_isInitialized =
true;
161 _compute(m_matrix, m_hCoeffs, m_temp);
162 m_isInitialized =
true;
181 eigen_assert(m_isInitialized &&
"HessenbergDecomposition is not initialized.");
216 eigen_assert(m_isInitialized &&
"HessenbergDecomposition is not initialized.");
236 eigen_assert(m_isInitialized &&
"HessenbergDecomposition is not initialized.");
238 .setLength(m_matrix.rows() - 1)
264 eigen_assert(m_isInitialized &&
"HessenbergDecomposition is not initialized.");
265 return MatrixHReturnType(*
this);
278 bool m_isInitialized;
293 template<
typename MatrixType>
294 void HessenbergDecomposition<MatrixType>::_compute(MatrixType& matA, CoeffVectorType& hCoeffs, VectorType& temp)
296 eigen_assert(matA.rows()==matA.cols());
297 Index n = matA.rows();
299 for (Index i = 0; i<n-1; ++i)
302 Index remainingSize = n-i-1;
305 matA.col(i).tail(remainingSize).makeHouseholderInPlace(h, beta);
306 matA.col(i).coeffRef(i+1) = beta;
307 hCoeffs.coeffRef(i) = h;
313 matA.bottomRightCorner(remainingSize, remainingSize)
314 .applyHouseholderOnTheLeft(matA.col(i).tail(remainingSize-1), h, &temp.coeffRef(0));
317 matA.rightCols(remainingSize)
318 .applyHouseholderOnTheRight(matA.col(i).tail(remainingSize-1), numext::conj(h), &temp.coeffRef(0));
339 template<
typename MatrixType>
struct HessenbergDecompositionMatrixHReturnType
340 :
public ReturnByValue<HessenbergDecompositionMatrixHReturnType<MatrixType> >
347 HessenbergDecompositionMatrixHReturnType(
const HessenbergDecomposition<MatrixType>& hess) : m_hess(hess) { }
354 template <
typename ResultType>
355 inline void evalTo(ResultType& result)
const
357 result = m_hess.packedMatrix();
358 Index n = result.rows();
360 result.bottomLeftCorner(n-2, n-2).template triangularView<Lower>().setZero();
363 Index rows()
const {
return m_hess.packedMatrix().rows(); }
364 Index cols()
const {
return m_hess.packedMatrix().cols(); }
367 const HessenbergDecomposition<MatrixType>& m_hess;
374 #endif // EIGEN_HESSENBERGDECOMPOSITION_H