summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xWrappers/Python/ccpi/optimisation/functions/MixedL21Norm.py28
-rwxr-xr-xWrappers/Python/ccpi/optimisation/functions/ScaledFunction.py4
2 files changed, 23 insertions, 9 deletions
diff --git a/Wrappers/Python/ccpi/optimisation/functions/MixedL21Norm.py b/Wrappers/Python/ccpi/optimisation/functions/MixedL21Norm.py
index 4266e51..ed1d5e5 100755
--- a/Wrappers/Python/ccpi/optimisation/functions/MixedL21Norm.py
+++ b/Wrappers/Python/ccpi/optimisation/functions/MixedL21Norm.py
@@ -87,17 +87,29 @@ class MixedL21Norm(Function):
res = BlockDataContainer(*frac)
return res
-
-# tmp2 = np.sqrt(x.as_array()[0]**2 + x.as_array()[1]**2 + 2*x.as_array()[2]**2)/self.alpha
-# res = x.divide(ImageData(tmp2).maximum(1.0))
else:
+# pass
+
- tmp = [ el*el for el in x]
- res = (sum(tmp).sqrt()).maximum(1.0)
- frac = [x[i]/res for i in range(x.shape[0])]
- res = BlockDataContainer(*frac)
+# # tmp2 = np.sqrt(x.as_array()[0]**2 + x.as_array()[1]**2 + 2*x.as_array()[2]**2)/self.alpha
+# # res = x.divide(ImageData(tmp2).maximum(1.0))
+# if out is None:
+
+ tmp = [ el*el for el in x]
+ res = (sum(tmp).sqrt()).maximum(1.0)
+ frac = [x[i]/res for i in range(x.shape[0])]
+ res = BlockDataContainer(*frac)
- return res
+ return res
+ # else:
+ # tmp = [ el*el for el in x]
+ # res = (sum(tmp).sqrt()).maximum(1.0)
+ # #frac = [x[i]/res for i in range(x.shape[0])]
+ # for i in range(x.shape[0]):
+ # a = out.get_item(i)
+ # b = x.get_item(i)
+ # b /= res
+ # a.fill( b )
def __rmul__(self, scalar):
return ScaledFunction(self, scalar)
diff --git a/Wrappers/Python/ccpi/optimisation/functions/ScaledFunction.py b/Wrappers/Python/ccpi/optimisation/functions/ScaledFunction.py
index 046a4a6..9e2ba0c 100755
--- a/Wrappers/Python/ccpi/optimisation/functions/ScaledFunction.py
+++ b/Wrappers/Python/ccpi/optimisation/functions/ScaledFunction.py
@@ -61,7 +61,9 @@ class ScaledFunction(object):
if out is None:
return self.scalar * self.function.proximal_conjugate(x/self.scalar, tau/self.scalar)
else:
- out.fill(self.scalar * self.function.proximal_conjugate(x/self.scalar, tau/self.scalar))
+ out.fill(self.scalar*self.function.proximal_conjugate(x/self.scalar, tau/self.scalar))
+ #self.function.proximal_conjugate(x/self.scalar, tau/self.scalar, out=out)
+ #out *= self.scalar
def grad(self, x):
'''Alias of gradient(x,None)'''