aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/main.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2011-02-18 17:39:04 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2011-02-18 17:39:04 +0100
commit86ca05b324f3f27249eb74b5ec839e2c331c8bbb (patch)
tree6bc852a2e421e7a6cd0037f1a5b57c5321775687 /test/main.h
parent8f8c67b8bd2915d1927c848e557e5076a00e25f9 (diff)
remove largeEps in adjoint unit test and use a more accurate test_isApproxWithRef test.
Diffstat (limited to 'test/main.h')
-rw-r--r--test/main.h12
1 files changed, 12 insertions, 0 deletions
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<typename Type1::Scalar>());
}
+// 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<typename Scalar,typename ScalarRef>
+inline bool test_isApproxWithRef(const Scalar& a, const Scalar& b, const ScalarRef& ref)
+{
+ return test_isApprox(a+ref, b+ref);
+}
+
template<typename Derived1, typename Derived2>
inline bool test_isMuchSmallerThan(const MatrixBase<Derived1>& m1,
const MatrixBase<Derived2>& m2)