From 7468e2ba9db068ef7a11b11d12ac66752ea96713 Mon Sep 17 00:00:00 2001 From: Cedric Nugteren Date: Sun, 6 Mar 2016 16:32:38 +0100 Subject: [PATCH] Adjusted the correctness-test error margins --- test/correctness/tester.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/correctness/tester.cc b/test/correctness/tester.cc index d9836500..8169f700 100644 --- a/test/correctness/tester.cc +++ b/test/correctness/tester.cc @@ -280,21 +280,21 @@ bool TestSimilarity(const T val1, const T val2) { const auto difference = std::fabs(val1 - val2); // Set the allowed error margin for floating-point comparisons - constexpr auto kErrorMarginRelative = 1.0e-2; - constexpr auto kErrorMarginAbsolute = 1.0e-10; + constexpr auto kErrorMarginRelative = T{0.025}; + constexpr auto kErrorMarginAbsolute = T{1.0e-6}; // Shortcut, handles infinities if (val1 == val2) { return true; } // The values are zero or very small: the relative error is less meaningful - else if (val1 == 0 || val2 == 0 || difference < static_cast(kErrorMarginAbsolute)) { - return (difference < static_cast(kErrorMarginAbsolute)); + else if (val1 == 0 || val2 == 0 || difference < kErrorMarginAbsolute) { + return (difference < kErrorMarginAbsolute); } // Use relative error else { const auto absolute_sum = std::fabs(val1) + std::fabs(val2); - return (difference / absolute_sum) < static_cast(kErrorMarginRelative); + return (difference / absolute_sum) < kErrorMarginRelative; } }