/[escript]/trunk/escript/py_src/util.py
ViewVC logotype

Diff of /trunk/escript/py_src/util.py

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

revision 785 by gross, Tue Jul 25 03:48:10 2006 UTC revision 881 by gross, Thu Oct 26 02:54:47 2006 UTC
# Line 26  import math Line 26  import math
26  import numarray  import numarray
27  import escript  import escript
28  import os  import os
29    from esys.escript import C_GeneralTensorProduct
30    
31  #=========================================================  #=========================================================
32  #   some helpers:  #   some helpers:
# Line 440  def matchShape(arg0,arg1): Line 441  def matchShape(arg0,arg1):
441      @type arg0: L{numarray.NumArray},L{escript.Data},C{float}, C{int}, L{Symbol}      @type arg0: L{numarray.NumArray},L{escript.Data},C{float}, C{int}, L{Symbol}
442      @param arg1: a given object      @param arg1: a given object
443      @type arg1: L{numarray.NumArray},L{escript.Data},C{float}, C{int}, L{Symbol}      @type arg1: L{numarray.NumArray},L{escript.Data},C{float}, C{int}, L{Symbol}
444      @return: arg0 and arg1 where copies are returned when the shape has to be changed.      @return: C{arg0} and C{arg1} where copies are returned when the shape has to be changed.
445      @rtype: C{tuple}      @rtype: C{tuple}
446      """      """
447      sh=commonShape(arg0,arg1)      sh=commonShape(arg0,arg1)
# Line 1310  def whereNonZero(arg,tol=0.): Line 1311  def whereNonZero(arg,tol=0.):
1311     else:     else:
1312        raise TypeError,"whereNonZero: Unknown argument type."        raise TypeError,"whereNonZero: Unknown argument type."
1313    
1314    def erf(arg):
1315       """
1316       returns erf of argument arg
1317    
1318       @param arg: argument
1319       @type arg: C{float}, L{escript.Data}, L{Symbol}, L{numarray.NumArray}.
1320       @rtype: C{float}, L{escript.Data}, L{Symbol}, L{numarray.NumArray} depending on the type of arg.
1321       @raises TypeError: if the type of the argument is not expected.
1322       """
1323       if isinstance(arg,escript.Data):
1324          return arg._erf()
1325       else:
1326          raise TypeError,"erf: Unknown argument type."
1327    
1328  def sin(arg):  def sin(arg):
1329     """     """
1330     returns sine of argument arg     returns sine of argument arg
# Line 2930  def trace(arg,axis_offset=0): Line 2945  def trace(arg,axis_offset=0):
2945    
2946     @param arg: argument     @param arg: argument
2947     @type arg: L{escript.Data}, L{Symbol}, L{numarray.NumArray}.     @type arg: L{escript.Data}, L{Symbol}, L{numarray.NumArray}.
2948     @param axis_offset: axis_offset to components to sum over. C{axis_offset} must be non-negative and less than the rank of arg +1. The dimensions on component     @param axis_offset: C{axis_offset} to components to sum over. C{axis_offset} must be non-negative and less than the rank of arg +1. The dimensions on component
2949                    axis_offset and axis_offset+1 must be equal.                    C{axis_offset} and axis_offset+1 must be equal.
2950     @type axis_offset: C{int}     @type axis_offset: C{int}
2951     @return: trace of arg. The rank of the returned object is minus 2 of the rank of arg.     @return: trace of arg. The rank of the returned object is minus 2 of the rank of arg.
2952     @rtype: L{escript.Data}, L{Symbol}, L{numarray.NumArray} depending on the type of arg.     @rtype: L{escript.Data}, L{Symbol}, L{numarray.NumArray} depending on the type of arg.
# Line 2963  def trace(arg,axis_offset=0): Line 2978  def trace(arg,axis_offset=0):
2978        s=list(arg.getShape())                s=list(arg.getShape())        
2979        if not s[axis_offset] == s[axis_offset+1]:        if not s[axis_offset] == s[axis_offset+1]:
2980          raise ValueError,"dimensions of component %s and %s must match."%(axis_offset.axis_offset+1)          raise ValueError,"dimensions of component %s and %s must match."%(axis_offset.axis_offset+1)
2981        return arg._matrixtrace(axis_offset)        return arg._trace(axis_offset)
2982     elif isinstance(arg,float):     elif isinstance(arg,float):
2983        raise TypeError,"illegal argument type float."        raise TypeError,"illegal argument type float."
2984     elif isinstance(arg,int):     elif isinstance(arg,int):
# Line 2982  class Trace_Symbol(DependendSymbol): Line 2997  class Trace_Symbol(DependendSymbol):
2997        initialization of trace L{Symbol} with argument arg        initialization of trace L{Symbol} with argument arg
2998        @param arg: argument of function        @param arg: argument of function
2999        @type arg: L{Symbol}.        @type arg: L{Symbol}.
3000        @param axis_offset: axis_offset to components to sum over. C{axis_offset} must be non-negative and less than the rank of arg +1. The dimensions on component        @param axis_offset: C{axis_offset} to components to sum over. C{axis_offset} must be non-negative and less than the rank of arg +1. The dimensions on component
3001                    axis_offset and axis_offset+1 must be equal.                    C{axis_offset} and axis_offset+1 must be equal.
3002        @type axis_offset: C{int}        @type axis_offset: C{int}
3003        """        """
3004        if arg.getRank()<2:        if arg.getRank()<2:
# Line 3049  class Trace_Symbol(DependendSymbol): Line 3064  class Trace_Symbol(DependendSymbol):
3064    
3065  def transpose(arg,axis_offset=None):  def transpose(arg,axis_offset=None):
3066     """     """
3067     returns the transpose of arg by swaping the first axis_offset and the last rank-axis_offset components.     returns the transpose of arg by swaping the first C{axis_offset} and the last rank-axis_offset components.
3068    
3069     @param arg: argument     @param arg: argument
3070     @type arg: L{escript.Data}, L{Symbol}, L{numarray.NumArray}, C{float}, C{int}     @type arg: L{escript.Data}, L{Symbol}, L{numarray.NumArray}, C{float}, C{int}
3071     @param axis_offset: the first axis_offset components are swapped with rest. If C{axis_offset} must be non-negative and less or equal the rank of arg.     @param axis_offset: the first C{axis_offset} components are swapped with rest. If C{axis_offset} must be non-negative and less or equal the rank of arg.
3072                         if axis_offset is not present C{int(r/2)} where r is the rank of arg is used.                         if C{axis_offset} is not present C{int(r/2)} where r is the rank of arg is used.
3073     @type axis_offset: C{int}     @type axis_offset: C{int}
3074     @return: transpose of arg     @return: transpose of arg
3075     @rtype: L{escript.Data}, L{Symbol}, L{numarray.NumArray},C{float}, C{int} depending on the type of arg.     @rtype: L{escript.Data}, L{Symbol}, L{numarray.NumArray},C{float}, C{int} depending on the type of arg.
# Line 3092  class Transpose_Symbol(DependendSymbol): Line 3107  class Transpose_Symbol(DependendSymbol):
3107    
3108        @param arg: argument of function        @param arg: argument of function
3109        @type arg: L{Symbol}.        @type arg: L{Symbol}.
3110        @param axis_offset: the first axis_offset components are swapped with rest. If C{axis_offset} must be non-negative and less or equal the rank of arg.        @param axis_offset: the first C{axis_offset} components are swapped with rest. If C{axis_offset} must be non-negative and less or equal the rank of arg.
3111                         if axis_offset is not present C{int(r/2)} where r is the rank of arg is used.                         if C{axis_offset} is not present C{int(r/2)} where r is the rank of arg is used.
3112        @type axis_offset: C{int}        @type axis_offset: C{int}
3113        """        """
3114        if axis_offset==None: axis_offset=int(arg.getRank()/2)        if axis_offset==None: axis_offset=int(arg.getRank()/2)
3115        if axis_offset<0 or axis_offset>arg.getRank():        if axis_offset<0 or axis_offset>arg.getRank():
3116          raise ValueError,"axis_offset must be between 0 and %s"%r          raise ValueError,"axis_offset must be between 0 and %s"%arg.getRank()
3117        s=arg.getShape()        s=arg.getShape()
3118        super(Transpose_Symbol,self).__init__(args=[arg,axis_offset],shape=s[axis_offset:]+s[:axis_offset],dim=arg.getDim())        super(Transpose_Symbol,self).__init__(args=[arg,axis_offset],shape=s[axis_offset:]+s[:axis_offset],dim=arg.getDim())
3119    
# Line 3153  class Transpose_Symbol(DependendSymbol): Line 3168  class Transpose_Symbol(DependendSymbol):
3168           return identity(self.getShape())           return identity(self.getShape())
3169        else:        else:
3170           return transpose(self.getDifferentiatedArguments(arg)[0],axis_offset=self.getArgument()[1])           return transpose(self.getDifferentiatedArguments(arg)[0],axis_offset=self.getArgument()[1])
3171    
3172    def swap_axes(arg,axis0=0,axis1=1):
3173       """
3174       returns the swap of arg by swaping the components axis0 and axis1
3175    
3176       @param arg: argument
3177       @type arg: L{escript.Data}, L{Symbol}, L{numarray.NumArray}.
3178       @param axis0: axis. C{axis0} must be non-negative and less than the rank of arg.
3179       @type axis0: C{int}
3180       @param axis1: axis. C{axis1} must be non-negative and less than the rank of arg.
3181       @type axis1: C{int}
3182       @return: C{arg} with swaped components
3183       @rtype: L{escript.Data}, L{Symbol}, L{numarray.NumArray} depending on the type of arg.
3184       """
3185       if axis0 > axis1:
3186          axis0,axis1=axis1,axis0
3187       if isinstance(arg,numarray.NumArray):
3188          return numarray.swapaxes(arg,axis0,axis1)
3189       elif isinstance(arg,escript.Data):
3190          return arg._swap_axes(axis0,axis1)
3191       elif isinstance(arg,float):
3192          raise TyepError,"float argument is not supported."
3193       elif isinstance(arg,int):
3194          raise TyepError,"int argument is not supported."
3195       elif isinstance(arg,Symbol):
3196          return SwapAxes_Symbol(arg,axis0,axis1)
3197       else:
3198          raise TypeError,"Unknown argument type."
3199    
3200    class SwapAxes_Symbol(DependendSymbol):
3201       """
3202       L{Symbol} representing the result of the swap function
3203       """
3204       def __init__(self,arg,axis0=0,axis1=1):
3205          """
3206          initialization of swap L{Symbol} with argument arg
3207    
3208          @param arg: argument
3209          @type arg: L{Symbol}.
3210          @param axis0: axis. C{axis0} must be non-negative and less than the rank of arg.
3211          @type axis0: C{int}
3212          @param axis1: axis. C{axis1} must be non-negative and less than the rank of arg.
3213          @type axis1: C{int}
3214          """
3215          if arg.getRank()<2:
3216             raise ValueError,"argument must have at least rank 2."
3217          if axis0<0 or axis0>arg.getRank()-1:
3218             raise ValueError,"axis0 must be between 0 and %s"%arg.getRank()-1
3219          if axis1<0 or axis1>arg.getRank()-1:
3220             raise ValueError,"axis1 must be between 0 and %s"%arg.getRank()-1
3221          if axis0 == axis1:
3222             raise ValueError,"axis indices must be different."
3223          if axis0 > axis1:
3224             axis0,axis1=axis1,axis0
3225          s=arg.getShape()
3226          s_out=[]
3227          for i in range(len(s)):
3228             if i == axis0:
3229                s_out.append(s[axis1])
3230             elif i == axis1:
3231                s_out.append(s[axis0])
3232             else:
3233                s_out.append(s[i])
3234          super(SwapAxes_Symbol,self).__init__(args=[arg,axis0,axis1],shape=tuple(s_out),dim=arg.getDim())
3235    
3236       def getMyCode(self,argstrs,format="escript"):
3237          """
3238          returns a program code that can be used to evaluate the symbol.
3239    
3240          @param argstrs: gives for each argument a string representing the argument for the evaluation.
3241          @type argstrs: C{str} or a C{list} of length 1 of C{str}.
3242          @param format: specifies the format to be used. At the moment only "escript" ,"text" and "str" are supported.
3243          @type format: C{str}
3244          @return: a piece of program code which can be used to evaluate the expression assuming the values for the arguments are available.
3245          @rtype: C{str}
3246          @raise NotImplementedError: if the requested format is not available
3247          """
3248          if format=="escript" or format=="str"  or format=="text":
3249             return "swap(%s,axis_offset=%s)"%(argstrs[0],argstrs[1])
3250          else:
3251             raise NotImplementedError,"SwapAxes_Symbol does not provide program code for format %s."%format
3252    
3253       def substitute(self,argvals):
3254          """
3255          assigns new values to symbols in the definition of the symbol.
3256          The method replaces the L{Symbol} u by argvals[u] in the expression defining this object.
3257    
3258          @param argvals: new values assigned to symbols
3259          @type argvals: C{dict} with keywords of type L{Symbol}.
3260          @return: result of the substitution process. Operations are executed as much as possible.
3261          @rtype: L{escript.Symbol}, C{float}, L{escript.Data}, L{numarray.NumArray} depending on the degree of substitution
3262          @raise TypeError: if a value for a L{Symbol} cannot be substituted.
3263          """
3264          if argvals.has_key(self):
3265             arg=argvals[self]
3266             if self.isAppropriateValue(arg):
3267                return arg
3268             else:
3269                raise TypeError,"%s: new value is not appropriate."%str(self)
3270          else:
3271             arg=self.getSubstitutedArguments(argvals)
3272             return swap_axes(arg[0],axis0=arg[1],axis1=arg[2])
3273    
3274       def diff(self,arg):
3275          """
3276          differential of this object
3277    
3278          @param arg: the derivative is calculated with respect to arg
3279          @type arg: L{escript.Symbol}
3280          @return: derivative with respect to C{arg}
3281          @rtype: typically L{Symbol} but other types such as C{float}, L{escript.Data}, L{numarray.NumArray}  are possible.
3282          """
3283          if arg==self:
3284             return identity(self.getShape())
3285          else:
3286             return swap_axes(self.getDifferentiatedArguments(arg)[0],axis0=self.getArgument()[1],axis1=self.getArgument()[2])
3287    
3288  def symmetric(arg):  def symmetric(arg):
3289      """      """
3290      returns the symmetric part of the square matrix arg. This is (arg+transpose(arg))/2      returns the symmetric part of the square matrix arg. This is (arg+transpose(arg))/2
# Line 3253  def inverse(arg): Line 3385  def inverse(arg):
3385    
3386      @param arg: square matrix. Must have rank 2 and the first and second dimension must be equal.      @param arg: square matrix. Must have rank 2 and the first and second dimension must be equal.
3387      @type arg: L{numarray.NumArray}, L{escript.Data}, L{Symbol}      @type arg: L{numarray.NumArray}, L{escript.Data}, L{Symbol}
3388      @return: inverse arg_inv of the argument. It will be matrixmul(inverse(arg),arg) almost equal to kronecker(arg.getShape()[0])      @return: inverse arg_inv of the argument. It will be matrix_mult(inverse(arg),arg) almost equal to kronecker(arg.getShape()[0])
3389      @rtype: L{numarray.NumArray}, L{escript.Data}, L{Symbol} depending on the input      @rtype: L{numarray.NumArray}, L{escript.Data}, L{Symbol} depending on the input
3390      @note: for L{escript.Data} objects the dimension is restricted to 3.      @note: for L{escript.Data} objects the dimension is restricted to 3.
3391      """      """
# Line 3934  def minimum(*args): Line 4066  def minimum(*args):
4066            out=add(out,mult(whereNegative(diff),diff))            out=add(out,mult(whereNegative(diff),diff))
4067      return out      return out
4068    
4069  def clip(arg,minval=0.,maxval=1.):  def clip(arg,minval=None,maxval=None):
4070      """      """
4071      cuts the values of arg between minval and maxval      cuts the values of arg between minval and maxval
4072    
4073      @param arg: argument      @param arg: argument
4074      @type arg: L{numarray.NumArray}, L{escript.Data}, L{Symbol}, C{int} or C{float}      @type arg: L{numarray.NumArray}, L{escript.Data}, L{Symbol}, C{int} or C{float}
4075      @param minval: lower range      @param minval: lower range. If None no lower range is applied
4076      @type minval: C{float}      @type minval: C{float} or C{None}
4077      @param maxval: upper range      @param maxval: upper range. If None no upper range is applied
4078      @type maxval: C{float}      @type maxval: C{float} or C{None}
4079      @return: is on object with all its value between minval and maxval. value of the argument that greater then minval and      @return: is on object with all its value between minval and maxval. value of the argument that greater then minval and
4080               less then maxval are unchanged.               less then maxval are unchanged.
4081      @rtype: L{numarray.NumArray}, L{escript.Data}, L{Symbol}, C{int} or C{float} depending on the input      @rtype: L{numarray.NumArray}, L{escript.Data}, L{Symbol}, C{int} or C{float} depending on the input
4082      @raise ValueError: if minval>maxval      @raise ValueError: if minval>maxval
4083      """      """
4084      if minval>maxval:      if not minval==None and not maxval==None:
4085         raise ValueError,"minval = %s must be less then maxval %s"%(minval,maxval)         if minval>maxval:
4086      return minimum(maximum(minval,arg),maxval)            raise ValueError,"minval = %s must be less then maxval %s"%(minval,maxval)
4087        if minval == None:
4088            tmp=arg
4089        else:
4090            tmp=maximum(minval,arg)
4091        if maxval == None:
4092            return tmp
4093        else:
4094            return minimum(tmp,maxval)
4095    
4096        
4097  def inner(arg0,arg1):  def inner(arg0,arg1):
# Line 3998  def outer(arg0,arg1): Line 4138  def outer(arg0,arg1):
4138      """      """
4139      return generalTensorProduct(arg0,arg1,axis_offset=0)      return generalTensorProduct(arg0,arg1,axis_offset=0)
4140    
4141  def matrixmul(arg0,arg1):  def matrixmult(arg0,arg1):
4142      """      """
4143      see L{matrix_mult}      see L{matrix_mult}
4144      """      """
# Line 4196  class GeneralTensorProduct_Symbol(Depend Line 4336  class GeneralTensorProduct_Symbol(Depend
4336           args=self.getSubstitutedArguments(argvals)           args=self.getSubstitutedArguments(argvals)
4337           return generalTensorProduct(args[0],args[1],args[2])           return generalTensorProduct(args[0],args[1],args[2])
4338    
4339  def escript_generalTensorProduct(arg0,arg1,axis_offset): # this should be escript._generalTensorProduct  def escript_generalTensorProduct(arg0,arg1,axis_offset,transpose=0):
4340      "arg0 and arg1 are both Data objects but not neccesrily on the same function space. they could be identical!!!"      "arg0 and arg1 are both Data objects but not neccesrily on the same function space. they could be identical!!!"
4341      # calculate the return shape:      return C_GeneralTensorProduct(arg0, arg1, axis_offset, transpose)
     shape0=arg0.getShape()[:arg0.getRank()-axis_offset]  
     shape01=arg0.getShape()[arg0.getRank()-axis_offset:]  
     shape10=arg1.getShape()[:axis_offset]  
     shape1=arg1.getShape()[axis_offset:]  
     if not shape01==shape10:  
         raise ValueError,"dimensions of last %s components in left argument don't match the first %s components in the right argument."%(axis_offset,axis_offset)  
   
     # whatr function space should be used? (this here is not good!)  
     fs=(escript.Scalar(0.,arg0.getFunctionSpace())+escript.Scalar(0.,arg1.getFunctionSpace())).getFunctionSpace()  
     # create return value:  
     out=escript.Data(0.,tuple(shape0+shape1),fs)  
     #  
     s0=[[]]  
     for k in shape0:  
           s=[]  
           for j in s0:  
                 for i in range(k): s.append(j+[slice(i,i)])  
           s0=s  
     s1=[[]]  
     for k in shape1:  
           s=[]  
           for j in s1:  
                 for i in range(k): s.append(j+[slice(i,i)])  
           s1=s  
     s01=[[]]  
     for k in shape01:  
           s=[]  
           for j in s01:  
                 for i in range(k): s.append(j+[slice(i,i)])  
           s01=s  
   
     for i0 in s0:  
        for i1 in s1:  
          s=escript.Scalar(0.,fs)  
          for i01 in s01:  
             s+=arg0.__getitem__(tuple(i0+i01))*arg1.__getitem__(tuple(i01+i1))  
          out.__setitem__(tuple(i0+i1),s)  
     return out  
   
