diff options
author | Adolfo Rodriguez Tsouroukdissian <adolfo.rodriguez@pal-robotics.com> | 2010-04-21 17:15:57 +0200 |
---|---|---|
committer | Adolfo Rodriguez Tsouroukdissian <adolfo.rodriguez@pal-robotics.com> | 2010-04-21 17:15:57 +0200 |
commit | 28dde19e40a3d758faa94f0fc228857f7b3192ea (patch) | |
tree | 2647d94ffd250e7b215e98baddcecb8fb651543a /Eigen/src/Eigenvalues/RealSchur.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/RealSchur.h')
-rw-r--r-- | Eigen/src/Eigenvalues/RealSchur.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/Eigen/src/Eigenvalues/RealSchur.h b/Eigen/src/Eigenvalues/RealSchur.h index a66ab8ace..dd4a1ab7e 100644 --- a/Eigen/src/Eigenvalues/RealSchur.h +++ b/Eigen/src/Eigenvalues/RealSchur.h @@ -78,6 +78,7 @@ template<typename _MatrixType> class RealSchur typedef typename MatrixType::Scalar Scalar; typedef std::complex<typename NumTraits<Scalar>::Real> ComplexScalar; typedef Matrix<ComplexScalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> EigenvalueType; + typedef Matrix<Scalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> ColumnVectorType; /** \brief Default constructor. * @@ -92,7 +93,9 @@ template<typename _MatrixType> class RealSchur */ RealSchur(int size = RowsAtCompileTime==Dynamic ? 1 : RowsAtCompileTime) : m_matT(size, size), - m_matU(size, size), + m_matU(size, size), + m_workspaceVector(size), + m_hess(size), m_isInitialized(false) { } @@ -108,6 +111,8 @@ template<typename _MatrixType> class RealSchur RealSchur(const MatrixType& matrix) : m_matT(matrix.rows(),matrix.cols()), m_matU(matrix.rows(),matrix.cols()), + m_workspaceVector(matrix.rows()), + m_hess(matrix.rows()), m_isInitialized(false) { compute(matrix); @@ -165,6 +170,8 @@ template<typename _MatrixType> class RealSchur MatrixType m_matT; MatrixType m_matU; + ColumnVectorType m_workspaceVector; + HessenbergDecomposition<MatrixType> m_hess; bool m_isInitialized; typedef Matrix<Scalar,3,1> Vector3s; @@ -185,14 +192,13 @@ void RealSchur<MatrixType>::compute(const MatrixType& matrix) // Step 1. Reduce to Hessenberg form // TODO skip Q if skipU = true - HessenbergDecomposition<MatrixType> hess(matrix); - m_matT = hess.matrixH(); - m_matU = hess.matrixQ(); + m_hess.compute(matrix); + m_matT = m_hess.matrixH(); + m_matU = m_hess.matrixQ(); // Step 2. Reduce to real Schur form - typedef Matrix<Scalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> ColumnVectorType; - ColumnVectorType workspaceVector(m_matU.cols()); - Scalar* workspace = &workspaceVector.coeffRef(0); + m_workspaceVector.resize(m_matU.cols()); + Scalar* workspace = &m_workspaceVector.coeffRef(0); // The matrix m_matT is divided in three parts. // Rows 0,...,il-1 are decoupled from the rest because m_matT(il,il-1) is zero. |