]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Bugfix: Also allow to multiply a PackagedOperation with 0 882/head
authorMatthias Maier <tamiko@43-1.org>
Mon, 11 May 2015 21:45:12 +0000 (23:45 +0200)
committerMatthias Maier <tamiko@43-1.org>
Mon, 11 May 2015 21:45:12 +0000 (23:45 +0200)
include/deal.II/lac/linear_operator.h

index a6580ef7357fa2edbbab0c41eb4c0277e5ce8a25..f50e634834a3f7e88714b4cc4e8c4990fd785789 100644 (file)
@@ -1639,18 +1639,33 @@ operator*(const PackagedOperation<Range> &comp,
 
   return_comp.reinit_vector = comp.reinit_vector;
 
-  return_comp.apply = [comp, number](Range &v)
-  {
-    comp.apply(v);
-    v *= number;
-  };
+  // the trivial case: number is zero
+  if (number == 0.)
+    {
+      return_comp.apply = [](Range &v)
+      {
+        v = 0.;
+      };
 
-  return_comp.apply_add = [comp, number](Range &v)
-  {
-    v /= number;
-    comp.apply_add(v);
-    v *= number;
-  };
+      return_comp.apply_add = [](Range &)
+      {
+      };
+    }
+  else
+    {
+      return_comp.apply = [comp, number](Range &v)
+      {
+        comp.apply(v);
+        v *= number;
+      };
+
+      return_comp.apply_add = [comp, number](Range &v)
+      {
+        v /= number;
+        comp.apply_add(v);
+        v *= number;
+      };
+    }
 
   return return_comp;
 }

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.