From 8f0e80fe304ad34b520a869ae58bbff8b64c63f2 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Thu, 14 Oct 2010 10:14:43 -0400 Subject: JacobiSVD: * fix preallocating constructors, allocate U and V of the right size for computation options * complete documentation and internal comments * improve unit test, test inf/nan values --- test/jacobisvd.cpp | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'test/jacobisvd.cpp') diff --git a/test/jacobisvd.cpp b/test/jacobisvd.cpp index a6dbcf2e8..7d8c36308 100644 --- a/test/jacobisvd.cpp +++ b/test/jacobisvd.cpp @@ -196,6 +196,23 @@ template void jacobisvd_verify_assert(const MatrixType& m) } } +template +void jacobisvd_inf_nan() +{ + JacobiSVD svd; + typedef typename MatrixType::Scalar Scalar; + Scalar some_inf = Scalar(1) / Scalar(0); + svd.compute(MatrixType::Constant(10,10,some_inf), ComputeFullU | ComputeFullV); + Scalar some_nan = Scalar(0) / Scalar(0); + svd.compute(MatrixType::Constant(10,10,some_nan), ComputeFullU | ComputeFullV); + MatrixType m = MatrixType::Zero(10,10); + m(ei_random(0,9), ei_random(0,9)) = some_inf; + svd.compute(m, ComputeFullU | ComputeFullV); + m = MatrixType::Zero(10,10); + m(ei_random(0,9), ei_random(0,9)) = some_nan; + svd.compute(m, ComputeFullU | ComputeFullV); +} + void test_jacobisvd() { CALL_SUBTEST_3(( jacobisvd_verify_assert(Matrix3f()) )); @@ -211,10 +228,15 @@ void test_jacobisvd() m << 1, 0, 1, 0; CALL_SUBTEST_1(( jacobisvd(m, false) )); + Matrix2d n; - n << 1, 1, - 1, -1; + n << 0, 0, + 0, 0; + CALL_SUBTEST_2(( jacobisvd(n, false) )); + n << 0, 0, + 0, 1; CALL_SUBTEST_2(( jacobisvd(n, false) )); + CALL_SUBTEST_3(( jacobisvd() )); CALL_SUBTEST_4(( jacobisvd() )); CALL_SUBTEST_5(( jacobisvd >() )); @@ -226,8 +248,14 @@ void test_jacobisvd() CALL_SUBTEST_8(( jacobisvd(MatrixXcd(r,c)) )); (void) r; (void) c; + + // Test on inf/nan matrix + CALL_SUBTEST_7( jacobisvd_inf_nan() ); } - CALL_SUBTEST_7(( jacobisvd(MatrixXf(ei_random(200, 300), ei_random(200, 300))) )); - CALL_SUBTEST_8(( jacobisvd(MatrixXcd(ei_random(100, 120), ei_random(100, 120))) )); + CALL_SUBTEST_7(( jacobisvd(MatrixXf(ei_random(100, 150), ei_random(100, 150))) )); + CALL_SUBTEST_8(( jacobisvd(MatrixXcd(ei_random(80, 100), ei_random(80, 100))) )); + + // Test problem size constructors + CALL_SUBTEST_7( JacobiSVD(10,10) ); } -- cgit v1.2.3