summaryrefslogtreecommitdiffstats
path: root/Wrappers/Python
diff options
context:
space:
mode:
authorEdoardo Pasca <edo.paskino@gmail.com>2019-01-08 17:06:55 +0000
committerGitHub <noreply@github.com>2019-01-08 17:06:55 +0000
commitc324276a3fc2b0fec6c938691fb61c4b42442751 (patch)
tree2507fe0a5162989e4e79197648173facb7954307 /Wrappers/Python
parent11744367fa0a36be738226f14898ac5e8816491e (diff)
downloadframework-c324276a3fc2b0fec6c938691fb61c4b42442751.tar.gz
framework-c324276a3fc2b0fec6c938691fb61c4b42442751.tar.bz2
framework-c324276a3fc2b0fec6c938691fb61c4b42442751.tar.xz
framework-c324276a3fc2b0fec6c938691fb61c4b42442751.zip
Norm2sq does not fail if cannot calculate Lipschitz constant
Diffstat (limited to 'Wrappers/Python')
-rwxr-xr-xWrappers/Python/ccpi/optimisation/funcs.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/Wrappers/Python/ccpi/optimisation/funcs.py b/Wrappers/Python/ccpi/optimisation/funcs.py
index 2266560..c7a6143 100755
--- a/Wrappers/Python/ccpi/optimisation/funcs.py
+++ b/Wrappers/Python/ccpi/optimisation/funcs.py
@@ -136,6 +136,8 @@ class Norm2sq(Function):
'''
def __init__(self,A,b,c=1.0,memopt=False):
+ super(Norm2sq, self).__init__()
+
self.A = A # Should be an operator, default identity
self.b = b # Default zero DataSet?
self.c = c # Default 1.
@@ -146,11 +148,13 @@ class Norm2sq(Function):
self.adjoint_placehold = A.allocate_adjoint()
- # Compute the Lipschitz parameter from the operator.
- # Initialise to None instead and only call when needed.
- self.L = 2.0*self.c*(self.A.get_max_sing_val()**2)
- super(Norm2sq, self).__init__()
-
+ # Compute the Lipschitz parameter from the operator if possible
+ # Leave it initialised to None otherwise
+ try:
+ self.L = 2.0*self.c*(self.A.get_max_sing_val()**2)
+ except AttributeError as ae:
+ pass
+
def grad(self,x):
#return 2*self.c*self.A.adjoint( self.A.direct(x) - self.b )
return (2.0*self.c)*self.A.adjoint( self.A.direct(x) - self.b )