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/main.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/main.h') diff --git a/test/main.h b/test/main.h index 671555aa3..51eca5453 100644 --- a/test/main.h +++ b/test/main.h @@ -346,6 +346,18 @@ inline bool test_isApprox(const Type1& a, const Type2& b) return a.isApprox(b, test_precision()); } +// The idea behind this function is to compare the two scalars a and b where +// the scalar ref is a hint about the expected order of magnitude of a and b. +// Therefore, if for some reason a and b are very small compared to ref, +// we won't issue a false negative. +// This test could be: abs(a-b) <= eps * ref +// However, it seems that simply comparing a+ref and b+ref is more sensitive to true error. +template +inline bool test_isApproxWithRef(const Scalar& a, const Scalar& b, const ScalarRef& ref) +{ + return test_isApprox(a+ref, b+ref); +} + template inline bool test_isMuchSmallerThan(const MatrixBase& m1, const MatrixBase& m2) -- cgit v1.2.3