aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/vectorwiseop.cpp
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2013-08-11 19:21:43 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2013-08-11 19:21:43 +0200
commitbffdc491b304cb207ed63cc421f39e597f8a6a9d (patch)
tree80e3460d8458f194cb3fffc27b2fe28ad5b4cdef /test/vectorwiseop.cpp
parent6719e56b5bfe9ae4badc9a6e894c5824f663d62e (diff)
Fix cost evaluation of partial reduxions -> improve performance of vectorwise/replicate expressions involving partial reduxions
Diffstat (limited to 'test/vectorwiseop.cpp')
-rw-r--r--test/vectorwiseop.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/vectorwiseop.cpp b/test/vectorwiseop.cpp
index 9d60b0388..6cd1acdda 100644
--- a/test/vectorwiseop.cpp
+++ b/test/vectorwiseop.cpp
@@ -101,6 +101,16 @@ template<typename ArrayType> void vectorwiseop_array(const ArrayType& m)
VERIFY_RAISES_ASSERT(m2.rowwise() /= rowvec.transpose());
VERIFY_RAISES_ASSERT(m1.rowwise() / rowvec.transpose());
+
+ m2 = m1;
+ // yes, there might be an aliasing issue there but ".rowwise() /="
+ // is suppposed to evaluate " m2.colwise().sum()" into to temporary to avoid
+ // evaluating the reducions multiple times
+ if(ArrayType::RowsAtCompileTime>2 || ArrayType::RowsAtCompileTime==Dynamic)
+ {
+ m2.rowwise() /= m2.colwise().sum();
+ VERIFY_IS_APPROX(m2, m1.rowwise() / m1.colwise().sum());
+ }
}
template<typename MatrixType> void vectorwiseop_matrix(const MatrixType& m)