aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2013-07-15 21:21:14 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2013-07-15 21:21:14 +0200
commitd02e329218d504930f91f05c3c040e19f19c57c2 (patch)
treee9af8c858c10f04c49939d7f82f06ddc42092cf8
parentc76990664bcc8647eb321105067af9ced86d4959 (diff)
Fix adjoint unit test: test_isApproxWithRef works for positive quantities only.
-rw-r--r--test/adjoint.cpp3
-rw-r--r--test/main.h1
2 files changed, 3 insertions, 1 deletions
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<false> {
template<typename Vec, typename Mat, typename Scalar>
static void run(const Vec& v1, const Vec& v2, Vec& v3, const Mat& square, Scalar s1, Scalar s2) {
typedef typename NumTraits<Scalar>::Real RealScalar;
+ using std::abs;
RealScalar ref = NumTraits<Scalar>::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<false> {
// check compatibility of dot and adjoint
ref = NumTraits<Scalar>::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<Scalar>()));
// check that Random().normalized() works: tricky as the random xpr must be evaluated by
// normalized() in order to produce a consistent result.
diff --git a/test/main.h b/test/main.h
index 0f55fef71..14f0d2f78 100644
--- a/test/main.h
+++ b/test/main.h
@@ -270,6 +270,7 @@ inline bool test_isApprox(const Type1& a, const Type2& b)
// 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.
+// WARNING: the scalar a and b must be positive
// 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