From 738d75d3eb187bf1b3169d0de4328c6a2a5ef500 Mon Sep 17 00:00:00 2001 From: Chen-Pang He Date: Sat, 13 Jul 2013 22:11:36 +0800 Subject: [PATCH] Document on the return type of MatrixPower::operator() --- .../Eigen/src/MatrixFunctions/MatrixPower.h | 42 ++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h b/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h index e4f13c993..5ba6278ae 100644 --- a/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h +++ b/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h @@ -14,16 +14,48 @@ namespace Eigen { template class MatrixPower; +/** + * \ingroup MatrixFunctions_Module + * + * \brief Proxy for the matrix power of some matrix. + * + * \tparam MatrixType type of the base, a matrix. + * + * This class holds the arguments to the matrix power until it is + * assigned or evaluated for some other reason (so the argument + * should not be changed in the meantime). It is the return type of + * MatrixPower::operator() and related functions and most of the + * time this is the only way it is used. + */ +/* TODO This class is only used by MatrixPower, so it should be nested + * into MatrixPower, like MatrixPower::ReturnValue. However, my + * compiler complained about unused template parameter in the + * following declaration in namespace internal. + * + * template + * struct traits::ReturnValue>; + */ template -class MatrixPowerRetval : public ReturnByValue< MatrixPowerRetval > +class MatrixPowerParenthesesReturnValue : public ReturnByValue< MatrixPowerParenthesesReturnValue > { public: typedef typename MatrixType::RealScalar RealScalar; typedef typename MatrixType::Index Index; - MatrixPowerRetval(MatrixPower& pow, RealScalar p) : m_pow(pow), m_p(p) + /** + * \brief Constructor. + * + * \param[in] pow %MatrixPower storing the base. + * \param[in] p scalar, the exponent of the matrix power. + */ + MatrixPowerParenthesesReturnValue(MatrixPower& pow, RealScalar p) : m_pow(pow), m_p(p) { } + /** + * \brief Compute the matrix power. + * + * \param[out] result + */ template inline void evalTo(ResultType& res) const { m_pow.compute(res, m_p); } @@ -286,8 +318,8 @@ class MatrixPower : internal::noncopyable * \return The expression \f$ A^p \f$, where A is specified in the * constructor. */ - const MatrixPowerRetval operator()(RealScalar p) - { return MatrixPowerRetval(*this, p); } + const MatrixPowerParenthesesReturnValue operator()(RealScalar p) + { return MatrixPowerParenthesesReturnValue(*this, p); } /** * \brief Compute the matrix power. @@ -530,7 +562,7 @@ class MatrixComplexPowerReturnValue : public ReturnByValue< MatrixComplexPowerRe namespace internal { template -struct traits< MatrixPowerRetval > +struct traits< MatrixPowerParenthesesReturnValue > { typedef typename MatrixPowerType::PlainObject ReturnType; }; template