/[escript]/trunk/downunder/test/python/run_inversioncostfunction.py
ViewVC logotype

Diff of /trunk/downunder/test/python/run_inversioncostfunction.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4748 by sshaw, Fri Mar 14 00:30:51 2014 UTC revision 4777 by sshaw, Wed Mar 19 23:52:36 2014 UTC
# Line 39  class SimpleModel(ForwardModel): Line 39  class SimpleModel(ForwardModel):
39          return self.trafo          return self.trafo
40                    
41      def getArguments(self, x):      def getArguments(self, x):
42          return tuple([ n+1 for n in xrange(self.numComps)] )          return tuple([ n+1 for n in range(self.numComps)] )
43    
44      def getDefect(self, x, *args):      def getDefect(self, x, *args):
45          if self.numComps == 1:          if self.numComps == 1:
46              out=(1.*x-2.)*(args[0]*x-2.)              out=(1.*x-2.)*(args[0]*x-2.)
47          else:          else:
48              out=0              out=0
49              for n in xrange(self.numComps):              for n in range(self.numComps):
50                  out=out+((n+1)*x[n]-(n+2))*(args[n]*x[n]-(n+2))                    out=out+((n+1)*x[n]-(n+2))*(args[n]*x[n]-(n+2))  
51          return integrate(out, Function(self.domain))/2          return integrate(out, Function(self.domain))/2
52    
# Line 55  class SimpleModel(ForwardModel): Line 55  class SimpleModel(ForwardModel):
55              Y=(1.*x-2.)*args[0]              Y=(1.*x-2.)*args[0]
56          else:          else:
57              Y=Data(0.,(self.numComps,), Function(self.domain))              Y=Data(0.,(self.numComps,), Function(self.domain))
58              for n in xrange(self.numComps):              for n in range(self.numComps):
59                  Y[n]=((n+1)*x[n]-(n+2))*args[n]                  Y[n]=((n+1)*x[n]-(n+2))*args[n]
60          return Y          return Y
61                    
# Line 63  class SimpleModel(ForwardModel): Line 63  class SimpleModel(ForwardModel):
63          if self.numComps == 1:          if self.numComps == 1:
64              return (s-2)**2 * 0.5              return (s-2)**2 * 0.5
65          else:          else:
66              return sum(((n+1)*s[n]-(n+2))**2 for n in xrange(self.numComps) )*.5                  return sum(((n+1)*s[n]-(n+2))**2 for n in range(self.numComps) )*.5    
67            
68                    
69  class LinearMappingX(Mapping):  class LinearMappingX(Mapping):

Legend:
Removed from v.4748  
changed lines
  Added in v.4777

  ViewVC Help
Powered by ViewVC 1.1.26