mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-04 04:05:19 +08:00
Let complex power fall back to "log, scale, exp".
This commit is contained in:
parent
4e26057f66
commit
04a9ad6e10
@ -455,6 +455,7 @@ template<typename Derived> class MatrixBase
|
|||||||
const MatrixSquareRootReturnValue<Derived> sqrt() const;
|
const MatrixSquareRootReturnValue<Derived> sqrt() const;
|
||||||
const MatrixLogarithmReturnValue<Derived> log() const;
|
const MatrixLogarithmReturnValue<Derived> log() const;
|
||||||
const MatrixPowerReturnValue<Derived> pow(const RealScalar& p) const;
|
const MatrixPowerReturnValue<Derived> pow(const RealScalar& p) const;
|
||||||
|
const MatrixComplexPowerReturnValue<Derived> pow(const std::complex<RealScalar>& p) const;
|
||||||
|
|
||||||
#ifdef EIGEN2_SUPPORT
|
#ifdef EIGEN2_SUPPORT
|
||||||
template<typename ProductDerived, typename Lhs, typename Rhs>
|
template<typename ProductDerived, typename Lhs, typename Rhs>
|
||||||
|
@ -271,6 +271,7 @@ template<typename Derived> class MatrixFunctionReturnValue;
|
|||||||
template<typename Derived> class MatrixSquareRootReturnValue;
|
template<typename Derived> class MatrixSquareRootReturnValue;
|
||||||
template<typename Derived> class MatrixLogarithmReturnValue;
|
template<typename Derived> class MatrixLogarithmReturnValue;
|
||||||
template<typename Derived> class MatrixPowerReturnValue;
|
template<typename Derived> class MatrixPowerReturnValue;
|
||||||
|
template<typename Derived> class MatrixComplexPowerReturnValue;
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template <typename Scalar>
|
template <typename Scalar>
|
||||||
|
@ -503,6 +503,30 @@ class MatrixPowerReturnValue : public ReturnByValue< MatrixPowerReturnValue<Deri
|
|||||||
MatrixPowerReturnValue& operator=(const MatrixPowerReturnValue&);
|
MatrixPowerReturnValue& operator=(const MatrixPowerReturnValue&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename Derived>
|
||||||
|
class MatrixComplexPowerReturnValue : public ReturnByValue< MatrixComplexPowerReturnValue<Derived> >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef typename Derived::PlainObject PlainObject;
|
||||||
|
typedef typename std::complex<typename Derived::RealScalar> ComplexScalar;
|
||||||
|
typedef typename Derived::Index Index;
|
||||||
|
|
||||||
|
MatrixComplexPowerReturnValue(const Derived& A, const ComplexScalar& p) : m_A(A), m_p(p)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
template<typename ResultType>
|
||||||
|
inline void evalTo(ResultType& res) const
|
||||||
|
{ res = (m_p * m_A.log()).exp(); }
|
||||||
|
|
||||||
|
Index rows() const { return m_A.rows(); }
|
||||||
|
Index cols() const { return m_A.cols(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
const Derived& m_A;
|
||||||
|
const ComplexScalar m_p;
|
||||||
|
MatrixComplexPowerReturnValue& operator=(const MatrixComplexPowerReturnValue&);
|
||||||
|
};
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template<typename MatrixPowerType>
|
template<typename MatrixPowerType>
|
||||||
@ -513,12 +537,20 @@ template<typename Derived>
|
|||||||
struct traits< MatrixPowerReturnValue<Derived> >
|
struct traits< MatrixPowerReturnValue<Derived> >
|
||||||
{ typedef typename Derived::PlainObject ReturnType; };
|
{ typedef typename Derived::PlainObject ReturnType; };
|
||||||
|
|
||||||
|
template<typename Derived>
|
||||||
|
struct traits< MatrixComplexPowerReturnValue<Derived> >
|
||||||
|
{ typedef typename Derived::PlainObject ReturnType; };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
const MatrixPowerReturnValue<Derived> MatrixBase<Derived>::pow(const RealScalar& p) const
|
const MatrixPowerReturnValue<Derived> MatrixBase<Derived>::pow(const RealScalar& p) const
|
||||||
{ return MatrixPowerReturnValue<Derived>(derived(), p); }
|
{ return MatrixPowerReturnValue<Derived>(derived(), p); }
|
||||||
|
|
||||||
|
template<typename Derived>
|
||||||
|
const MatrixComplexPowerReturnValue<Derived> MatrixBase<Derived>::pow(const std::complex<RealScalar>& p) const
|
||||||
|
{ return MatrixComplexPowerReturnValue<Derived>(derived(), p); }
|
||||||
|
|
||||||
} // namespace Eigen
|
} // namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_MATRIX_POWER
|
#endif // EIGEN_MATRIX_POWER
|
||||||
|
Loading…
x
Reference in New Issue
Block a user