bug #426: move operator && and || to MatrixBase and SparseMatrixBase.
diff --git a/test/array_for_matrix.cpp b/test/array_for_matrix.cpp
index 97e03be..c150194 100644
--- a/test/array_for_matrix.cpp
+++ b/test/array_for_matrix.cpp
@@ -134,6 +134,12 @@
// count
VERIFY(((m1.array().abs()+1)>RealScalar(0.1)).count() == rows*cols);
+ // and/or
+ VERIFY( ((m1.array()<RealScalar(0)).matrix() && (m1.array()>RealScalar(0)).matrix()).count() == 0);
+ VERIFY( ((m1.array()<RealScalar(0)).matrix() || (m1.array()>=RealScalar(0)).matrix()).count() == rows*cols);
+ RealScalar a = m1.cwiseAbs().mean();
+ VERIFY( ((m1.array()<-a).matrix() || (m1.array()>a).matrix()).count() == (m1.cwiseAbs().array()>a).count());
+
typedef Matrix<typename MatrixType::Index, Dynamic, 1> VectorOfIndices;
// TODO allows colwise/rowwise for array
diff --git a/test/sparse_basic.cpp b/test/sparse_basic.cpp
index 552bbac..2a3117b 100644
--- a/test/sparse_basic.cpp
+++ b/test/sparse_basic.cpp
@@ -217,6 +217,21 @@
refM1(it.row(), it.col()) += s1;
VERIFY_IS_APPROX(m1, refM1);
}
+
+ // and/or
+ {
+ typedef SparseMatrix<bool, SparseMatrixType::Options, typename SparseMatrixType::StorageIndex> SpBool;
+ SpBool mb1 = m1.real().template cast<bool>();
+ SpBool mb2 = m2.real().template cast<bool>();
+ VERIFY_IS_EQUAL(mb1.template cast<int>().sum(), refM1.real().template cast<bool>().count());
+ VERIFY_IS_EQUAL((mb1 && mb2).template cast<int>().sum(), (refM1.real().template cast<bool>() && refM2.real().template cast<bool>()).count());
+ VERIFY_IS_EQUAL((mb1 || mb2).template cast<int>().sum(), (refM1.real().template cast<bool>() || refM2.real().template cast<bool>()).count());
+ SpBool mb3 = mb1 && mb2;
+ if(mb1.coeffs().all() && mb2.coeffs().all())
+ {
+ VERIFY_IS_EQUAL(mb3.nonZeros(), (refM1.real().template cast<bool>() && refM2.real().template cast<bool>()).count());
+ }
+ }
}
// test reverse iterators