From: Matthias Maier Date: Mon, 11 May 2015 21:45:12 +0000 (+0200) Subject: Bugfix: Also allow to multiply a PackagedOperation with 0 X-Git-Tag: v8.3.0-rc1~179^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=957fb3e3800d2300bf76c2930f0f7630a52be2c5;p=dealii.git Bugfix: Also allow to multiply a PackagedOperation with 0 --- diff --git a/include/deal.II/lac/linear_operator.h b/include/deal.II/lac/linear_operator.h index a6580ef735..f50e634834 100644 --- a/include/deal.II/lac/linear_operator.h +++ b/include/deal.II/lac/linear_operator.h @@ -1639,18 +1639,33 @@ operator*(const PackagedOperation &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; }