diff options
author | Edoardo Pasca <edo.paskino@gmail.com> | 2019-03-14 11:37:06 +0000 |
---|---|---|
committer | Edoardo Pasca <edo.paskino@gmail.com> | 2019-03-14 11:37:51 +0000 |
commit | 2dabf103a7d56de9afcf252dab881b097a9cd259 (patch) | |
tree | af22dd38ae809cc5edb9e8c7a18c308c1b539a50 | |
parent | 5338f1c6936584c867107a6512f204b2b3778afc (diff) | |
download | framework-2dabf103a7d56de9afcf252dab881b097a9cd259.tar.gz framework-2dabf103a7d56de9afcf252dab881b097a9cd259.tar.bz2 framework-2dabf103a7d56de9afcf252dab881b097a9cd259.tar.xz framework-2dabf103a7d56de9afcf252dab881b097a9cd259.zip |
added corrections to files which shoudl go?
-rw-r--r-- | Wrappers/Python/ccpi/optimisation/functions/FunctionComposition.py | 60 | ||||
-rw-r--r-- | Wrappers/Python/ccpi/optimisation/functions/functions.py | 3 |
2 files changed, 5 insertions, 58 deletions
diff --git a/Wrappers/Python/ccpi/optimisation/functions/FunctionComposition.py b/Wrappers/Python/ccpi/optimisation/functions/FunctionComposition.py index 5b6defc..f24dc10 100644 --- a/Wrappers/Python/ccpi/optimisation/functions/FunctionComposition.py +++ b/Wrappers/Python/ccpi/optimisation/functions/FunctionComposition.py @@ -7,9 +7,11 @@ Created on Wed Mar 6 19:45:06 2019 """ import numpy as np -from ccpi.optimisation.funcs import Function +#from ccpi.optimisation.funcs import Function +from ccpi.optimisation.functions import Function from ccpi.framework import DataContainer, ImageData, ImageGeometry from ccpi.framework import BlockDataContainer +from ccpi.optimisation.functions import BlockFunction class FunctionOperatorComposition(Function): @@ -51,63 +53,7 @@ class FunctionOperatorComposition(Function): return self.adjoint(self.function.gradient(self.operator.direct(x))) -class BlockFunction(Function): - - def __init__(self, operator, *functions): - - self.functions = functions - self.operator = operator - self.length = len(self.functions) - - super(BlockFunction, self).__init__() - - def __call__(self, x): - - tmp = operator.direct(x) - - t = 0 - for i in range(tmp.shape[0]): - t += self.functions[i](tmp.get_item(i)) - return t - - def call_adjoint(self, x): - - tmp = operator.adjoint(x) - - t = 0 - for i in range(tmp.shape[0]): - t += self.functions[i](tmp.get_item(i)) - return t - - def convex_conjugate(self, x): - - ''' Convex_conjugate does not take into account the BlockOperator''' - t = 0 - for i in range(x.shape[0]): - t += self.functions[i].convex_conjugate(x.get_item(i)) - return t - - - def proximal_conjugate(self, x, tau, out = None): - - ''' proximal_conjugate does not take into account the BlockOperator''' - out = [None]*self.length - for i in range(self.length): - out[i] = self.functions[i].proximal_conjugate(x.get_item(i), tau) - - return CompositeDataContainer(*out) - - def proximal(self, x, tau, out = None): - - ''' proximal does not take into account the BlockOperator''' - out = [None]*self.length - for i in range(self.length): - out[i] = self.functions[i].proximal(x.get_item(i), tau) - return CompositeDataContainer(*out) - - def gradient(self,x, out=None): - pass class FunctionComposition_new(Function): diff --git a/Wrappers/Python/ccpi/optimisation/functions/functions.py b/Wrappers/Python/ccpi/optimisation/functions/functions.py index f40abb9..8632920 100644 --- a/Wrappers/Python/ccpi/optimisation/functions/functions.py +++ b/Wrappers/Python/ccpi/optimisation/functions/functions.py @@ -9,7 +9,8 @@ Created on Thu Feb 7 13:10:56 2019 """ import numpy as np -from ccpi.optimisation.funcs import Function +#from ccpi.optimisation.funcs import Function +from ccpi.optimisation.functions import Function from ccpi.framework import DataContainer, ImageData, ImageGeometry from operators import CompositeDataContainer, Identity, CompositeOperator from numbers import Number |