fix sum()/prod() on empty matrix making sure this does not affect fixed sized object, extend related unit tests including partial reduction

This commit is contained in:
Gael Guennebaud
2010-07-16 14:02:20 +02:00
parent 6a370f50c7
commit 044424b0e2
3 changed files with 23 additions and 1 deletions

View File

@@ -72,6 +72,10 @@ template<typename MatrixType> void array_for_matrix(const MatrixType& m)
VERIFY_IS_APPROX(m3.rowwise() += rv1, m1.rowwise() + rv1);
m3 = m1;
VERIFY_IS_APPROX(m3.rowwise() -= rv1, m1.rowwise() - rv1);
// empty objects
VERIFY_IS_APPROX(m1.block(0,0,0,cols).colwise().sum(), RowVectorType::Zero(cols));
VERIFY_IS_APPROX(m1.block(0,0,rows,0).rowwise().prod(), ColVectorType::Ones(rows));
}
template<typename MatrixType> void comparisons(const MatrixType& m)