mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-03 03:35:11 +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 MatrixLogarithmReturnValue<Derived> log() const;
|
||||
const MatrixPowerReturnValue<Derived> pow(const RealScalar& p) const;
|
||||
const MatrixComplexPowerReturnValue<Derived> pow(const std::complex<RealScalar>& p) const;
|
||||
|
||||
#ifdef EIGEN2_SUPPORT
|
||||
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 MatrixLogarithmReturnValue;
|
||||
template<typename Derived> class MatrixPowerReturnValue;
|
||||
template<typename Derived> class MatrixComplexPowerReturnValue;
|
||||
|
||||
namespace internal {
|
||||
template <typename Scalar>
|
||||
|
@ -503,6 +503,30 @@ class MatrixPowerReturnValue : public ReturnByValue< MatrixPowerReturnValue<Deri
|
||||
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 {
|
||||
|
||||
template<typename MatrixPowerType>
|
||||
@ -513,12 +537,20 @@ template<typename Derived>
|
||||
struct traits< MatrixPowerReturnValue<Derived> >
|
||||
{ typedef typename Derived::PlainObject ReturnType; };
|
||||
|
||||
template<typename Derived>
|
||||
struct traits< MatrixComplexPowerReturnValue<Derived> >
|
||||
{ typedef typename Derived::PlainObject ReturnType; };
|
||||
|
||||
}
|
||||
|
||||
template<typename Derived>
|
||||
const MatrixPowerReturnValue<Derived> MatrixBase<Derived>::pow(const RealScalar& p) const
|
||||
{ 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
|
||||
|
||||
#endif // EIGEN_MATRIX_POWER
|
||||
|
Loading…
x
Reference in New Issue
Block a user