Commit 729b67fc authored by Philipp Arras's avatar Philipp Arras
Browse files

Performance tweak

parent eef0b9c9
......@@ -75,9 +75,9 @@ class ModelGradientOperator(LinearOperator):
for dd in self.domain:
if dd in grad_keys:
res[dd] = self._gradients[dd].adjoint_times(x)
res[dd] = full(self.domain[dd], 0.)
# else:
# res[dd] = full(self.domain[dd], 0.)
res = MultiField(res)
if not res.domain == self.domain:
raise TypeError
# if not res.domain == self.domain:
# raise TypeError
return res
......@@ -41,9 +41,10 @@ class SelectionOperator(LinearOperator):
return self.TIMES | self.ADJOINT_TIMES
def apply(self, x, mode):
# FIXME Is the copying necessary?
self._check_input(x, mode)
if mode == self.TIMES:
return x[self._key].copy()
from ..multi import MultiField
return MultiField({self._key: x})
return MultiField({self._key: x.copy()})
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment