From 6cbf662f14d8fd0606d9e9c6f7052e5dcc52b2ae Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Thu, 19 Nov 2009 22:01:13 -0500 Subject: [PATCH] * don't laugh, but these bugs took me forever to fix. * expand unit tests to make sure to catch them: they nearly escaped the existing tests as these memory violations were highly dependent on the numbers of rows and cols. --- Eigen/src/Core/TriangularMatrix.h | 6 +++--- test/triangular.cpp | 27 ++++++++++++--------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Eigen/src/Core/TriangularMatrix.h b/Eigen/src/Core/TriangularMatrix.h index 1286bf6a6..1a8f6493d 100644 --- a/Eigen/src/Core/TriangularMatrix.h +++ b/Eigen/src/Core/TriangularMatrix.h @@ -410,7 +410,7 @@ struct ei_triangular_assignment_selector @@ -451,9 +451,9 @@ struct ei_triangular_assignment_selector void triangular_rect(const MatrixType& m) m3 = 3 * m2; VERIFY_IS_APPROX(m3.template triangularView().toDenseMatrix(), m1); + m1.setZero(); m1.template triangularView() = 3 * m2; VERIFY_IS_APPROX(m3.template triangularView().toDenseMatrix(), m1); @@ -196,10 +197,10 @@ template void triangular_rect(const MatrixType& m) m1.template triangularView() = 3 * m2; VERIFY_IS_APPROX(m3.template triangularView().toDenseMatrix(), m1); + m1.setZero(); m1.template triangularView() = 3 * m2; VERIFY_IS_APPROX(m3.template triangularView().toDenseMatrix(), m1); - m1.setRandom(); m2 = m1.template triangularView(); VERIFY(m2.isUpperTriangular()); @@ -234,24 +235,20 @@ void test_triangular() { for(int i = 0; i < g_repeat ; i++) { - -#ifdef EIGEN_TEST_PART_7 - int r = ei_random(2,20); - int c = ei_random(2,20); -#endif + EIGEN_UNUSED int r = ei_random(2,20); + EIGEN_UNUSED int c = ei_random(2,20); CALL_SUBTEST_1( triangular_square(Matrix()) ); CALL_SUBTEST_2( triangular_square(Matrix()) ); CALL_SUBTEST_3( triangular_square(Matrix3d()) ); - CALL_SUBTEST_4( triangular_square(MatrixXcf(4, 4)) ); - CALL_SUBTEST_5( triangular_square(Matrix,8, 8>()) ); - CALL_SUBTEST_6( triangular_square(MatrixXcd(17,17)) ); - CALL_SUBTEST_7( triangular_square(Matrix(r, r)) ); + CALL_SUBTEST_4( triangular_square(Matrix,8, 8>()) ); + CALL_SUBTEST_5( triangular_square(MatrixXcd(r,r)) ); + CALL_SUBTEST_6( triangular_square(Matrix(r, r)) ); - CALL_SUBTEST_8( triangular_rect(Matrix()) ); - CALL_SUBTEST_9( triangular_rect(Matrix()) ); - CALL_SUBTEST_4( triangular_rect(MatrixXcf(4, 10)) ); - CALL_SUBTEST_6( triangular_rect(MatrixXcd(11, 3)) ); - CALL_SUBTEST_7( triangular_rect(Matrix(r, c)) ); + CALL_SUBTEST_7( triangular_rect(Matrix()) ); + CALL_SUBTEST_8( triangular_rect(Matrix()) ); + CALL_SUBTEST_9( triangular_rect(MatrixXcf(r, c)) ); + CALL_SUBTEST_5( triangular_rect(MatrixXcd(r, c)) ); + CALL_SUBTEST_6( triangular_rect(Matrix(r, c)) ); } }