2012-08-15 00:34:20 +08:00
|
|
|
// This file is part of Eigen, a lightweight C++ template library
|
|
|
|
|
// for linear algebra.
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2012 Chen-Pang He <jdh8@ms63.hinet.net>
|
|
|
|
|
//
|
|
|
|
|
// This Source Code Form is subject to the terms of the Mozilla
|
|
|
|
|
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
|
|
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
|
|
#ifndef EIGEN_MATRIX_POWER
|
|
|
|
|
#define EIGEN_MATRIX_POWER
|
|
|
|
|
|
|
|
|
|
namespace Eigen {
|
|
|
|
|
|
2012-08-28 01:55:13 +08:00
|
|
|
/**
|
|
|
|
|
* \ingroup MatrixFunctions_Module
|
|
|
|
|
*
|
2012-09-21 23:24:28 +08:00
|
|
|
* \brief Class for computing matrix powers.
|
2012-08-28 01:55:13 +08:00
|
|
|
*
|
2012-09-21 23:24:28 +08:00
|
|
|
* \tparam MatrixType type of the base, expected to be an instantiation
|
|
|
|
|
* of the Matrix class template.
|
2012-08-28 01:55:13 +08:00
|
|
|
*
|
2012-09-21 23:24:28 +08:00
|
|
|
* This class is capable of computing real/complex matrices raised to
|
|
|
|
|
* an arbitrary real power. Meanwhile, it saves the result of Schur
|
|
|
|
|
* decomposition if an non-integral power has even been calculated.
|
|
|
|
|
* Therefore, if you want to compute multiple (>= 2) matrix powers
|
|
|
|
|
* for the same matrix, using the class directly is more efficient than
|
|
|
|
|
* calling MatrixBase::pow().
|
|
|
|
|
*
|
|
|
|
|
* Example:
|
|
|
|
|
* \include MatrixPower_optimal.cpp
|
|
|
|
|
* Output: \verbinclude MatrixPower_optimal.out
|
2012-08-28 01:55:13 +08:00
|
|
|
*/
|
2012-09-21 23:24:28 +08:00
|
|
|
template<typename MatrixType> class MatrixPower
|
2012-08-15 00:34:20 +08:00
|
|
|
{
|
2012-08-28 01:55:13 +08:00
|
|
|
private:
|
2012-09-21 23:24:28 +08:00
|
|
|
static const int Rows = MatrixType::RowsAtCompileTime;
|
|
|
|
|
static const int Cols = MatrixType::ColsAtCompileTime;
|
|
|
|
|
static const int Options = MatrixType::Options;
|
|
|
|
|
static const int MaxRows = MatrixType::MaxRowsAtCompileTime;
|
|
|
|
|
static const int MaxCols = MatrixType::MaxColsAtCompileTime;
|
|
|
|
|
|
|
|
|
|
typedef typename MatrixType::Scalar Scalar;
|
|
|
|
|
typedef typename MatrixType::RealScalar RealScalar;
|
|
|
|
|
typedef typename MatrixType::Index Index;
|
|
|
|
|
typedef Matrix<std::complex<RealScalar>,Rows,Cols,Options,MaxRows,MaxCols> ComplexMatrix;
|
|
|
|
|
|
2012-09-23 18:49:44 +08:00
|
|
|
const MatrixType* m_A;
|
2012-09-21 23:24:28 +08:00
|
|
|
MatrixType m_tmp1, m_tmp2;
|
|
|
|
|
ComplexMatrix m_T, m_U, m_fT;
|
2012-09-23 18:49:44 +08:00
|
|
|
char m_flag;
|
2012-09-21 23:24:28 +08:00
|
|
|
|
|
|
|
|
RealScalar modfAndInit(RealScalar, RealScalar*);
|
|
|
|
|
|
2012-09-23 00:20:19 +08:00
|
|
|
template<typename Derived, typename ResultType>
|
|
|
|
|
void apply(const Derived&, ResultType&, bool&);
|
2012-09-21 23:24:28 +08:00
|
|
|
|
|
|
|
|
template<typename ResultType>
|
|
|
|
|
void computeIntPower(ResultType&, RealScalar);
|
|
|
|
|
|
2012-09-23 00:20:19 +08:00
|
|
|
template<typename Derived, typename ResultType>
|
|
|
|
|
void computeIntPower(const Derived&, ResultType&, RealScalar);
|
2012-09-21 23:24:28 +08:00
|
|
|
|
|
|
|
|
template<typename ResultType>
|
|
|
|
|
void computeFracPower(ResultType&, RealScalar);
|
2012-08-15 00:34:20 +08:00
|
|
|
|
2012-08-28 01:55:13 +08:00
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* \brief Constructor.
|
|
|
|
|
*
|
2012-09-21 23:24:28 +08:00
|
|
|
* \param[in] A the base of the matrix power.
|
2012-08-28 01:55:13 +08:00
|
|
|
*/
|
2012-09-21 23:24:28 +08:00
|
|
|
explicit MatrixPower(const MatrixType& A);
|
2012-08-15 00:34:20 +08:00
|
|
|
|
2012-09-23 18:49:44 +08:00
|
|
|
/**
|
|
|
|
|
* \brief Constructor.
|
|
|
|
|
*
|
|
|
|
|
* \param[in] A the base of the matrix power.
|
|
|
|
|
*/
|
|
|
|
|
template<typename Derived>
|
|
|
|
|
explicit MatrixPower(const MatrixBase<Derived>& A);
|
|
|
|
|
|
|
|
|
|
/** \brief Destructor. */
|
|
|
|
|
~MatrixPower();
|
|
|
|
|
|
2012-08-28 01:55:13 +08:00
|
|
|
/**
|
2012-09-21 23:24:28 +08:00
|
|
|
* \brief Return the expression \f$ A^p \f$.
|
2012-08-28 01:55:13 +08:00
|
|
|
*
|
2012-09-21 23:24:28 +08:00
|
|
|
* \param[in] p exponent, a real scalar.
|
2012-08-28 01:55:13 +08:00
|
|
|
*/
|
2012-09-23 23:49:50 +08:00
|
|
|
const MatrixPowerReturnValue<MatrixType> operator()(RealScalar p)
|
|
|
|
|
{ return MatrixPowerReturnValue<MatrixType>(*this, p); }
|
2012-08-15 00:34:20 +08:00
|
|
|
|
2012-09-21 23:24:28 +08:00
|
|
|
/**
|
|
|
|
|
* \brief Compute the matrix power.
|
|
|
|
|
*
|
|
|
|
|
* \param[in] p exponent, a real scalar.
|
|
|
|
|
* \param[out] res \f$ A^p \f$ where A is specified in the
|
|
|
|
|
* constructor.
|
|
|
|
|
*/
|
|
|
|
|
void compute(MatrixType& res, RealScalar p);
|
2012-08-28 01:55:13 +08:00
|
|
|
|
2012-09-21 23:24:28 +08:00
|
|
|
/**
|
|
|
|
|
* \brief Compute the matrix power multiplied by another matrix.
|
|
|
|
|
*
|
|
|
|
|
* \param[in] b a matrix with the same rows as A.
|
|
|
|
|
* \param[in] p exponent, a real scalar.
|
|
|
|
|
* \param[in] noalias
|
|
|
|
|
* \param[out] res \f$ A^p b \f$, where A is specified in the
|
|
|
|
|
* constructor.
|
|
|
|
|
*/
|
2012-09-23 00:20:19 +08:00
|
|
|
template<typename Derived, typename ResultType>
|
|
|
|
|
void compute(const Derived& b, ResultType& res, RealScalar p);
|
2012-09-21 23:24:28 +08:00
|
|
|
|
2012-09-23 18:49:44 +08:00
|
|
|
Index rows() const { return m_A->rows(); }
|
|
|
|
|
Index cols() const { return m_A->cols(); }
|
2012-08-28 01:55:13 +08:00
|
|
|
};
|
2012-08-15 00:34:20 +08:00
|
|
|
|
2012-09-21 23:24:28 +08:00
|
|
|
template<typename MatrixType>
|
|
|
|
|
MatrixPower<MatrixType>::MatrixPower(const MatrixType& A) :
|
2012-09-23 18:49:44 +08:00
|
|
|
m_A(&A),
|
|
|
|
|
m_flag(0)
|
|
|
|
|
{ /* empty body */ }
|
|
|
|
|
|
|
|
|
|
template<typename MatrixType>
|
|
|
|
|
template<typename Derived>
|
|
|
|
|
MatrixPower<MatrixType>::MatrixPower(const MatrixBase<Derived>& A) :
|
|
|
|
|
m_A(new MatrixType(A)),
|
|
|
|
|
m_flag(2)
|
2012-09-21 23:24:28 +08:00
|
|
|
{ /* empty body */ }
|
|
|
|
|
|
2012-09-23 18:49:44 +08:00
|
|
|
template<typename MatrixType>
|
|
|
|
|
MatrixPower<MatrixType>::~MatrixPower()
|
|
|
|
|
{ if (m_flag & 2) delete m_A; }
|
|
|
|
|
|
2012-09-21 23:24:28 +08:00
|
|
|
template<typename MatrixType>
|
|
|
|
|
void MatrixPower<MatrixType>::compute(MatrixType& res, RealScalar p)
|
|
|
|
|
{
|
2012-09-23 18:49:44 +08:00
|
|
|
switch (m_A->cols()) {
|
2012-09-21 23:24:28 +08:00
|
|
|
case 0:
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
2012-09-23 18:49:44 +08:00
|
|
|
res(0,0) = std::pow(m_A->coeff(0,0), p);
|
2012-09-21 23:24:28 +08:00
|
|
|
break;
|
|
|
|
|
default:
|
2012-09-23 18:49:44 +08:00
|
|
|
RealScalar intpart, x = modfAndInit(p, &intpart);
|
|
|
|
|
res = MatrixType::Identity(m_A->rows(), m_A->cols());
|
2012-09-21 23:24:28 +08:00
|
|
|
computeIntPower(res, intpart);
|
|
|
|
|
computeFracPower(res, x);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename MatrixType>
|
2012-09-23 00:20:19 +08:00
|
|
|
template<typename Derived, typename ResultType>
|
|
|
|
|
void MatrixPower<MatrixType>::compute(const Derived& b, ResultType& res, RealScalar p)
|
2012-09-21 23:24:28 +08:00
|
|
|
{
|
2012-09-23 18:49:44 +08:00
|
|
|
switch (m_A->cols()) {
|
2012-09-21 23:24:28 +08:00
|
|
|
case 0:
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
2012-09-23 18:49:44 +08:00
|
|
|
res = std::pow(m_A->coeff(0,0), p) * b;
|
2012-09-21 23:24:28 +08:00
|
|
|
break;
|
|
|
|
|
default:
|
2012-09-23 18:49:44 +08:00
|
|
|
RealScalar intpart, x = modfAndInit(p, &intpart);
|
2012-09-21 23:24:28 +08:00
|
|
|
computeIntPower(b, res, intpart);
|
|
|
|
|
computeFracPower(res, x);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename MatrixType>
|
|
|
|
|
typename MatrixType::RealScalar MatrixPower<MatrixType>::modfAndInit(RealScalar x, RealScalar* intpart)
|
|
|
|
|
{
|
|
|
|
|
static RealScalar maxAbsEival, minAbsEival;
|
|
|
|
|
*intpart = std::floor(x);
|
|
|
|
|
RealScalar res = x - *intpart;
|
|
|
|
|
|
2012-09-23 18:49:44 +08:00
|
|
|
if (!(m_flag & 1) && res) {
|
|
|
|
|
const ComplexSchur<MatrixType> schurOfA(*m_A);
|
2012-09-21 23:24:28 +08:00
|
|
|
m_T = schurOfA.matrixT();
|
|
|
|
|
m_U = schurOfA.matrixU();
|
2012-09-23 18:49:44 +08:00
|
|
|
m_flag |= 1;
|
2012-09-21 23:24:28 +08:00
|
|
|
|
|
|
|
|
const Array<RealScalar,EIGEN_SIZE_MIN_PREFER_FIXED(Rows,Cols),1,ColMajor,EIGEN_SIZE_MIN_PREFER_FIXED(MaxRows,MaxCols)>
|
|
|
|
|
absTdiag = m_T.diagonal().array().abs();
|
|
|
|
|
maxAbsEival = absTdiag.maxCoeff();
|
|
|
|
|
minAbsEival = absTdiag.minCoeff();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (res > RealScalar(0.5) && res > (1-res) * std::pow(maxAbsEival/minAbsEival, res)) {
|
|
|
|
|
--res;
|
|
|
|
|
++*intpart;
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename MatrixType>
|
2012-09-23 00:20:19 +08:00
|
|
|
template<typename Derived, typename ResultType>
|
|
|
|
|
void MatrixPower<MatrixType>::apply(const Derived& b, ResultType& res, bool& init)
|
2012-09-21 23:24:28 +08:00
|
|
|
{
|
|
|
|
|
if (init)
|
|
|
|
|
res = m_tmp1 * res;
|
|
|
|
|
else {
|
|
|
|
|
init = true;
|
|
|
|
|
res.noalias() = m_tmp1 * b;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename MatrixType>
|
|
|
|
|
template<typename ResultType>
|
|
|
|
|
void MatrixPower<MatrixType>::computeIntPower(ResultType& res, RealScalar p)
|
|
|
|
|
{
|
|
|
|
|
RealScalar pp = std::abs(p);
|
|
|
|
|
|
2012-09-23 18:49:44 +08:00
|
|
|
if (p<0) m_tmp1 = m_A->inverse();
|
|
|
|
|
else m_tmp1 = *m_A;
|
2012-09-21 23:24:28 +08:00
|
|
|
|
|
|
|
|
while (pp >= 1) {
|
|
|
|
|
if (std::fmod(pp, 2) >= 1)
|
|
|
|
|
res = m_tmp1 * res;
|
|
|
|
|
m_tmp1 *= m_tmp1;
|
|
|
|
|
pp /= 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename MatrixType>
|
2012-09-23 00:20:19 +08:00
|
|
|
template<typename Derived, typename ResultType>
|
|
|
|
|
void MatrixPower<MatrixType>::computeIntPower(const Derived& b, ResultType& res, RealScalar p)
|
2012-09-21 23:24:28 +08:00
|
|
|
{
|
2012-09-23 18:49:44 +08:00
|
|
|
if (b.cols() >= m_A->cols()) {
|
|
|
|
|
m_tmp2 = MatrixType::Identity(m_A->rows(), m_A->cols());
|
2012-09-21 23:24:28 +08:00
|
|
|
computeIntPower(m_tmp2, p);
|
|
|
|
|
res.noalias() = m_tmp2 * b;
|
2012-09-22 17:37:14 +08:00
|
|
|
}
|
|
|
|
|
else {
|
2012-09-21 23:24:28 +08:00
|
|
|
RealScalar pp = std::abs(p);
|
2012-09-22 17:37:14 +08:00
|
|
|
int squarings, applyings = internal::binary_powering_cost(pp, &squarings);
|
2012-09-21 23:24:28 +08:00
|
|
|
bool init = false;
|
|
|
|
|
|
|
|
|
|
if (p==0) {
|
|
|
|
|
res = b;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-09-22 17:37:14 +08:00
|
|
|
else if (p>0) {
|
2012-09-23 18:49:44 +08:00
|
|
|
m_tmp1 = *m_A;
|
2012-09-22 17:37:14 +08:00
|
|
|
}
|
2012-09-23 18:49:44 +08:00
|
|
|
else if (m_A->cols() > 2 && b.cols()*(pp-applyings) <= m_A->cols()*squarings) {
|
|
|
|
|
PartialPivLU<MatrixType> A(*m_A);
|
2012-09-22 17:37:14 +08:00
|
|
|
res = A.solve(b);
|
|
|
|
|
for (--pp; pp >= 1; --pp)
|
|
|
|
|
res = A.solve(res);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-09-23 18:49:44 +08:00
|
|
|
m_tmp1 = m_A->inverse();
|
2012-09-22 17:37:14 +08:00
|
|
|
}
|
2012-09-21 23:24:28 +08:00
|
|
|
|
2012-09-23 18:49:44 +08:00
|
|
|
while (b.cols()*(pp-applyings) > m_A->cols()*squarings) {
|
2012-09-21 23:24:28 +08:00
|
|
|
if (std::fmod(pp, 2) >= 1) {
|
|
|
|
|
apply(b, res, init);
|
2012-09-22 17:37:14 +08:00
|
|
|
--applyings;
|
2012-09-21 23:24:28 +08:00
|
|
|
}
|
|
|
|
|
m_tmp1 *= m_tmp1;
|
2012-09-22 17:37:14 +08:00
|
|
|
--squarings;
|
2012-09-21 23:24:28 +08:00
|
|
|
pp /= 2;
|
|
|
|
|
}
|
|
|
|
|
for (; pp >= 1; --pp)
|
|
|
|
|
apply(b, res, init);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename MatrixType>
|
|
|
|
|
template<typename ResultType>
|
|
|
|
|
void MatrixPower<MatrixType>::computeFracPower(ResultType& res, RealScalar p)
|
|
|
|
|
{
|
|
|
|
|
if (p) {
|
|
|
|
|
MatrixPowerTriangularAtomic<ComplexMatrix>(m_T).compute(m_fT, p);
|
|
|
|
|
internal::recompose_complex_schur<NumTraits<Scalar>::IsComplex>::run(m_tmp1, m_fT, m_U);
|
|
|
|
|
res = m_tmp1 * res;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-23 00:20:19 +08:00
|
|
|
template<typename Lhs, typename Rhs>
|
|
|
|
|
class MatrixPowerMatrixProduct : public MatrixPowerProductBase<MatrixPowerMatrixProduct<Lhs,Rhs>,Lhs,Rhs>
|
2012-09-22 03:26:00 +08:00
|
|
|
{
|
|
|
|
|
public:
|
2012-09-23 00:20:19 +08:00
|
|
|
EIGEN_MATRIX_POWER_PRODUCT_PUBLIC_INTERFACE(MatrixPowerMatrixProduct)
|
2012-09-22 03:26:00 +08:00
|
|
|
|
2012-09-23 00:20:19 +08:00
|
|
|
MatrixPowerMatrixProduct(MatrixPower<Lhs>& pow, const Rhs& b, RealScalar p)
|
2012-09-22 03:26:00 +08:00
|
|
|
: m_pow(pow), m_b(b), m_p(p) { }
|
|
|
|
|
|
|
|
|
|
template<typename ResultType>
|
|
|
|
|
inline void evalTo(ResultType& res) const
|
|
|
|
|
{ m_pow.compute(m_b, res, m_p); }
|
|
|
|
|
|
|
|
|
|
Index rows() const { return m_b.rows(); }
|
|
|
|
|
Index cols() const { return m_b.cols(); }
|
|
|
|
|
|
|
|
|
|
private:
|
2012-09-23 00:20:19 +08:00
|
|
|
MatrixPower<Lhs>& m_pow;
|
|
|
|
|
const Rhs& m_b;
|
2012-09-22 03:26:00 +08:00
|
|
|
const RealScalar m_p;
|
|
|
|
|
MatrixPowerMatrixProduct& operator=(const MatrixPowerMatrixProduct&);
|
|
|
|
|
};
|
|
|
|
|
|
2012-08-15 00:34:20 +08:00
|
|
|
/**
|
|
|
|
|
* \ingroup MatrixFunctions_Module
|
|
|
|
|
*
|
|
|
|
|
* \brief Proxy for the matrix power of some matrix (expression).
|
|
|
|
|
*
|
2012-08-28 01:55:13 +08:00
|
|
|
* \tparam Derived type of the base, a matrix (expression).
|
2012-08-15 00:34:20 +08:00
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
* MatrixBase::pow() and related functions and most of the
|
|
|
|
|
* time this is the only way it is used.
|
|
|
|
|
*/
|
2012-08-28 01:55:13 +08:00
|
|
|
template<typename Derived>
|
|
|
|
|
class MatrixPowerReturnValue : public ReturnByValue<MatrixPowerReturnValue<Derived> >
|
2012-08-15 00:34:20 +08:00
|
|
|
{
|
2012-09-21 23:24:28 +08:00
|
|
|
public:
|
2012-09-23 18:49:44 +08:00
|
|
|
typedef typename Derived::PlainObject PlainObject;
|
2012-08-28 01:55:13 +08:00
|
|
|
typedef typename Derived::RealScalar RealScalar;
|
2012-08-15 00:34:20 +08:00
|
|
|
typedef typename Derived::Index Index;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \brief Constructor.
|
|
|
|
|
*
|
|
|
|
|
* \param[in] A %Matrix (expression), the base of the matrix power.
|
|
|
|
|
* \param[in] p scalar, the exponent of the matrix power.
|
|
|
|
|
*/
|
2012-08-28 01:55:13 +08:00
|
|
|
MatrixPowerReturnValue(const Derived& A, RealScalar p)
|
2012-09-23 23:49:50 +08:00
|
|
|
: m_pow(new MatrixPower<PlainObject>(A)), m_p(p), m_del(true) { }
|
|
|
|
|
|
|
|
|
|
MatrixPowerReturnValue(MatrixPower<PlainObject>& pow, RealScalar p)
|
|
|
|
|
: m_pow(&pow), m_p(p), m_del(false) { }
|
|
|
|
|
|
|
|
|
|
~MatrixPowerReturnValue()
|
|
|
|
|
{ if (m_del) delete m_pow; }
|
2012-08-15 00:34:20 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \brief Compute the matrix power.
|
|
|
|
|
*
|
2012-08-19 18:12:04 +08:00
|
|
|
* \param[out] result \f$ A^p \f$ where \p A and \p p are as in the
|
2012-08-15 00:34:20 +08:00
|
|
|
* constructor.
|
|
|
|
|
*/
|
2012-08-28 01:55:13 +08:00
|
|
|
template<typename ResultType>
|
2012-09-21 23:24:28 +08:00
|
|
|
inline void evalTo(ResultType& res) const
|
2012-09-23 23:49:50 +08:00
|
|
|
{ m_pow->compute(res, m_p); }
|
2012-09-23 18:49:44 +08:00
|
|
|
|
|
|
|
|
template<typename OtherDerived>
|
|
|
|
|
const MatrixPowerMatrixProduct<PlainObject,OtherDerived> operator*(const MatrixBase<OtherDerived>& b) const
|
2012-09-23 23:49:50 +08:00
|
|
|
{ return MatrixPowerMatrixProduct<PlainObject,OtherDerived>(*m_pow, b.derived(), m_p); }
|
2012-08-15 00:34:20 +08:00
|
|
|
|
2012-09-23 23:49:50 +08:00
|
|
|
Index rows() const { return m_pow->rows(); }
|
|
|
|
|
Index cols() const { return m_pow->cols(); }
|
2012-08-15 00:34:20 +08:00
|
|
|
|
|
|
|
|
private:
|
2012-09-23 23:49:50 +08:00
|
|
|
MatrixPower<PlainObject>* m_pow;
|
2012-08-28 01:55:13 +08:00
|
|
|
const RealScalar m_p;
|
2012-09-23 23:49:50 +08:00
|
|
|
const bool m_del; // whether to delete the pointer at destruction
|
2012-08-15 00:34:20 +08:00
|
|
|
MatrixPowerReturnValue& operator=(const MatrixPowerReturnValue&);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
namespace internal {
|
2012-09-23 00:20:19 +08:00
|
|
|
template<typename MatrixType, typename Derived>
|
|
|
|
|
struct nested<MatrixPowerMatrixProduct<MatrixType,Derived> >
|
|
|
|
|
{ typedef typename MatrixPowerMatrixProduct<MatrixType,Derived>::PlainObject const& type; };
|
2012-09-22 03:26:00 +08:00
|
|
|
|
2012-09-21 23:24:28 +08:00
|
|
|
template<typename Derived>
|
|
|
|
|
struct traits<MatrixPowerReturnValue<Derived> >
|
|
|
|
|
{ typedef typename Derived::PlainObject ReturnType; };
|
|
|
|
|
|
2012-09-23 00:20:19 +08:00
|
|
|
template<typename Lhs, typename Rhs>
|
|
|
|
|
struct traits<MatrixPowerMatrixProduct<Lhs,Rhs> >
|
|
|
|
|
: traits<MatrixPowerProductBase<MatrixPowerMatrixProduct<Lhs,Rhs>,Lhs,Rhs> >
|
|
|
|
|
{ };
|
2012-08-15 00:34:20 +08:00
|
|
|
}
|
|
|
|
|
|
2012-08-28 01:55:13 +08:00
|
|
|
template<typename Derived>
|
|
|
|
|
const MatrixPowerReturnValue<Derived> MatrixBase<Derived>::pow(RealScalar p) const
|
2012-08-15 00:34:20 +08:00
|
|
|
{
|
|
|
|
|
eigen_assert(rows() == cols());
|
2012-08-28 01:55:13 +08:00
|
|
|
return MatrixPowerReturnValue<Derived>(derived(), p);
|
2012-08-15 00:34:20 +08:00
|
|
|
}
|
|
|
|
|
|
2012-09-22 03:26:00 +08:00
|
|
|
} // namespace Eigen
|
2012-08-15 00:34:20 +08:00
|
|
|
|
|
|
|
|
#endif // EIGEN_MATRIX_POWER
|