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:
Christoph Hertzberg 2013-10-17 15:37:29 +02:00
parent 3d2a3bc755
commit 36052c4911
2 changed files with 15 additions and 4 deletions

View File

@ -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)

View File

@ -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) );