From 546f1f1f3d924ee496c22f929850aedb01318a4c Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Mon, 26 Sep 2022 11:37:33 +0200 Subject: [PATCH] Pass scalars by value and fix a relative tolerance --- include/deal.II/base/floating_point_comparator.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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; -- 2.39.5