From 334532b7f56728e425dca64007ff7a3b6857d79f Mon Sep 17 00:00:00 2001 From: Chen-Pang He Date: Sun, 23 Sep 2012 23:49:50 +0800 Subject: Remove class MatrixPowerEvaluator with enhanced existing MatrixPowerReturnValue to simplicity, but docs are not completed yet. --- .../Eigen/src/MatrixFunctions/MatrixPower.h | 61 ++++++---------------- 1 file changed, 15 insertions(+), 46 deletions(-) (limited to 'unsupported/Eigen') diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h b/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h index 0d00cf76e..15ede1c2a 100644 --- a/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h +++ b/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h @@ -12,9 +12,6 @@ namespace Eigen { -template -class MatrixPowerEvaluator; - /** * \ingroup MatrixFunctions_Module * @@ -91,8 +88,8 @@ template class MatrixPower * * \param[in] p exponent, a real scalar. */ - const MatrixPowerEvaluator operator()(RealScalar p) - { return MatrixPowerEvaluator(*this, p); } + const MatrixPowerReturnValue operator()(RealScalar p) + { return MatrixPowerReturnValue(*this, p); } /** * \brief Compute the matrix power. @@ -333,7 +330,13 @@ class MatrixPowerReturnValue : public ReturnByValue(A)), m_p(p), m_del(true) { } + + MatrixPowerReturnValue(MatrixPower& pow, RealScalar p) + : m_pow(&pow), m_p(p), m_del(false) { } + + ~MatrixPowerReturnValue() + { if (m_del) delete m_pow; } /** * \brief Compute the matrix power. @@ -343,52 +346,22 @@ class MatrixPowerReturnValue : public ReturnByValue inline void evalTo(ResultType& res) const - { MatrixPower(m_A).compute(res, m_p); } + { m_pow->compute(res, m_p); } template const MatrixPowerMatrixProduct operator*(const MatrixBase& b) const - { - MatrixPower Apow(m_A); - return MatrixPowerMatrixProduct(Apow, b.derived(), m_p); - } + { return MatrixPowerMatrixProduct(*m_pow, b.derived(), m_p); } - Index rows() const { return m_A.rows(); } - Index cols() const { return m_A.cols(); } + Index rows() const { return m_pow->rows(); } + Index cols() const { return m_pow->cols(); } private: - const Derived& m_A; + MatrixPower* m_pow; const RealScalar m_p; + const bool m_del; // whether to delete the pointer at destruction MatrixPowerReturnValue& operator=(const MatrixPowerReturnValue&); }; -template -class MatrixPowerEvaluator -: public ReturnByValue > -{ - public: - typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; - - MatrixPowerEvaluator(MatrixPower& ref, RealScalar p) - : m_pow(ref), m_p(p) { } - - template - inline void evalTo(ResultType& res) const - { m_pow.compute(res, m_p); } - - template - const MatrixPowerMatrixProduct operator*(const MatrixBase& b) const - { return MatrixPowerMatrixProduct(m_pow, b.derived(), m_p); } - - Index rows() const { return m_pow.rows(); } - Index cols() const { return m_pow.cols(); } - - private: - MatrixPower& m_pow; - const RealScalar m_p; - MatrixPowerEvaluator& operator=(const MatrixPowerEvaluator&); -}; - namespace internal { template struct nested > @@ -398,10 +371,6 @@ template struct traits > { typedef typename Derived::PlainObject ReturnType; }; -template -struct traits > -{ typedef MatrixType ReturnType; }; - template struct traits > : traits,Lhs,Rhs> > -- cgit v1.2.3