diff options
author | 2010-04-21 17:15:57 +0200 | |
---|---|---|
committer | 2010-04-21 17:15:57 +0200 | |
commit | 28dde19e40a3d758faa94f0fc228857f7b3192ea (patch) | |
tree | 2647d94ffd250e7b215e98baddcecb8fb651543a /Eigen/src/Eigenvalues/ComplexSchur.h | |
parent | faf8f7732dffd33eeae8afc8aad165668c8b6b2e (diff) |
- Added problem size constructor to decompositions that did not have one. It preallocates member data structures.
- Updated unit tests to check above constructor.
- In the compute() method of decompositions: Made temporary matrices/vectors class members to avoid heap allocations during compute() (when dynamic matrices are used, of course).
These changes can speed up decomposition computation time when a solver instance is used to solve multiple same-sized problems. An added benefit is that the compute() method can now be invoked in contexts were heap allocations are forbidden, such as in real-time control loops.
CAVEAT: Not all of the decompositions in the Eigenvalues module have a heap-allocation-free compute() method. A future patch may address this issue, but some required API changes need to be incorporated first.
Diffstat (limited to 'Eigen/src/Eigenvalues/ComplexSchur.h')
-rw-r--r-- | Eigen/src/Eigenvalues/ComplexSchur.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Eigen/src/Eigenvalues/ComplexSchur.h b/Eigen/src/Eigenvalues/ComplexSchur.h index 7c9ab03c8..8874aa257 100644 --- a/Eigen/src/Eigenvalues/ComplexSchur.h +++ b/Eigen/src/Eigenvalues/ComplexSchur.h @@ -96,7 +96,11 @@ template<typename _MatrixType> class ComplexSchur * \sa compute() for an example. */ ComplexSchur(int size = RowsAtCompileTime==Dynamic ? 1 : RowsAtCompileTime) - : m_matT(size,size), m_matU(size,size), m_isInitialized(false), m_matUisUptodate(false) + : m_matT(size,size), + m_matU(size,size), + m_hess(size), + m_isInitialized(false), + m_matUisUptodate(false) {} /** \brief Constructor; computes Schur decomposition of given matrix. @@ -111,6 +115,7 @@ template<typename _MatrixType> class ComplexSchur ComplexSchur(const MatrixType& matrix, bool skipU = false) : m_matT(matrix.rows(),matrix.cols()), m_matU(matrix.rows(),matrix.cols()), + m_hess(matrix.rows()), m_isInitialized(false), m_matUisUptodate(false) { @@ -182,6 +187,7 @@ template<typename _MatrixType> class ComplexSchur protected: ComplexMatrixType m_matT, m_matU; + HessenbergDecomposition<MatrixType> m_hess; bool m_isInitialized; bool m_matUisUptodate; @@ -300,10 +306,10 @@ void ComplexSchur<MatrixType>::compute(const MatrixType& matrix, bool skipU) // Reduce to Hessenberg form // TODO skip Q if skipU = true - HessenbergDecomposition<MatrixType> hess(matrix); + m_hess.compute(matrix); - m_matT = hess.matrixH().template cast<ComplexScalar>(); - if(!skipU) m_matU = hess.matrixQ().template cast<ComplexScalar>(); + m_matT = m_hess.matrixH().template cast<ComplexScalar>(); + if(!skipU) m_matU = m_hess.matrixQ().template cast<ComplexScalar>(); // Reduce the Hessenberg matrix m_matT to triangular form by QR iteration. |