From 6dee5440e4971781077769913586e9748b1d6dbf Mon Sep 17 00:00:00 2001 From: Hauke Heibel Date: Fri, 29 Jan 2010 12:12:02 +0100 Subject: Adapted mean to work with complex numbers. Added regression test. --- test/redux.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/redux.cpp') diff --git a/test/redux.cpp b/test/redux.cpp index 3293fd54e..f95e8b29c 100644 --- a/test/redux.cpp +++ b/test/redux.cpp @@ -44,7 +44,11 @@ template void matrixRedux(const MatrixType& m) minc = std::min(ei_real(minc), ei_real(m1(i,j))); maxc = std::max(ei_real(maxc), ei_real(m1(i,j))); } + const Scalar mean = s/Scalar(rows*cols); + const Scalar other_mean = m1.mean(); + VERIFY_IS_APPROX(m1.sum(), s); + VERIFY_IS_APPROX(m1.mean(), mean); VERIFY_IS_APPROX(m1.prod(), p); VERIFY_IS_APPROX(m1.real().minCoeff(), ei_real(minc)); VERIFY_IS_APPROX(m1.real().maxCoeff(), ei_real(maxc)); @@ -113,15 +117,24 @@ void test_redux() { for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1( matrixRedux(Matrix()) ); + CALL_SUBTEST_1( matrixRedux(Array()) ); CALL_SUBTEST_2( matrixRedux(Matrix2f()) ); + CALL_SUBTEST_2( matrixRedux(Array2f()) ); CALL_SUBTEST_3( matrixRedux(Matrix4d()) ); + CALL_SUBTEST_3( matrixRedux(Array4d()) ); CALL_SUBTEST_4( matrixRedux(MatrixXcf(3, 3)) ); + CALL_SUBTEST_4( matrixRedux(ArrayXXcf(3, 3)) ); CALL_SUBTEST_5( matrixRedux(MatrixXd(8, 12)) ); + CALL_SUBTEST_5( matrixRedux(ArrayXXd(8, 12)) ); CALL_SUBTEST_6( matrixRedux(MatrixXi(8, 12)) ); + CALL_SUBTEST_6( matrixRedux(ArrayXXi(8, 12)) ); } for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_7( vectorRedux(Vector4f()) ); + CALL_SUBTEST_7( vectorRedux(Array4f()) ); CALL_SUBTEST_5( vectorRedux(VectorXd(10)) ); + CALL_SUBTEST_5( vectorRedux(ArrayXd(10)) ); CALL_SUBTEST_8( vectorRedux(VectorXf(33)) ); + CALL_SUBTEST_8( vectorRedux(ArrayXf(33)) ); } } -- cgit v1.2.3