aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/sparse_basic.cpp
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2016-11-14 18:47:02 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2016-11-14 18:47:02 +0100
commit2e334f5da0c37eea3bd91f0e80adb5f509d2416b (patch)
tree9ac6ff63601880397ca349286029aea640f1bb23 /test/sparse_basic.cpp
parenta048aba14c69c286cc04ce3dc8acea8f3801a682 (diff)
bug #426: move operator && and || to MatrixBase and SparseMatrixBase.
Diffstat (limited to 'test/sparse_basic.cpp')
-rw-r--r--test/sparse_basic.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/sparse_basic.cpp b/test/sparse_basic.cpp
index 552bbac4d..2a3117b2b 100644
--- a/test/sparse_basic.cpp
+++ b/test/sparse_basic.cpp
@@ -217,6 +217,21 @@ template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& re
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