mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-03-07 18:27:40 +08:00
Added comparisons scalar to array (previously only the array to scalar was possible) (Fixes bug #147)
Extended the unit test for that
This commit is contained in:
parent
3d2a3bc755
commit
36052c4911
@ -191,6 +191,11 @@ cube() const
|
|||||||
METHOD_NAME(const Scalar& s) const { \
|
METHOD_NAME(const Scalar& s) const { \
|
||||||
return CwiseUnaryOp<std::binder2nd<FUNCTOR<Scalar> >, const Derived> \
|
return CwiseUnaryOp<std::binder2nd<FUNCTOR<Scalar> >, const Derived> \
|
||||||
(derived(), std::bind2nd(FUNCTOR<Scalar>(), s)); \
|
(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)
|
EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(operator==, std::equal_to)
|
||||||
|
@ -110,11 +110,17 @@ template<typename ArrayType> void comparisons(const ArrayType& m)
|
|||||||
VERIFY(! (m1 > m3).all() );
|
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)-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) ).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
|
// test Select
|
||||||
VERIFY_IS_APPROX( (m1<m2).select(m1,m2), m1.cwiseMin(m2) );
|
VERIFY_IS_APPROX( (m1<m2).select(m1,m2), m1.cwiseMin(m2) );
|
||||||
|
Loading…
Reference in New Issue
Block a user