]> https://gitweb.dealii.org/ - dealii.git/commitdiff
AffineConstraints::close(): Replace division by multiplication with reciprocal 16134/head
authorMartin Kronbichler <martin.kronbichler@uni-a.de>
Fri, 13 Oct 2023 18:15:20 +0000 (20:15 +0200)
committerMartin Kronbichler <martin.kronbichler@uni-a.de>
Fri, 13 Oct 2023 18:15:20 +0000 (20:15 +0200)
include/deal.II/lac/affine_constraints.templates.h

index eb2029bd430af55bfaec5853f0d28ef038d64540..75bf4a95064184a2595d5fdfe28634df41a1a857 100644 (file)
@@ -1030,11 +1030,13 @@ AffineConstraints<number>::close()
           number sum = 0.;
           for (const std::pair<size_type, number> &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<size_type, number> &entry : line.entries)
-                entry.second /= sum;
-              line.inhomogeneity /= sum;
+                entry.second *= inverse_sum;
+              line.inhomogeneity *= inverse_sum;
             }
         }
     },

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.