From 3460f3558e7b469efb8a225894e21929c8c77629 Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen Date: Wed, 1 Feb 2023 13:49:56 -0800 Subject: [PATCH] Use VERIFY_IS_EQUAL to compare to zeros. --- test/array_for_matrix.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/array_for_matrix.cpp b/test/array_for_matrix.cpp index 06e04a2fa..34d72154b 100644 --- a/test/array_for_matrix.cpp +++ b/test/array_for_matrix.cpp @@ -24,10 +24,10 @@ template void array_for_matrix(const MatrixType& m) ColVectorType cv1 = ColVectorType::Random(rows); RowVectorType rv1 = RowVectorType::Random(cols); - + Scalar s1 = internal::random(), s2 = internal::random(); - + // scalar addition VERIFY_IS_APPROX(m1.array() + s1, s1 + m1.array()); VERIFY_IS_APPROX((m1.array() + s1).matrix(), MatrixType::Constant(rows,cols,s1) + m1); @@ -55,18 +55,18 @@ template 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.template block<0,Dynamic>(0,0,0,cols).colwise().sum()), RowVectorType::Zero(cols)); - VERIFY_IS_APPROX((m1.template block(0,0,rows,0).rowwise().sum()), ColVectorType::Zero(rows)); - VERIFY_IS_APPROX((m1.template block<0,Dynamic>(0,0,0,cols).colwise().prod()), RowVectorType::Ones(cols)); - VERIFY_IS_APPROX((m1.template block(0,0,rows,0).rowwise().prod()), ColVectorType::Ones(rows)); - VERIFY_IS_APPROX(m1.block(0,0,0,cols).colwise().sum(), RowVectorType::Zero(cols)); - VERIFY_IS_APPROX(m1.block(0,0,rows,0).rowwise().sum(), ColVectorType::Zero(rows)); - VERIFY_IS_APPROX(m1.block(0,0,0,cols).colwise().prod(), RowVectorType::Ones(cols)); - VERIFY_IS_APPROX(m1.block(0,0,rows,0).rowwise().prod(), ColVectorType::Ones(rows)); - + // empty objects + VERIFY_IS_EQUAL((m1.template block<0,Dynamic>(0,0,0,cols).colwise().sum()), RowVectorType::Zero(cols)); + VERIFY_IS_EQUAL((m1.template block(0,0,rows,0).rowwise().sum()), ColVectorType::Zero(rows)); + VERIFY_IS_EQUAL((m1.template block<0,Dynamic>(0,0,0,cols).colwise().prod()), RowVectorType::Ones(cols)); + VERIFY_IS_EQUAL((m1.template block(0,0,rows,0).rowwise().prod()), ColVectorType::Ones(rows)); + + VERIFY_IS_EQUAL(m1.block(0,0,0,cols).colwise().sum(), RowVectorType::Zero(cols)); + VERIFY_IS_EQUAL(m1.block(0,0,rows,0).rowwise().sum(), ColVectorType::Zero(rows)); + VERIFY_IS_EQUAL(m1.block(0,0,0,cols).colwise().prod(), RowVectorType::Ones(cols)); + VERIFY_IS_EQUAL(m1.block(0,0,rows,0).rowwise().prod(), ColVectorType::Ones(rows)); + // verify the const accessors exist const Scalar& ref_m1 = m.matrix().array().coeffRef(0); const Scalar& ref_m2 = m.matrix().array().coeffRef(0,0);