diff options
author | Gael Guennebaud <g.gael@free.fr> | 2010-07-16 14:02:20 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2010-07-16 14:02:20 +0200 |
commit | 044424b0e2d27a33c985803ed3e736e9af28993d (patch) | |
tree | 9105774e3f3f834b66a056e4a77ee321d27b207b /test/redux.cpp | |
parent | 6a370f50c72a320a4a5a2740e881b61601d2a917 (diff) |
fix sum()/prod() on empty matrix making sure this does not affect fixed sized object, extend related unit tests including partial reduction
Diffstat (limited to 'test/redux.cpp')
-rw-r--r-- | test/redux.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/redux.cpp b/test/redux.cpp index b28252903..9a1df71a8 100644 --- a/test/redux.cpp +++ b/test/redux.cpp @@ -64,6 +64,10 @@ template<typename MatrixType> void matrixRedux(const MatrixType& m) VERIFY_IS_APPROX(m1.block(r0,c0,r1,c1).prod(), m1.block(r0,c0,r1,c1).eval().prod()); VERIFY_IS_APPROX(m1.block(r0,c0,r1,c1).real().minCoeff(), m1.block(r0,c0,r1,c1).real().eval().minCoeff()); VERIFY_IS_APPROX(m1.block(r0,c0,r1,c1).real().maxCoeff(), m1.block(r0,c0,r1,c1).real().eval().maxCoeff()); + + // test empty objects + VERIFY_IS_APPROX(m1.block(r0,c0,0,0).sum(), Scalar(0)); + VERIFY_IS_APPROX(m1.block(r0,c0,0,0).prod(), Scalar(1)); } template<typename VectorType> void vectorRedux(const VectorType& w) @@ -124,6 +128,13 @@ template<typename VectorType> void vectorRedux(const VectorType& w) VERIFY_IS_APPROX(minc, v.real().segment(i, size-2*i).minCoeff()); VERIFY_IS_APPROX(maxc, v.real().segment(i, size-2*i).maxCoeff()); } + + // test empty objects + VERIFY_IS_APPROX(v.head(0).sum(), Scalar(0)); + VERIFY_IS_APPROX(v.tail(0).prod(), Scalar(1)); + VERIFY_RAISES_ASSERT(v.head(0).mean()); + VERIFY_RAISES_ASSERT(v.head(0).minCoeff()); + VERIFY_RAISES_ASSERT(v.head(0).maxCoeff()); } void test_redux() |