From 86ca05b324f3f27249eb74b5ec839e2c331c8bbb Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Fri, 18 Feb 2011 17:39:04 +0100 Subject: remove largeEps in adjoint unit test and use a more accurate test_isApproxWithRef test. --- test/adjoint.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'test/adjoint.cpp') diff --git a/test/adjoint.cpp b/test/adjoint.cpp index bed409191..bc0bad4d0 100644 --- a/test/adjoint.cpp +++ b/test/adjoint.cpp @@ -40,10 +40,6 @@ template void adjoint(const MatrixType& m) Index rows = m.rows(); Index cols = m.cols(); - RealScalar largerEps = test_precision(); - if (internal::is_same::value) - largerEps = RealScalar(1e-3f); - MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols), m3(rows, cols), @@ -68,8 +64,10 @@ template void adjoint(const MatrixType& m) // check basic properties of dot, norm, norm2 typedef typename NumTraits::Real RealScalar; - VERIFY(internal::isApprox((s1 * v1 + s2 * v2).dot(v3), internal::conj(s1) * v1.dot(v3) + internal::conj(s2) * v2.dot(v3), largerEps)); - VERIFY(internal::isApprox(v3.dot(s1 * v1 + s2 * v2), s1*v3.dot(v1)+s2*v3.dot(v2), largerEps)); + + RealScalar ref = NumTraits::IsInteger ? 0 : std::max((s1 * v1 + s2 * v2).norm(),v3.norm()); + VERIFY(test_isApproxWithRef((s1 * v1 + s2 * v2).dot(v3), internal::conj(s1) * v1.dot(v3) + internal::conj(s2) * v2.dot(v3), ref)); + VERIFY(test_isApproxWithRef(v3.dot(s1 * v1 + s2 * v2), s1*v3.dot(v1)+s2*v3.dot(v2), ref)); VERIFY_IS_APPROX(internal::conj(v1.dot(v2)), v2.dot(v1)); VERIFY_IS_APPROX(internal::real(v1.dot(v1)), v1.squaredNorm()); if(!NumTraits::IsInteger) @@ -77,7 +75,9 @@ template void adjoint(const MatrixType& m) VERIFY_IS_MUCH_SMALLER_THAN(internal::abs(vzero.dot(v1)), static_cast(1)); // check compatibility of dot and adjoint - VERIFY(internal::isApprox(v1.dot(square * v2), (square.adjoint() * v1).dot(v2), largerEps)); + + ref = NumTraits::IsInteger ? 0 : std::max(std::max(v1.norm(),v2.norm()),std::max((square * v2).norm(),(square.adjoint() * v1).norm())); + VERIFY(test_isApproxWithRef(v1.dot(square * v2), (square.adjoint() * v1).dot(v2), ref)); // like in testBasicStuff, test operator() to check const-qualification Index r = internal::random(0, rows-1), @@ -119,9 +119,9 @@ void test_adjoint() CALL_SUBTEST_1( adjoint(Matrix()) ); CALL_SUBTEST_2( adjoint(Matrix3d()) ); CALL_SUBTEST_3( adjoint(Matrix4f()) ); - CALL_SUBTEST_4( adjoint(MatrixXcf(4, 4)) ); - CALL_SUBTEST_5( adjoint(MatrixXi(8, 12)) ); - CALL_SUBTEST_6( adjoint(MatrixXf(21, 21)) ); + CALL_SUBTEST_4( adjoint(MatrixXcf(internal::random(1,50), internal::random(1,50))) ); + CALL_SUBTEST_5( adjoint(MatrixXi(internal::random(1,50), internal::random(1,50))) ); + CALL_SUBTEST_6( adjoint(MatrixXf(internal::random(1,50), internal::random(1,50))) ); } // test a large matrix only once CALL_SUBTEST_7( adjoint(Matrix()) ); -- cgit v1.2.3