From d02e329218d504930f91f05c3c040e19f19c57c2 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 15 Jul 2013 21:21:14 +0200 Subject: Fix adjoint unit test: test_isApproxWithRef works for positive quantities only. --- test/adjoint.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/adjoint.cpp') diff --git a/test/adjoint.cpp b/test/adjoint.cpp index b63e843c6..ea36f7841 100644 --- a/test/adjoint.cpp +++ b/test/adjoint.cpp @@ -28,6 +28,7 @@ template<> struct adjoint_specific { template static void run(const Vec& v1, const Vec& v2, Vec& v3, const Mat& square, Scalar s1, Scalar s2) { typedef typename NumTraits::Real RealScalar; + using std::abs; RealScalar ref = NumTraits::IsInteger ? RealScalar(0) : (std::max)((s1 * v1 + s2 * v2).norm(),v3.norm()); VERIFY(test_isApproxWithRef((s1 * v1 + s2 * v2).dot(v3), numext::conj(s1) * v1.dot(v3) + numext::conj(s2) * v2.dot(v3), ref)); @@ -44,7 +45,7 @@ template<> struct adjoint_specific { // check compatibility of dot and adjoint 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)); + VERIFY(internal::isMuchSmallerThan(abs(v1.dot(square * v2) - (square.adjoint() * v1).dot(v2)), ref, test_precision())); // check that Random().normalized() works: tricky as the random xpr must be evaluated by // normalized() in order to produce a consistent result. -- cgit v1.2.3