aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/adjoint.cpp
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 /test/adjoint.cpp
parentc76990664bcc8647eb321105067af9ced86d4959 (diff)
Fix adjoint unit test: test_isApproxWithRef works for positive quantities only.
Diffstat (limited to 'test/adjoint.cpp')
-rw-r--r--test/adjoint.cpp3
1 files changed, 2 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.