Skip to content

Commit

Permalink
closes #944 (#947)
Browse files Browse the repository at this point in the history
closes #944
  • Loading branch information
paskino committed Aug 12, 2021
1 parent 8a40028 commit 63cb57c
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions Wrappers/Python/cil/optimisation/operators/Operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def __init__(self, operator, scalar, **kwargs):
:param operator: a Operator or LinearOperator
:param scalar: a scalar multiplier
:type scalar: float'''
:type scalar: Number'''

super(ScaledOperator, self).__init__(domain_geometry=operator.domain_geometry(),
range_geometry=operator.range_geometry())
Expand All @@ -256,15 +256,19 @@ def __init__(self, operator, scalar, **kwargs):
def direct(self, x, out=None):
'''direct method'''
if out is None:
return self.scalar * self.operator.direct(x, out=out)
tmp = self.operator.direct(x)
tmp *= self.scalar
return tmp
else:
self.operator.direct(x, out=out)
out *= self.scalar
def adjoint(self, x, out=None):
'''adjoint method'''
if self.operator.is_linear():
if out is None:
return self.scalar * self.operator.adjoint(x, out=out)
tmp = self.operator.adjoint(x)
tmp *= self.scalar
return tmp
else:
self.operator.adjoint(x, out=out)
out *= self.scalar
Expand All @@ -273,12 +277,7 @@ def adjoint(self, x, out=None):
def norm(self, **kwargs):
'''norm of the operator'''
return numpy.abs(self.scalar) * self.operator.norm(**kwargs)
# def range_geometry(self):
# '''range of the operator'''
# return self.operator.range_geometry()
# def domain_geometry(self):
# '''domain of the operator'''
# return self.operator.domain_geometry()

def is_linear(self):
'''returns whether the operator is linear
Expand Down

0 comments on commit 63cb57c

Please sign in to comment.