From: Martin Kronbichler Date: Mon, 26 Sep 2022 09:37:33 +0000 (+0200) Subject: Pass scalars by value and fix a relative tolerance X-Git-Tag: v9.5.0-rc1~926^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=546f1f1f3d924ee496c22f929850aedb01318a4c;p=dealii.git Pass scalars by value and fix a relative tolerance --- diff --git a/include/deal.II/base/floating_point_comparator.h b/include/deal.II/base/floating_point_comparator.h index eef3f96b46..b4bb6967ea 100644 --- a/include/deal.II/base/floating_point_comparator.h +++ b/include/deal.II/base/floating_point_comparator.h @@ -116,7 +116,7 @@ struct FloatingPointComparator * Compare two scalar numbers. */ ComparisonResult - compare(const ScalarNumber &s1, const ScalarNumber &s2) const; + compare(const ScalarNumber s1, const ScalarNumber s2) const; /** * Compare two VectorizedArray instances. @@ -240,14 +240,15 @@ FloatingPointComparator::compare(const Table<2, T> &t1, template typename FloatingPointComparator::ComparisonResult -FloatingPointComparator::compare(const ScalarNumber &s1, - const ScalarNumber &s2) const +FloatingPointComparator::compare(const ScalarNumber s1, + const ScalarNumber s2) const { if (width == 1 || mask[0]) { - const ScalarNumber tolerance = use_absolute_tolerance ? - this->tolerance : - (std::abs(s1 + s2) * this->tolerance); + const ScalarNumber tolerance = + use_absolute_tolerance ? + this->tolerance : + ((std::abs(s1) + std::abs(s2)) * this->tolerance); if (s1 < s2 - tolerance) return ComparisonResult::less;