diff options
-rw-r--r-- | Eigen/src/plugins/ArrayCwiseUnaryOps.h | 5 | ||||
-rw-r--r-- | test/array.cpp | 14 |
2 files changed, 15 insertions, 4 deletions
diff --git a/Eigen/src/plugins/ArrayCwiseUnaryOps.h b/Eigen/src/plugins/ArrayCwiseUnaryOps.h index a59636790..b58d8667c 100644 --- a/Eigen/src/plugins/ArrayCwiseUnaryOps.h +++ b/Eigen/src/plugins/ArrayCwiseUnaryOps.h @@ -191,6 +191,11 @@ cube() const METHOD_NAME(const Scalar& s) const { \ return CwiseUnaryOp<std::binder2nd<FUNCTOR<Scalar> >, const Derived> \ (derived(), std::bind2nd(FUNCTOR<Scalar>(), s)); \ + } \ + friend inline const CwiseUnaryOp<std::binder1st<FUNCTOR<Scalar> >, const Derived> \ + METHOD_NAME(const Scalar& s, const Derived& d) { \ + return CwiseUnaryOp<std::binder1st<FUNCTOR<Scalar> >, const Derived> \ + (d, std::bind1st(FUNCTOR<Scalar>(), s)); \ } EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(operator==, std::equal_to) diff --git a/test/array.cpp b/test/array.cpp index 8960e49f8..f1deda7e3 100644 --- a/test/array.cpp +++ b/test/array.cpp @@ -110,11 +110,17 @@ template<typename ArrayType> void comparisons(const ArrayType& m) VERIFY(! (m1 > m3).all() ); } - // comparisons to scalar + // comparisons array to scalar VERIFY( (m1 != (m1(r,c)+1) ).any() ); - VERIFY( (m1 > (m1(r,c)-1) ).any() ); - VERIFY( (m1 < (m1(r,c)+1) ).any() ); - VERIFY( (m1 == m1(r,c) ).any() ); + VERIFY( (m1 > (m1(r,c)-1) ).any() ); + VERIFY( (m1 < (m1(r,c)+1) ).any() ); + VERIFY( (m1 == m1(r,c) ).any() ); + + // comparisons scalar to array + VERIFY( ( (m1(r,c)+1) != m1).any() ); + VERIFY( ( (m1(r,c)-1) < m1).any() ); + VERIFY( ( (m1(r,c)+1) > m1).any() ); + VERIFY( ( m1(r,c) == m1).any() ); // test Select VERIFY_IS_APPROX( (m1<m2).select(m1,m2), m1.cwiseMin(m2) ); |