diff --git a/odl/operator/operator.py b/odl/operator/operator.py index 3c0e01fa00d..f6bc6a3edbb 100644 --- a/odl/operator/operator.py +++ b/odl/operator/operator.py @@ -1154,8 +1154,10 @@ def _call(self, x, out=None): else: tmp = (self.__tmp_ran if self.__tmp_ran is not None else self.range.element()) - self.left(x, out=out) - self.right(x, out=tmp) + # Write to `tmp` first, otherwise aliased `x` and `out` lead + # to wrong result + self.left(x, out=tmp) + self.right(x, out=out) out += tmp def derivative(self, x): @@ -1492,8 +1494,10 @@ def _call(self, x, out=None): return self.left(x) * self.right(x) else: tmp = self.right.range.element() - self.left(x, out=out) - self.right(x, out=tmp) + # Write to `tmp` first, otherwise aliased `x` and `out` lead + # to wrong result + self.left(x, out=tmp) + self.right(x, out=out) out *= tmp def derivative(self, x):