From: Martin Kronbichler Date: Sun, 5 Nov 2017 17:31:12 +0000 (+0100) Subject: Add option to set small numbers to zero. X-Git-Tag: v9.0.0-rc1~817^2~9 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=414ceac00671c9259951c2df9b752e005513e88b;p=dealii.git Add option to set small numbers to zero. --- 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 -------------------