4342    
4343  def transposed_matrix_mult(arg0,arg1):  def transposed_matrix_mult(arg0,arg1):
4344      """      """
# Line 4434  class GeneralTransposedTensorProduct_Sym Line 4535  class GeneralTransposedTensorProduct_Sym
4535    
4536  def escript_generalTransposedTensorProduct(arg0,arg1,axis_offset): # this should be escript._generalTransposedTensorProduct  def escript_generalTransposedTensorProduct(arg0,arg1,axis_offset): # this should be escript._generalTransposedTensorProduct
4537      "arg0 and arg1 are both Data objects but not neccesrily on the same function space. they could be identical!!!"      "arg0 and arg1 are both Data objects but not neccesrily on the same function space. they could be identical!!!"
4538      # calculate the return shape:      return C_GeneralTensorProduct(arg0, arg1, axis_offset, 1)
     shape01=arg0.getShape()[:axis_offset]  
     shape10=arg1.getShape()[:axis_offset]  
     shape0=arg0.getShape()[axis_offset:]  
     shape1=arg1.getShape()[axis_offset:]  
     if not shape01==shape10:  
         raise ValueError,"dimensions of first %s components in left argument don't match the first %s components in the right argument."%(axis_offset,axis_offset)  
   
     # whatr function space should be used? (this here is not good!)  
     fs=(escript.Scalar(0.,arg0.getFunctionSpace())+escript.Scalar(0.,arg1.getFunctionSpace())).getFunctionSpace()  
     # create return value:  
     out=escript.Data(0.,tuple(shape0+shape1),fs)  
     #  
     s0=[[]]  
     for k in shape0:  
           s=[]  
           for j in s0:  
                 for i in range(k): s.append(j+[slice(i,i)])  
           s0=s  
     s1=[[]]  
     for k in shape1:  
           s=[]  
           for j in s1:  
                 for i in range(k): s.append(j+[slice(i,i)])  
           s1=s  
     s01=[[]]  
     for k in shape01:  
           s=[]  
           for j in s01:  
                 for i in range(k): s.append(j+[slice(i,i)])  
           s01=s  
   
     for i0 in s0:  
        for i1 in s1:  
          s=escript.Scalar(0.,fs)  
          for i01 in s01:  
             s+=arg0.__getitem__(tuple(i01+i0))*arg1.__getitem__(tuple(i01+i1))  
          out.__setitem__(tuple(i0+i1),s)  
     return out  
   
