From c803a3ec1ac39adc71ccca44ded03774b94c957c Mon Sep 17 00:00:00 2001
From: Martin Reinecke <martin@mpa-garching.mpg.de>
Date: Tue, 6 Feb 2018 20:41:36 +0100
Subject: [PATCH] efficiency tweaks

---
 nifty4/operators/chain_operator.py   | 8 ++++++++
 nifty4/operators/scaling_operator.py | 3 +--
 nifty4/operators/sum_operator.py     | 4 ++++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/nifty4/operators/chain_operator.py b/nifty4/operators/chain_operator.py
index c9f054bab..89cf44142 100644
--- a/nifty4/operators/chain_operator.py
+++ b/nifty4/operators/chain_operator.py
@@ -99,6 +99,14 @@ class ChainOperator(LinearOperator):
     def target(self):
         return self._ops[0].target
 
+    @property
+    def inverse(self):
+        return self.make([op.inverse for op in reversed(self._ops)])
+
+    @property
+    def adjoint(self):
+        return self.make([op.adjoint for op in reversed(self._ops)])
+
     @property
     def capability(self):
         return self._capability
diff --git a/nifty4/operators/scaling_operator.py b/nifty4/operators/scaling_operator.py
index 31819c600..8c870a43d 100644
--- a/nifty4/operators/scaling_operator.py
+++ b/nifty4/operators/scaling_operator.py
@@ -81,8 +81,7 @@ class ScalingOperator(EndomorphicOperator):
     def capability(self):
         if self._factor == 0.:
             return self.TIMES | self.ADJOINT_TIMES
-        return (self.TIMES | self.ADJOINT_TIMES |
-                self.INVERSE_TIMES | self.ADJOINT_INVERSE_TIMES)
+        return self._all_ops
 
     def draw_sample(self):
         return Field.from_random(random_type="normal",
diff --git a/nifty4/operators/sum_operator.py b/nifty4/operators/sum_operator.py
index 7a9f71b29..ab2cdbf78 100644
--- a/nifty4/operators/sum_operator.py
+++ b/nifty4/operators/sum_operator.py
@@ -122,6 +122,10 @@ class SumOperator(LinearOperator):
     def target(self):
         return self._ops[0].target
 
+    @property
+    def adjoint(self):
+        return self.make([op.adjoint for op in self._ops], self._neg)
+
     @property
     def capability(self):
         return self._capability
-- 
GitLab