mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-08 01:39:03 +08:00
add missing support for std::pow(array,scalar)
This commit is contained in:
parent
eba418a458
commit
575ac5409c
@ -60,6 +60,12 @@ namespace std
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(log,ei_scalar_log_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(abs,ei_scalar_abs_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(sqrt,ei_scalar_sqrt_op)
|
||||
|
||||
template<typename Derived>
|
||||
inline const Eigen::CwiseUnaryOp<Eigen::ei_scalar_pow_op<typename Derived::Scalar>, Derived>
|
||||
pow(const Eigen::ArrayBase<Derived>& x, const typename Derived::Scalar& exponent) { \
|
||||
return x.derived().pow(exponent); \
|
||||
}
|
||||
}
|
||||
|
||||
namespace Eigen
|
||||
|
@ -171,6 +171,12 @@ template<typename ArrayType> void array_real(const ArrayType& m)
|
||||
VERIFY_IS_APPROX(m1.exp() * m2.exp(), std::exp(m1+m2));
|
||||
VERIFY_IS_APPROX(m1.exp(), ei_exp(m1));
|
||||
VERIFY_IS_APPROX(m1.exp() / m2.exp(), std::exp(m1-m2));
|
||||
|
||||
VERIFY_IS_APPROX(m1.pow(2), m1.square());
|
||||
VERIFY_IS_APPROX(std::pow(m1,2), m1.square());
|
||||
m3 = m1.abs();
|
||||
VERIFY_IS_APPROX(m3.pow(RealScalar(0.5)), m3.sqrt());
|
||||
VERIFY_IS_APPROX(std::pow(m3,RealScalar(0.5)), m3.sqrt());
|
||||
}
|
||||
|
||||
void test_array()
|
||||
|
Loading…
x
Reference in New Issue
Block a user