From: Martin Kronbichler Date: Fri, 13 Oct 2023 18:15:20 +0000 (+0200) Subject: AffineConstraints::close(): Replace division by multiplication with reciprocal X-Git-Tag: relicensing~401^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc5ae2d14fe43587b9bc5245d2959e9bfe35dc7e;p=dealii.git AffineConstraints::close(): Replace division by multiplication with reciprocal --- diff --git a/include/deal.II/lac/affine_constraints.templates.h b/include/deal.II/lac/affine_constraints.templates.h index eb2029bd43..75bf4a9506 100644 --- a/include/deal.II/lac/affine_constraints.templates.h +++ b/include/deal.II/lac/affine_constraints.templates.h @@ -1030,11 +1030,13 @@ AffineConstraints::close() number sum = 0.; for (const std::pair &entry : line.entries) sum += entry.second; - if (std::abs(sum - number(1.)) < 1.e-13) + if (std::abs(sum - number(1.)) < 1.e-13 && + std::abs(sum - number(1.)) > 0.) { + const number inverse_sum = number(1.) / sum; for (std::pair &entry : line.entries) - entry.second /= sum; - line.inhomogeneity /= sum; + entry.second *= inverse_sum; + line.inhomogeneity *= inverse_sum; } } },