From 33febdb48b188a7edabd73ddb184011d7869f550 Mon Sep 17 00:00:00 2001 From: Desire NUENTSA Date: Fri, 11 Jan 2013 17:36:45 +0100 Subject: Add support for Schur decomposition of matrices in Hessenberg form --- Eigen/src/Eigenvalues/ComplexSchur.h | 32 +++++++++++++++++++++++++++++++- Eigen/src/Eigenvalues/RealSchur.h | 6 +++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/Eigen/src/Eigenvalues/ComplexSchur.h b/Eigen/src/Eigenvalues/ComplexSchur.h index e5466132b..57ce23e42 100644 --- a/Eigen/src/Eigenvalues/ComplexSchur.h +++ b/Eigen/src/Eigenvalues/ComplexSchur.h @@ -187,6 +187,26 @@ template class ComplexSchur * \sa compute(const MatrixType&, bool, Index) */ ComplexSchur& compute(const MatrixType& matrix, bool computeU = true); + + /** \brief Compute Schur decomposition from a given Hessenberg matrix + * \param[in] matrixH Matrix in Hessenberg form H + * \param[in] matrixQ orthogonal matrix Q that transform a matrix A to H : A = Q H Q^T + * \param computeU Computes the matriX U of the Schur vectors + * \return Reference to \c *this + * + * This routine assumes that the matrix is already reduced in Hessenberg form matrixH + * using either the class HessenbergDecomposition or another mean. + * It computes the upper quasi-triangular matrix T of the Schur decomposition of H + * When computeU is true, this routine computes the matrix U such that + * A = U T U^T = (QZ) T (QZ)^T = Q H Q^T where A is the initial matrix + * + * NOTE Q is referenced if computeU is true; so, if the initial orthogonal matrix + * is not available, the user should give an identity matrix (Q.setIdentity()) + * + * \sa compute(const MatrixType&, bool) + */ + template + ComplexSchur& computeFromHessenberg(const HessMatrixType& matrixH, const OrthMatrixType& matrixQ, bool computeU=true); /** \brief Reports whether previous computation was successful. * @@ -309,10 +329,20 @@ ComplexSchur& ComplexSchur::compute(const MatrixType& ma } internal::complex_schur_reduce_to_hessenberg::IsComplex>::run(*this, matrix, computeU); - reduceToTriangularForm(computeU); + computeFromHessenberg(m_matT, m_matU, computeU); return *this; } +template +template +ComplexSchur& ComplexSchur::computeFromHessenberg(const HessMatrixType& matrixH, const OrthMatrixType& matrixQ, bool computeU) +{ + m_matT = matrixH; + if(computeU) + m_matU = matrixQ; + reduceToTriangularForm(computeU); + return *this; +} namespace internal { /* Reduce given matrix to Hessenberg form */ diff --git a/Eigen/src/Eigenvalues/RealSchur.h b/Eigen/src/Eigenvalues/RealSchur.h index 1f349aa4d..7680f9929 100644 --- a/Eigen/src/Eigenvalues/RealSchur.h +++ b/Eigen/src/Eigenvalues/RealSchur.h @@ -185,7 +185,7 @@ template class RealSchur * \sa compute(const MatrixType&, bool) */ template - RealSchur& computeHessenberg(const HessMatrixType& matrixH, const OrthMatrixType& matrixQ, bool computeU); + RealSchur& computeFromHessenberg(const HessMatrixType& matrixH, const OrthMatrixType& matrixQ, bool computeU); /** \brief Reports whether previous computation was successful. * * \returns \c Success if computation was succesful, \c NoConvergence otherwise. @@ -254,13 +254,13 @@ RealSchur& RealSchur::compute(const MatrixType& matrix, m_hess.compute(matrix); // Step 2. Reduce to real Schur form - computeHessenberg(m_hess.matrixH(), m_hess.matrixQ(), computeU); + computeFromHessenberg(m_hess.matrixH(), m_hess.matrixQ(), computeU); return *this; } template template -RealSchur& RealSchur::computeHessenberg(const HessMatrixType& matrixH, const OrthMatrixType& matrixQ, bool computeU) +RealSchur& RealSchur::computeFromHessenberg(const HessMatrixType& matrixH, const OrthMatrixType& matrixQ, bool computeU) { m_matT = matrixH; if(computeU) -- cgit v1.2.3