From 414ceac00671c9259951c2df9b752e005513e88b Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Sun, 5 Nov 2017 18:31:12 +0100 Subject: [PATCH] Add option to set small numbers to zero. --- tests/tests.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/tests.h b/tests/tests.h index 82fefde5c6..42eb4a332b 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -259,6 +259,20 @@ std::string unify_pretty_function (const std::string &text) } \ } +/* + * Allow a test program to define a number that is very small to a given + * tolerance to be output as zero. This is used e.g. for the output of float + * numbers where roundoff difference can make the error larger than what we + * have set for numdiff (that is appropriate for double variables). + */ +template +Number filter_out_small_numbers (const Number number, const double tolerance) +{ + if (std::abs(number) < tolerance) + return Number(); + else + return number; +} // ------------------------------ Functions used in initializing subsystems ------------------- -- 2.39.5