4539    
4540  def matrix_transposed_mult(arg0,arg1):  def matrix_transposed_mult(arg0,arg1):
4541      """      """
# Line 4657  class GeneralTensorTransposedProduct_Sym Line 4719  class GeneralTensorTransposedProduct_Sym
4719    
4720  def escript_generalTensorTransposedProduct(arg0,arg1,axis_offset): # this should be escript._generalTensorTransposedProduct  def escript_generalTensorTransposedProduct(arg0,arg1,axis_offset): # this should be escript._generalTensorTransposedProduct
4721      "arg0 and arg1 are both Data objects but not neccesrily on the same function space. they could be identical!!!"      "arg0 and arg1 are both Data objects but not neccesrily on the same function space. they could be identical!!!"
4722      # calculate the return shape:      return C_GeneralTensorProduct(arg0, arg1, axis_offset, 2)
     shape01=arg0.getShape()[arg0.getRank()-axis_offset:]  
     shape0=arg0.getShape()[:arg0.getRank()-axis_offset]  
     shape10=arg1.getShape()[arg1.getRank()-axis_offset:]  
     shape1=arg1.getShape()[:arg1.getRank()-axis_offset]  
     if not shape01==shape10:  
         raise ValueError,"dimensions of first %s components in left argument don't match the first %s components in the right argument."%(axis_offset,axis_offset)  
   
     # whatr function space should be used? (this here is not good!)  
     fs=(escript.Scalar(0.,arg0.getFunctionSpace())+escript.Scalar(0.,arg1.getFunctionSpace())).getFunctionSpace()  
     # create return value:  
     out=escript.Data(0.,tuple(shape0+shape1),fs)  
     #  
     s0=[[]]  
     for k in shape0:  
           s=[]  
           for j in s0:  
                 for i in range(k): s.append(j+[slice(i,i)])  
           s0=s  
     s1=[[]]  
     for k in shape1:  
           s=[]  
           for j in s1:  
                 for i in range(k): s.append(j+[slice(i,i)])  
           s1=s  
     s01=[[]]  
     for k in shape01:  
           s=[]  
           for j in s01:  
                 for i in range(k): s.append(j+[slice(i,i)])  
           s01=s  
   
     for i0 in s0:  
        for i1 in s1:  
          s=escript.Scalar(0.,fs)  
          for i01 in s01:  
             s+=arg0.__getitem__(tuple(i0+i01))*arg1.__getitem__(tuple(i1+i01))  
          out.__setitem__(tuple(i0+i1),s)  
     return out  
   
4723    
4724  #=========================================================  #=========================================================
4725  #  functions dealing with spatial dependency  #  functions dealing with spatial dependency

Legend:
Removed from v.785  
changed lines
  Added in v.881

  ViewVC Help
Powered by ViewVC 1.1.26