/[escript]/trunk/escript/py_src/generateutil
ViewVC logotype

Diff of /trunk/escript/py_src/generateutil

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

revision 1388 by trankine, Fri Jan 11 07:45:58 2008 UTC revision 2169 by caltinay, Wed Dec 17 03:08:58 2008 UTC
# Line 19  test_tail+="suite = unittest.TestSuite() Line 19  test_tail+="suite = unittest.TestSuite()
19  test_tail+="suite.addTest(unittest.makeSuite(Test_util2))\n"  test_tail+="suite.addTest(unittest.makeSuite(Test_util2))\n"
20  test_tail+="unittest.TextTestRunner(verbosity=2).run(suite)\n"  test_tail+="unittest.TextTestRunner(verbosity=2).run(suite)\n"
21    
22  case_set=["float","array","constData","taggedData","expandedData","Symbol"]  case_set=["float","array","constData","taggedData","expandedData","Symbol"]
23  shape_set=[ (),(2,), (4,5), (6,2,2),(3,2,3,4)]  shape_set=[ (),(2,), (4,5), (6,2,2),(3,2,3,4)]
24    
25  t_prog=""  t_prog=""
# Line 30  u_prog="" Line 30  u_prog=""
30  def wherepos(arg):  def wherepos(arg):
31     if arg>0.:     if arg>0.:
32        return 1.        return 1.
33     else:     else:
34        return 0.        return 0.
35    
36    
# Line 49  class OPERATOR: Line 49  class OPERATOR:
49              self.diff=diff              self.diff=diff
50              self.name=name              self.name=name
51    
52  import random  import random
53  import numarray  import numarray
54  import math  import math
55  finc=1.e-6  finc=1.e-6
56    
57  def getResultCaseForBin(case0,case1):  def getResultCaseForBin(case0,case1):
58      if case0=="float":      if case0=="float":
59          if case1=="float":          if case1=="float":
60              case="float"              case="float"
# Line 67  def getResultCaseForBin(case0,case1): Line 67  def getResultCaseForBin(case0,case1):
67          elif case1=="expandedData":          elif case1=="expandedData":
68              case="expandedData"              case="expandedData"
69          elif case1=="Symbol":          elif case1=="Symbol":
70              case="Symbol"                case="Symbol"
71          else:          else:
72                  raise ValueError,"unknown case1=%s"%case1                  raise ValueError,"unknown case1=%s"%case1
73      elif case0=="array":      elif case0=="array":
# Line 82  def getResultCaseForBin(case0,case1): Line 82  def getResultCaseForBin(case0,case1):
82          elif case1=="expandedData":          elif case1=="expandedData":
83              case="expandedData"              case="expandedData"
84          elif case1=="Symbol":          elif case1=="Symbol":
85              case="Symbol"                case="Symbol"
86          else:          else:
87                  raise ValueError,"unknown case1=%s"%case1                  raise ValueError,"unknown case1=%s"%case1
88      elif case0=="constData":      elif case0=="constData":
# Line 97  def getResultCaseForBin(case0,case1): Line 97  def getResultCaseForBin(case0,case1):
97          elif case1=="expandedData":          elif case1=="expandedData":
98              case="expandedData"              case="expandedData"
99          elif case1=="Symbol":          elif case1=="Symbol":
100              case="Symbol"                case="Symbol"
101          else:          else:
102                  raise ValueError,"unknown case1=%s"%case1                  raise ValueError,"unknown case1=%s"%case1
103      elif case0=="taggedData":      elif case0=="taggedData":
# Line 112  def getResultCaseForBin(case0,case1): Line 112  def getResultCaseForBin(case0,case1):
112          elif case1=="expandedData":          elif case1=="expandedData":
113              case="expandedData"              case="expandedData"
114          elif case1=="Symbol":          elif case1=="Symbol":
115              case="Symbol"                case="Symbol"
116          else:          else:
117                  raise ValueError,"unknown case1=%s"%case1                  raise ValueError,"unknown case1=%s"%case1
118      elif case0=="expandedData":      elif case0=="expandedData":
# Line 127  def getResultCaseForBin(case0,case1): Line 127  def getResultCaseForBin(case0,case1):
127          elif case1=="expandedData":          elif case1=="expandedData":
128              case="expandedData"              case="expandedData"
129          elif case1=="Symbol":          elif case1=="Symbol":
130              case="Symbol"                case="Symbol"
131          else:          else:
132                  raise ValueError,"unknown case1=%s"%case1                    raise ValueError,"unknown case1=%s"%case1
133      elif case0=="Symbol":      elif case0=="Symbol":
134          if case1=="float":          if case1=="float":
135              case="Symbol"              case="Symbol"
# Line 154  def makeArray(shape,rng): Line 154  def makeArray(shape,rng):
154     l=rng[1]-rng[0]     l=rng[1]-rng[0]
155     out=numarray.zeros(shape,numarray.Float64)     out=numarray.zeros(shape,numarray.Float64)
156     if isinstance(l,int):     if isinstance(l,int):
157       if len(shape)==0:         if len(shape)==0:
158           out=int(l*random.random()+rng[0])*1.           out=int(l*random.random()+rng[0])*1.
159       elif len(shape)==1:       elif len(shape)==1:
160           for i0 in range(shape[0]):           for i0 in range(shape[0]):
# Line 184  def makeArray(shape,rng): Line 184  def makeArray(shape,rng):
184       else:       else:
185           raise SystemError,"rank is restricted to 5"           raise SystemError,"rank is restricted to 5"
186     else:     else:
187       if len(shape)==0:         if len(shape)==0:
188           out=l*random.random()+rng[0]           out=l*random.random()+rng[0]
189       elif len(shape)==1:       elif len(shape)==1:
190           for i0 in range(shape[0]):           for i0 in range(shape[0]):
# Line 213  def makeArray(shape,rng): Line 213  def makeArray(shape,rng):
213                       out[i0,i1,i2,i3,i4]=l*ranm.random()+rng[0]                       out[i0,i1,i2,i3,i4]=l*ranm.random()+rng[0]
214       else:       else:
215           raise SystemError,"rank is restricted to 5"           raise SystemError,"rank is restricted to 5"
216     return out             return out
217    
218  def makeNumberedArray(shape,s=1.):  def makeNumberedArray(shape,s=1.):
219     out=numarray.zeros(shape,numarray.Float64)     out=numarray.zeros(shape,numarray.Float64)
# Line 239  def makeNumberedArray(shape,s=1.): Line 239  def makeNumberedArray(shape,s=1.):
239                     out[i0,i1,i2,i3]=s*int(8*random.random()+1)                     out[i0,i1,i2,i3]=s*int(8*random.random()+1)
240     else:     else:
241         raise SystemError,"rank is restricted to 4"         raise SystemError,"rank is restricted to 4"
242     return out             return out
243    
244  def makeResult(val,test_expr):  def makeResult(val,test_expr):
245     if isinstance(val,float):     if isinstance(val,float):
# Line 270  def makeResult(val,test_expr): Line 270  def makeResult(val,test_expr):
270                     out[i0,i1,i2,i3]=eval(test_expr.replace("%a1%","val[i0,i1,i2,i3]"))                     out[i0,i1,i2,i3]=eval(test_expr.replace("%a1%","val[i0,i1,i2,i3]"))
271     else:     else:
272         raise SystemError,"rank is restricted to 4"         raise SystemError,"rank is restricted to 4"
273     return out             return out
274    
275  def makeResult2(val0,val1,test_expr):  def makeResult2(val0,val1,test_expr):
276     if isinstance(val0,float):     if isinstance(val0,float):
# Line 282  def makeResult2(val0,val1,test_expr): Line 282  def makeResult2(val0,val1,test_expr):
282            out=numarray.zeros(val1.shape,numarray.Float64)            out=numarray.zeros(val1.shape,numarray.Float64)
283            for i0 in range(val1.shape[0]):            for i0 in range(val1.shape[0]):
284                       out[i0]=eval(test_expr.replace("%a1%","val0").replace("%a2%","val1[i0]"))                       out[i0]=eval(test_expr.replace("%a1%","val0").replace("%a2%","val1[i0]"))
285        elif len(val1.shape)==2:            elif len(val1.shape)==2:
286            out=numarray.zeros(val1.shape,numarray.Float64)            out=numarray.zeros(val1.shape,numarray.Float64)
287            for i0 in range(val1.shape[0]):            for i0 in range(val1.shape[0]):
288               for i1 in range(val1.shape[1]):               for i1 in range(val1.shape[1]):
# Line 293  def makeResult2(val0,val1,test_expr): Line 293  def makeResult2(val0,val1,test_expr):
293               for i1 in range(val1.shape[1]):               for i1 in range(val1.shape[1]):
294                  for i2 in range(val1.shape[2]):                  for i2 in range(val1.shape[2]):
295                       out[i0,i1,i2]=eval(test_expr.replace("%a1%","val0").replace("%a2%","val1[i0,i1,i2]"))                       out[i0,i1,i2]=eval(test_expr.replace("%a1%","val0").replace("%a2%","val1[i0,i1,i2]"))
296        elif len(val1.shape)==4:          elif len(val1.shape)==4:
297            out=numarray.zeros(val1.shape,numarray.Float64)            out=numarray.zeros(val1.shape,numarray.Float64)
298            for i0 in range(val1.shape[0]):            for i0 in range(val1.shape[0]):
299               for i1 in range(val1.shape[1]):               for i1 in range(val1.shape[1]):
# Line 311  def makeResult2(val0,val1,test_expr): Line 311  def makeResult2(val0,val1,test_expr):
311            out=numarray.zeros(val1.shape,numarray.Float64)            out=numarray.zeros(val1.shape,numarray.Float64)
312            for i0 in range(val1.shape[0]):            for i0 in range(val1.shape[0]):
313                       out[i0]=eval(test_expr.replace("%a1%","val0").replace("%a2%","val1[i0]"))                       out[i0]=eval(test_expr.replace("%a1%","val0").replace("%a2%","val1[i0]"))
314        elif len(val1.shape)==2:            elif len(val1.shape)==2:
315            out=numarray.zeros(val1.shape,numarray.Float64)            out=numarray.zeros(val1.shape,numarray.Float64)
316            for i0 in range(val1.shape[0]):            for i0 in range(val1.shape[0]):
317               for i1 in range(val1.shape[1]):               for i1 in range(val1.shape[1]):
# Line 322  def makeResult2(val0,val1,test_expr): Line 322  def makeResult2(val0,val1,test_expr):
322               for i1 in range(val1.shape[1]):               for i1 in range(val1.shape[1]):
323                  for i2 in range(val1.shape[2]):                  for i2 in range(val1.shape[2]):
324                       out[i0,i1,i2]=eval(test_expr.replace("%a1%","val0").replace("%a2%","val1[i0,i1,i2]"))                       out[i0,i1,i2]=eval(test_expr.replace("%a1%","val0").replace("%a2%","val1[i0,i1,i2]"))
325        elif len(val1.shape)==4:          elif len(val1.shape)==4:
326            out=numarray.zeros(val1.shape,numarray.Float64)            out=numarray.zeros(val1.shape,numarray.Float64)
327            for i0 in range(val1.shape[0]):            for i0 in range(val1.shape[0]):
328               for i1 in range(val1.shape[1]):               for i1 in range(val1.shape[1]):
# Line 333  def makeResult2(val0,val1,test_expr): Line 333  def makeResult2(val0,val1,test_expr):
333            raise SystemError,"rank of val1 is restricted to 4"            raise SystemError,"rank of val1 is restricted to 4"
334     elif len(val0.shape)==1:     elif len(val0.shape)==1:
335        if isinstance(val1,float):        if isinstance(val1,float):
336             out=numarray.zeros(val0.shape,numarray.Float64)               out=numarray.zeros(val0.shape,numarray.Float64)
337             for i0 in range(val0.shape[0]):             for i0 in range(val0.shape[0]):
338                out[i0]=eval(test_expr.replace("%a1%","val0[i0]").replace("%a2%","val1"))                out[i0]=eval(test_expr.replace("%a1%","val0[i0]").replace("%a2%","val1"))
339        elif len(val1.shape)==0:        elif len(val1.shape)==0:
340            out=numarray.zeros(val0.shape,numarray.Float64)              out=numarray.zeros(val0.shape,numarray.Float64)
341            for i0 in range(val0.shape[0]):            for i0 in range(val0.shape[0]):
342                out[i0]=eval(test_expr.replace("%a1%","val0[i0]").replace("%a2%","val1"))                out[i0]=eval(test_expr.replace("%a1%","val0[i0]").replace("%a2%","val1"))
343        elif len(val1.shape)==1:        elif len(val1.shape)==1:
344            out=numarray.zeros(val0.shape,numarray.Float64)              out=numarray.zeros(val0.shape,numarray.Float64)
345            for i0 in range(val0.shape[0]):            for i0 in range(val0.shape[0]):
346                out[i0]=eval(test_expr.replace("%a1%","val0[i0]").replace("%a2%","val1[i0]"))                out[i0]=eval(test_expr.replace("%a1%","val0[i0]").replace("%a2%","val1[i0]"))
347        elif len(val1.shape)==2:        elif len(val1.shape)==2:
# Line 366  def makeResult2(val0,val1,test_expr): Line 366  def makeResult2(val0,val1,test_expr):
366           raise SystemError,"rank of val1 is restricted to 4"           raise SystemError,"rank of val1 is restricted to 4"
367     elif len(val0.shape)==2:     elif len(val0.shape)==2:
368        if isinstance(val1,float):        if isinstance(val1,float):
369             out=numarray.zeros(val0.shape,numarray.Float64)               out=numarray.zeros(val0.shape,numarray.Float64)
370             for i0 in range(val0.shape[0]):             for i0 in range(val0.shape[0]):
371                for i1 in range(val0.shape[1]):                for i1 in range(val0.shape[1]):
372                     out[i0,i1]=eval(test_expr.replace("%a1%","val0[i0,i1]").replace("%a2%","val1"))                     out[i0,i1]=eval(test_expr.replace("%a1%","val0[i0,i1]").replace("%a2%","val1"))
373        elif len(val1.shape)==0:        elif len(val1.shape)==0:
374            out=numarray.zeros(val0.shape,numarray.Float64)              out=numarray.zeros(val0.shape,numarray.Float64)
375            for i0 in range(val0.shape[0]):            for i0 in range(val0.shape[0]):
376                for i1 in range(val0.shape[1]):                for i1 in range(val0.shape[1]):
377                     out[i0,i1]=eval(test_expr.replace("%a1%","val0[i0,i1]").replace("%a2%","val1"))                     out[i0,i1]=eval(test_expr.replace("%a1%","val0[i0,i1]").replace("%a2%","val1"))
378        elif len(val1.shape)==1:        elif len(val1.shape)==1:
379            out=numarray.zeros(val0.shape,numarray.Float64)              out=numarray.zeros(val0.shape,numarray.Float64)
380            for i0 in range(val0.shape[0]):            for i0 in range(val0.shape[0]):
381                for i1 in range(val0.shape[1]):                for i1 in range(val0.shape[1]):
382                     out[i0,i1]=eval(test_expr.replace("%a1%","val0[i0,i1]").replace("%a2%","val1[i0]"))                     out[i0,i1]=eval(test_expr.replace("%a1%","val0[i0,i1]").replace("%a2%","val1[i0]"))
# Line 402  def makeResult2(val0,val1,test_expr): Line 402  def makeResult2(val0,val1,test_expr):
402           raise SystemError,"rank of val1 is restricted to 4"           raise SystemError,"rank of val1 is restricted to 4"
403     elif len(val0.shape)==3:     elif len(val0.shape)==3:
404        if isinstance(val1,float):        if isinstance(val1,float):
405             out=numarray.zeros(val0.shape,numarray.Float64)               out=numarray.zeros(val0.shape,numarray.Float64)
406             for i0 in range(val0.shape[0]):             for i0 in range(val0.shape[0]):
407                for i1 in range(val0.shape[1]):                for i1 in range(val0.shape[1]):
408                    for i2 in range(val0.shape[2]):                    for i2 in range(val0.shape[2]):
409                        out[i0,i1,i2]=eval(test_expr.replace("%a1%","val0[i0,i1,i2]").replace("%a2%","val1"))                        out[i0,i1,i2]=eval(test_expr.replace("%a1%","val0[i0,i1,i2]").replace("%a2%","val1"))
410        elif len(val1.shape)==0:        elif len(val1.shape)==0:
411            out=numarray.zeros(val0.shape,numarray.Float64)              out=numarray.zeros(val0.shape,numarray.Float64)
412            for i0 in range(val0.shape[0]):            for i0 in range(val0.shape[0]):
413                for i1 in range(val0.shape[1]):                for i1 in range(val0.shape[1]):
414                    for i2 in range(val0.shape[2]):                    for i2 in range(val0.shape[2]):
415                        out[i0,i1,i2]=eval(test_expr.replace("%a1%","val0[i0,i1,i2]").replace("%a2%","val1"))                        out[i0,i1,i2]=eval(test_expr.replace("%a1%","val0[i0,i1,i2]").replace("%a2%","val1"))
416        elif len(val1.shape)==1:        elif len(val1.shape)==1:
417            out=numarray.zeros(val0.shape,numarray.Float64)              out=numarray.zeros(val0.shape,numarray.Float64)
418            for i0 in range(val0.shape[0]):            for i0 in range(val0.shape[0]):
419                for i1 in range(val0.shape[1]):                for i1 in range(val0.shape[1]):
420                    for i2 in range(val0.shape[2]):                    for i2 in range(val0.shape[2]):
# Line 442  def makeResult2(val0,val1,test_expr): Line 442  def makeResult2(val0,val1,test_expr):
442           raise SystemError,"rank of val1 is rargs[1]estricted to 4"           raise SystemError,"rank of val1 is rargs[1]estricted to 4"
443     elif len(val0.shape)==4:     elif len(val0.shape)==4:
444        if isinstance(val1,float):        if isinstance(val1,float):
445             out=numarray.zeros(val0.shape,numarray.Float64)               out=numarray.zeros(val0.shape,numarray.Float64)
446             for i0 in range(val0.shape[0]):             for i0 in range(val0.shape[0]):
447                for i1 in range(val0.shape[1]):                for i1 in range(val0.shape[1]):
448                    for i2 in range(val0.shape[2]):                    for i2 in range(val0.shape[2]):
449                       for i3 in range(val0.shape[3]):                       for i3 in range(val0.shape[3]):
450                           out[i0,i1,i2,i3]=eval(test_expr.replace("%a1%","val0[i0,i1,i2,i3]").replace("%a2%","val1"))                           out[i0,i1,i2,i3]=eval(test_expr.replace("%a1%","val0[i0,i1,i2,i3]").replace("%a2%","val1"))
451        elif len(val1.shape)==0:        elif len(val1.shape)==0:
452            out=numarray.zeros(val0.shape,numarray.Float64)              out=numarray.zeros(val0.shape,numarray.Float64)
453            for i0 in range(val0.shape[0]):            for i0 in range(val0.shape[0]):
454                for i1 in range(val0.shape[1]):                for i1 in range(val0.shape[1]):
455                    for i2 in range(val0.shape[2]):                    for i2 in range(val0.shape[2]):
456                       for i3 in range(val0.shape[3]):                       for i3 in range(val0.shape[3]):
457                           out[i0,i1,i2,i3]=eval(test_expr.replace("%a1%","val0[i0,i1,i2,i3]").replace("%a2%","val1"))                           out[i0,i1,i2,i3]=eval(test_expr.replace("%a1%","val0[i0,i1,i2,i3]").replace("%a2%","val1"))
458        elif len(val1.shape)==1:        elif len(val1.shape)==1:
459            out=numarray.zeros(val0.shape,numarray.Float64)              out=numarray.zeros(val0.shape,numarray.Float64)
460            for i0 in range(val0.shape[0]):            for i0 in range(val0.shape[0]):
461                for i1 in range(val0.shape[1]):                for i1 in range(val0.shape[1]):
462                    for i2 in range(val0.shape[2]):                    for i2 in range(val0.shape[2]):
# Line 487  def makeResult2(val0,val1,test_expr): Line 487  def makeResult2(val0,val1,test_expr):
487           raise SystemError,"rank of val1 is restricted to 4"           raise SystemError,"rank of val1 is restricted to 4"
488     else:     else:
489         raise SystemError,"rank is restricted to 4"         raise SystemError,"rank is restricted to 4"
490     return out             return out
491    
492    
493  def mkText(case,name,a,a1=None,use_tagging_for_expanded_data=False):  def mkText(case,name,a,a1=None,use_tagging_for_expanded_data=False):
# Line 534  def mkText(case,name,a,a1=None,use_taggi Line 534  def mkText(case,name,a,a1=None,use_taggi
534                else:                else:
535                   t_out+="      %s=Data(numarray.array(%s),self.functionspace)\n"%(name,a.tolist())                   t_out+="      %s=Data(numarray.array(%s),self.functionspace)\n"%(name,a.tolist())
536                   t_out+="      %s.setTaggedValue(1,numarray.array(%s))\n"%(name,a1.tolist())                   t_out+="      %s.setTaggedValue(1,numarray.array(%s))\n"%(name,a1.tolist())
537                t_out+="      %s.expand()\n"%name                          t_out+="      %s.expand()\n"%name
538             else:             else:
539                t_out+="      msk_%s=1-whereZero(self.functionspace.getX()[0],1.e-8)\n"%name                t_out+="      msk_%s=1-whereZero(self.functionspace.getX()[0],1.e-8)\n"%name
540                if isinstance(a,float):                if isinstance(a,float):
541                     t_out+="      %s=msk_%s*(%s)+(1-msk_%s)*(%s)\n"%(name,name,a,name,a1)                     t_out+="      %s=msk_%s*(%s)+(1-msk_%s)*(%s)\n"%(name,name,a,name,a1)
# Line 560  def mkTypeAndShapeTest(case,sh,argstr,na Line 560  def mkTypeAndShapeTest(case,sh,argstr,na
560      elif case=="array":      elif case=="array":
561           text+="      self.failUnless(isinstance(%s,numarray.NumArray),\"wrong type of result%s.\")\n"%(argstr,name)           text+="      self.failUnless(isinstance(%s,numarray.NumArray),\"wrong type of result%s.\")\n"%(argstr,name)
562           text+="      self.failUnlessEqual(%s.shape,%s,\"wrong shape of result%s.\")\n"%(argstr,str(sh),name)           text+="      self.failUnlessEqual(%s.shape,%s,\"wrong shape of result%s.\")\n"%(argstr,str(sh),name)
563      elif case in ["constData","taggedData","expandedData"]:          elif case in ["constData","taggedData","expandedData"]:
564           text+="      self.failUnless(isinstance(%s,Data),\"wrong type of result%s.\")\n"%(argstr,name)           text+="      self.failUnless(isinstance(%s,Data),\"wrong type of result%s.\")\n"%(argstr,name)
565           text+="      self.failUnlessEqual(%s.getShape(),%s,\"wrong shape of result%s.\")\n"%(argstr,str(sh),name)           text+="      self.failUnlessEqual(%s.getShape(),%s,\"wrong shape of result%s.\")\n"%(argstr,str(sh),name)
566      elif case=="Symbol":      elif case=="Symbol":
# Line 572  def mkCode(txt,args=[],intend=""): Line 572  def mkCode(txt,args=[],intend=""):
572      s=txt.split("\n")      s=txt.split("\n")
573      if len(s)>1:      if len(s)>1:
574         out=""         out=""
575         for l in s:         for l in s:
576          out+=intend+l+"\n"          out+=intend+l+"\n"
577      else:      else:
578          out="%sreturn %s\n"%(intend,txt)          out="%sreturn %s\n"%(intend,txt)
579      c=1      c=1
580      for r in args:      for r in args:
581        out=out.replace("%%a%s%%"%c,r)        out=out.replace("%%a%s%%"%c,r)
582      return out        return out
583    
584    
585  #=======================================================================================================  #==============================================================================
586  # swap axes  # swap axes
587  #=======================================================================================================  #==============================================================================
588  for case0 in ["array","Symbol","constData","taggedData","expandedData"]:  for case0 in ["array","Symbol","constData","taggedData","expandedData"]:
589    for sh0 in [ (4,5), (6,2,2),(3,2,3,4)]:    for sh0 in [ (4,5), (6,2,2),(3,2,3,4)]:
590      for axis0 in range(len(sh0)):      for axis0 in range(len(sh0)):
591         for axis1 in range(axis0+1,len(sh0)):         for axis1 in range(axis0+1,len(sh0)):
# Line 614  for case0 in ["array","Symbol","constDat Line 614  for case0 in ["array","Symbol","constDat
614    
615            if case0 == "taggedData":            if case0 == "taggedData":
616                 t_prog_with_tags+=text                 t_prog_with_tags+=text
617            else:                          else:
618                 t_prog+=text                 t_prog+=text
619  print test_header  print test_header
620  # print t_prog  # print t_prog
621  print t_prog_with_tags  print t_prog_with_tags
622  print test_tail  print test_tail
623  1/0            1/0
624  while True:    while True:
625       for sh_s in [ (),(3,), (2,3), (2,4,3),(4,2,3,2)]:       for sh_s in [ (),(3,), (2,3), (2,4,3),(4,2,3,2)]:
626            if (len(sh0+sh_s)==0 or not case0=="float") and (len(sh1+sh_s)==0 or not case1=="float") \            if (len(sh0+sh_s)==0 or not case0=="float") and (len(sh1+sh_s)==0 or not case1=="float") \
627                 and len(sh0+sh1)<5 and len(sh0+sh_s)<5 and len(sh1+sh_s)<5:                 and len(sh0+sh1)<5 and len(sh0+sh_s)<5 and len(sh1+sh_s)<5:
628              arg_shape=oper[2](sh0,sh1,sh_s)              arg_shape=oper[2](sh0,sh1,sh_s)
629              if not arg_shape==None:              if not arg_shape==None:
630                case=getResultCaseForBin(case0,case1)                  case=getResultCaseForBin(case0,case1)
631                use_tagging_for_expanded_data= case0=="taggedData" or case1=="taggedData"                use_tagging_for_expanded_data= case0=="taggedData" or case1=="taggedData"
632                if oper[0] in [ "generalTensorProduct", "generalTransposedTensorProduct", "generalTensorTransposedProduct"]:                if oper[0] in [ "generalTensorProduct", "generalTransposedTensorProduct", "generalTensorTransposedProduct"]:
633                  tname="test_%s_%s_rank%s_%s_rank%s_offset%s"%(oper[0],case0,len(sh0+sh_s),case1,len(sh_s+sh1),len(sh_s))                  tname="test_%s_%s_rank%s_%s_rank%s_offset%s"%(oper[0],case0,len(sh0+sh_s),case1,len(sh_s+sh1),len(sh_s))
# Line 657  while True: Line 657  while True:
657                if case=="Symbol":                if case=="Symbol":
658                   c0_res,c1_res=case0,case1                   c0_res,c1_res=case0,case1
659                   subs="{"                   subs="{"
660                   if case0=="Symbol":                           if case0=="Symbol":
661                      text+=mkText("array","s0",a_0,a1_0)                      text+=mkText("array","s0",a_0,a1_0)
662                      subs+="arg0:s0"                      subs+="arg0:s0"
663                      c0_res="array"                      c0_res="array"
664                   if case1=="Symbol":                           if case1=="Symbol":
665                      text+=mkText("array","s1",a_1,a1_1)                      text+=mkText("array","s1",a_1,a1_1)
666                      if not subs.endswith("{"): subs+=","                      if not subs.endswith("{"): subs+=","
667                      subs+="arg1:s1"                      subs+="arg1:s1"
668                      c1_res="array"                      c1_res="array"
669                   subs+="}"                     subs+="}"
670                   text+="      sub=res.substitute(%s)\n"%subs                   text+="      sub=res.substitute(%s)\n"%subs
671                   res="sub"                   res="sub"
672                   text+=mkText(getResultCaseForBin(c0_res,c1_res),"ref",r,r1)                   text+=mkText(getResultCaseForBin(c0_res,c1_res),"ref",r,r1)
# Line 682  def testMatrixMult(arg0,arg1,sh_s): Line 682  def testMatrixMult(arg0,arg1,sh_s):
682       return numarray.matrixmultiply(arg0,arg1)       return numarray.matrixmultiply(arg0,arg1)
683    
684  def shapeTestMatrixMult(sh0,sh1,sh_s):  def shapeTestMatrixMult(sh0,sh1,sh_s):
685   if len(sh_s)==1 and len(sh0+sh_s)==2 and (len(sh_s+sh1)==1 or len(sh_s+sh1)==2):   if len(sh_s)==1 and len(sh0+sh_s)==2 and (len(sh_s+sh1)==1 or len(sh_s+sh1)==2):
686          return sh0+sh_s,sh_s+sh1          return sh0+sh_s,sh_s+sh1
687    
688  def testTensorMult(arg0,arg1,sh_s):  def testTensorMult(arg0,arg1,sh_s):
# Line 756  def transpose(r,offset): Line 756  def transpose(r,offset):
756      return numarray.resize(out,s[offset:]+s[:offset])      return numarray.resize(out,s[offset:]+s[:offset])
757    
758  def shapeTestTMatrixMult(sh0,sh1,sh_s):  def shapeTestTMatrixMult(sh0,sh1,sh_s):
759   if len(sh_s)==1 and len(sh0+sh_s)==2 and (len(sh_s+sh1)==1 or len(sh_s+sh1)==2):   if len(sh_s)==1 and len(sh0+sh_s)==2 and (len(sh_s+sh1)==1 or len(sh_s+sh1)==2):
760          return sh_s+sh0,sh_s+sh1          return sh_s+sh0,sh_s+sh1
761    
762  def testTMatrixMult(arg0,arg1,sh_s):  def testTMatrixMult(arg0,arg1,sh_s):
# Line 823  def tensorTProductTest(arg0,arg1,sh_s): Line 823  def tensorTProductTest(arg0,arg1,sh_s):
823      return out      return out
824    
825  def shapeTestMatrixTMult(sh0,sh1,sh_s):  def shapeTestMatrixTMult(sh0,sh1,sh_s):
826   if len(sh_s)==1 and len(sh0+sh_s)==2 and len(sh_s+sh1)==2:   if len(sh_s)==1 and len(sh0+sh_s)==2 and len(sh_s+sh1)==2:
827       return sh0+sh_s,sh1+sh_s       return sh0+sh_s,sh1+sh_s
828    
829  def testMatrixTMult(arg0,arg1,sh_s):  def testMatrixTMult(arg0,arg1,sh_s):
# Line 902  for oper in [ ["tensor_mult",testTensorM Line 902  for oper in [ ["tensor_mult",testTensorM
902                ["generalTransposedTensorProduct",tensorTProductTest,tensorTProductShape], \                ["generalTransposedTensorProduct",tensorTProductTest,tensorTProductShape], \
903                ["matrix_transposed_mult",testMatrixTMult,shapeTestMatrixTMult], \                ["matrix_transposed_mult",testMatrixTMult,shapeTestMatrixTMult], \
904                ["tensor_transposed_mult",testTensorTMult,shapeTestTensorTMult], \                ["tensor_transposed_mult",testTensorTMult,shapeTestTensorTMult], \
905                ["generalTensorTransposedProduct",tensorProductTTest,tensorProductTShape] ]:                ["generalTensorTransposedProduct",tensorProductTTest,tensorProductTShape] ]:
906    
907   for case0 in ["float","array","Symbol","constData","taggedData","expandedData"]:   for case0 in ["float","array","Symbol","constData","taggedData","expandedData"]:
908    for sh0 in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:    for sh0 in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:
909     for case1 in ["float","array","Symbol","constData","taggedData","expandedData"]:     for case1 in ["float","array","Symbol","constData","taggedData","expandedData"]:
910       for sh1 in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:       for sh1 in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:
# Line 913  for oper in [ ["tensor_mult",testTensorM Line 913  for oper in [ ["tensor_mult",testTensorM
913                 and len(sh0+sh1)<5 and len(sh0+sh_s)<5 and len(sh1+sh_s)<5:                 and len(sh0+sh1)<5 and len(sh0+sh_s)<5 and len(sh1+sh_s)<5:
914              arg_shape=oper[2](sh0,sh1,sh_s)              arg_shape=oper[2](sh0,sh1,sh_s)
915              if not arg_shape==None:              if not arg_shape==None:
916                case=getResultCaseForBin(case0,case1)                  case=getResultCaseForBin(case0,case1)
917                use_tagging_for_expanded_data= case0=="taggedData" or case1=="taggedData"                use_tagging_for_expanded_data= case0=="taggedData" or case1=="taggedData"
918                text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"                text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
919                if oper[0] in [ "generalTensorProduct", "generalTransposedTensorProduct", "generalTensorTransposedProduct"]:                if oper[0] in [ "generalTensorProduct", "generalTransposedTensorProduct", "generalTensorTransposedProduct"]:
# Line 945  for oper in [ ["tensor_mult",testTensorM Line 945  for oper in [ ["tensor_mult",testTensorM
945                if case=="Symbol":                if case=="Symbol":
946                   c0_res,c1_res=case0,case1                   c0_res,c1_res=case0,case1
947                   subs="{"                   subs="{"
948                   if case0=="Symbol":                           if case0=="Symbol":
949                      text+=mkText("array","s0",a_0,a1_0)                      text+=mkText("array","s0",a_0,a1_0)
950                      subs+="arg0:s0"                      subs+="arg0:s0"
951                      c0_res="array"                      c0_res="array"
952                   if case1=="Symbol":                           if case1=="Symbol":
953                      text+=mkText("array","s1",a_1,a1_1)                      text+=mkText("array","s1",a_1,a1_1)
954                      if not subs.endswith("{"): subs+=","                      if not subs.endswith("{"): subs+=","
955                      subs+="arg1:s1"                      subs+="arg1:s1"
956                      c1_res="array"                      c1_res="array"
957                   subs+="}"                     subs+="}"
958                   text+="      sub=res.substitute(%s)\n"%subs                   text+="      sub=res.substitute(%s)\n"%subs
959                   res="sub"                   res="sub"
960                   text+=mkText(getResultCaseForBin(c0_res,c1_res),"ref",r,r1)                   text+=mkText(getResultCaseForBin(c0_res,c1_res),"ref",r,r1)
# Line 965  for oper in [ ["tensor_mult",testTensorM Line 965  for oper in [ ["tensor_mult",testTensorM
965                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res
966                if case0 == "taggedData" or case1 == "taggedData":                if case0 == "taggedData" or case1 == "taggedData":
967                    t_prog_with_tags+=text                    t_prog_with_tags+=text
968                else:                              else:
969                    t_prog+=text                    t_prog+=text
970  print test_header  print test_header
971  print t_prog  print t_prog
972  # print t_prog_with_tags  # print t_prog_with_tags
973  print test_tail            print test_tail
974  1/0  1/0
975    
976    
977    
978  #=======================================================================================================  #==============================================================================
979  # eigenvalues and eigen vectors 2D:  # eigenvalues and eigenvectors 2D:
980  #=======================================================================================================  #==============================================================================
981  alltests= \  alltests= \
982    [ ("case0",[[0.0, 0.0], [0.0, 0.0]],[0.0, 0.0]) \    [ ("case0",[[0.0, 0.0], [0.0, 0.0]],[0.0, 0.0]) \
983     , ("case3",[[-1.0, 0.0], [0.0, -1.0]],[-1.0, -1.0]) \     , ("case3",[[-1.0, 0.0], [0.0, -1.0]],[-1.0, -1.0]) \
# Line 1027  alltests= \ Line 1027  alltests= \
1027  ]  ]
1028  dim=1  dim=1
1029    
1030  for case in ["constData","taggedData","expandedData"]:  for case in ["constData","taggedData","expandedData"]:
1031     n=0     n=0
1032     while n<len(alltests):     while n<len(alltests):
1033        text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"        text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
# Line 1044  for case in ["constData","taggedData","e Line 1044  for case in ["constData","taggedData","e
1044             ev1_0=numarray.array(alltests[0][2],numarray.Float64)             ev1_0=numarray.array(alltests[0][2],numarray.Float64)
1045           n+=2           n+=2
1046        else:        else:
1047           a1_0=a_0                             a1_0=a_0
1048           ev1_0=ev_0           ev1_0=ev_0
1049           n+=1           n+=1
1050        text+=mkText(case,"arg",a_0,a1_0)        text+=mkText(case,"arg",a_0,a1_0)
# Line 1058  for case in ["constData","taggedData","e Line 1058  for case in ["constData","taggedData","e
1058        text+="      self.failUnless(Lsup(matrixmult(transpose(res[1]),res[1])-kronecker(%s))<=self.RES_TOL,\"eigenvectors are not orthonormal\")\n"%dim        text+="      self.failUnless(Lsup(matrixmult(transpose(res[1]),res[1])-kronecker(%s))<=self.RES_TOL,\"eigenvectors are not orthonormal\")\n"%dim
1059        if case == "taggedData" :        if case == "taggedData" :
1060             t_prog_with_tags+=text             t_prog_with_tags+=text
1061        else:                      else:
1062             t_prog+=text             t_prog+=text
1063  print test_header  print test_header
1064  print t_prog  print t_prog
1065  print t_prog_with_tags  print t_prog_with_tags
1066  print test_tail            print test_tail
1067  1/0  1/0
1068  #=======================================================================================================  #==============================================================================
1069  # get slices  # get slices
1070  #=======================================================================================================  #==============================================================================
1071  from esys.escript import *  from esys.escript import *
1072  for case0 in ["constData","taggedData","expandedData"]:  for case0 in ["constData","taggedData","expandedData"]:
1073     for sh0 in [ (3,), (3,4), (3,4,3) ,(4,3,3,3)]:     for sh0 in [ (3,), (3,4), (3,4,3) ,(4,3,3,3)]:
1074      # get perm:      # get perm:
1075      if len(sh0)==2:      if len(sh0)==2:
# Line 1085  for case0 in ["constData","taggedData"," Line 1085  for case0 in ["constData","taggedData","
1085                 [0,2,1,3],                 [0,2,1,3],
1086                 [0,2,3,1],                 [0,2,3,1],
1087                 [0,3,2,1],                 [0,3,2,1],
1088                 [0,3,1,2] ,                           [0,3,1,2] ,
1089                 [1,0,2,3],                 [1,0,2,3],
1090                 [1,0,3,2],                 [1,0,3,2],
1091                 [1,2,0,3],                 [1,2,0,3],
# Line 1106  for case0 in ["constData","taggedData"," Line 1106  for case0 in ["constData","taggedData","
1106                 [3,2,0,1]]                 [3,2,0,1]]
1107      else:      else:
1108           check=[]           check=[]
1109        
1110      # create the test cases:      # create the test cases:
1111      processed=[]      processed=[]
1112      l=["R","U","L","P","C","N"]      l=["R","U","L","P","C","N"]
# Line 1131  for case0 in ["constData","taggedData"," Line 1131  for case0 in ["constData","taggedData","
1131            if ci[i]=="R":            if ci[i]=="R":
1132               s="%s:%s"%(1,sh0[i]-1)               s="%s:%s"%(1,sh0[i]-1)
1133               sl=sl+(slice(1,sh0[i]-1),)               sl=sl+(slice(1,sh0[i]-1),)
1134               sh=sh+(sh0[i]-2,)                           sh=sh+(sh0[i]-2,)
1135            if ci[i]=="U":            if ci[i]=="U":
1136                s=":%s"%(sh0[i]-1)                s=":%s"%(sh0[i]-1)
1137                sh=sh+(sh0[i]-1,)                sh=sh+(sh0[i]-1,)
1138                sl=sl+(slice(0,sh0[i]-1),)                            sl=sl+(slice(0,sh0[i]-1),)
1139            if ci[i]=="L":            if ci[i]=="L":
1140                s="2:"                s="2:"
1141                sh=sh+(sh0[i]-2,)                            sh=sh+(sh0[i]-2,)
1142                sl=sl+(slice(2,sh0[i]),)                            sl=sl+(slice(2,sh0[i]),)
1143            if ci[i]=="P":            if ci[i]=="P":
1144                s="%s"%(int(sh0[i]/2))                s="%s"%(int(sh0[i]/2))
1145                sl=sl+(int(sh0[i]/2),)                            sl=sl+(int(sh0[i]/2),)
1146            if ci[i]=="C":            if ci[i]=="C":
1147                s=":"                s=":"
1148                sh=sh+(sh0[i],)                            sh=sh+(sh0[i],)
1149                sl=sl+(slice(0,sh0[i]),)                            sl=sl+(slice(0,sh0[i]),)
1150            if ci[i]=="N":            if ci[i]=="N":
1151                s=""                s=""
1152                sh=sh+(sh0[i],)                sh=sh+(sh0[i],)
# Line 1169  for case0 in ["constData","taggedData"," Line 1169  for case0 in ["constData","taggedData","
1169           for ci2 in processed:           for ci2 in processed:
1170             for chi in check:             for chi in check:
1171                 is_perm=True                 is_perm=True
1172                 for i in range(len(chi)):                 for i in range(len(chi)):
1173                     if not ci[i]==ci2[chi[i]]: is_perm=False                     if not ci[i]==ci2[chi[i]]: is_perm=False
1174                 if is_perm: process=False                 if is_perm: process=False
1175        # if not process: print ci," rejected"        # if not process: print ci," rejected"
1176        if process:        if process:
1177         processed.append(ci)         processed.append(ci)
1178         for case1 in ["array","constData","taggedData","expandedData"]:         for case1 in ["array","constData","taggedData","expandedData"]:
1179            text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"            text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
1180            tname="test_setslice_%s_rank%s_%s_%s"%(case0,len(sh0),case1,ci)            tname="test_setslice_%s_rank%s_%s_%s"%(case0,len(sh0),case1,ci)
1181            text+="   def %s(self):\n"%tname            text+="   def %s(self):\n"%tname
# Line 1191  for case0 in ["constData","taggedData"," Line 1191  for case0 in ["constData","taggedData","
1191            else:            else:
1192                a1_1=a_1*1.                a1_1=a_1*1.
1193    
1194            text+=mkText(case0,"arg",a_0,a1_0)                                              text+=mkText(case0,"arg",a_0,a1_0)
1195            text+=mkText(case1,"val",a_1,a1_1)                                              text+=mkText(case1,"val",a_1,a1_1)
1196            text+="      arg[%s]=val\n"%t            text+="      arg[%s]=val\n"%t
1197            a_0.__setitem__(sl,a_1)            a_0.__setitem__(sl,a_1)
1198            a1_0.__setitem__(sl,a1_1)            a1_0.__setitem__(sl,a1_1)
# Line 1201  for case0 in ["constData","taggedData"," Line 1201  for case0 in ["constData","taggedData","
1201            else:            else:
1202               text+=mkText("expandedData","ref",a_0,a1_0)               text+=mkText("expandedData","ref",a_0,a1_0)
1203            text+="      self.failUnless(Lsup(arg-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"            text+="      self.failUnless(Lsup(arg-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"
1204                  
1205            if case0 == "taggedData" or case1 == "taggedData":            if case0 == "taggedData" or case1 == "taggedData":
1206              t_prog_with_tags+=text              t_prog_with_tags+=text
1207            else:                          else:
1208              t_prog+=text              t_prog+=text
1209    
1210  print test_header  print test_header
1211  # print t_prog  # print t_prog
1212  print t_prog_with_tags  print t_prog_with_tags
1213  print test_tail            print test_tail
1214  1/0  1/0
1215    
1216  #=======================================================================================================  #==============================================================================
1217  # (non)symmetric part  # (non)symmetric part
1218  #=======================================================================================================  #==============================================================================
1219  from esys.escript import *  from esys.escript import *
1220  for name in ["symmetric", "nonsymmetric"]:  for name in ["symmetric", "nonsymmetric"]:
1221   f=1.   f=1.
1222   if name=="nonsymmetric": f=-1   if name=="nonsymmetric": f=-1
1223   for case0 in ["array","Symbol","constData","taggedData","expandedData"]:   for case0 in ["array","Symbol","constData","taggedData","expandedData"]:
1224    for sh0 in [ (3,3), (2,3,2,3)]:    for sh0 in [ (3,3), (2,3,2,3)]:
1225                text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"                text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
1226                tname="test_%s_%s_rank%s"%(name,case0,len(sh0))                tname="test_%s_%s_rank%s"%(name,case0,len(sh0))
# Line 1231  for name in ["symmetric", "nonsymmetric" Line 1231  for name in ["symmetric", "nonsymmetric"
1231                   a1_0=makeNumberedArray(sh0,s=-1.)                   a1_0=makeNumberedArray(sh0,s=-1.)
1232                   r1_0=(a1_0+f*transpose(a1_0))/2.                   r1_0=(a1_0+f*transpose(a1_0))/2.
1233                else:                else:
1234                    a1_0=a_0                                      a1_0=a_0
1235                    r1_0=r_0                    r1_0=r_0
1236                text+=mkText(case0,"arg",a_0,a1_0)                text+=mkText(case0,"arg",a_0,a1_0)
1237                text+="      res=%s(arg)\n"%name                text+="      res=%s(arg)\n"%name
# Line 1242  for name in ["symmetric", "nonsymmetric" Line 1242  for name in ["symmetric", "nonsymmetric"
1242                   text+=mkText("array","ref",r_0,r1_0)                   text+=mkText("array","ref",r_0,r1_0)
1243                else:                else:
1244                   res="res"                   res="res"
1245                   text+=mkText(case0,"ref",r_0,r1_0)                     text+=mkText(case0,"ref",r_0,r1_0)
1246                text+=mkTypeAndShapeTest(case0,sh0,"res")                text+=mkTypeAndShapeTest(case0,sh0,"res")
1247                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res
1248                  
1249                if case0 == "taggedData" :                if case0 == "taggedData" :
1250                    t_prog_with_tags+=text                    t_prog_with_tags+=text
1251                else:                              else:
1252                    t_prog+=text                    t_prog+=text
1253  print test_header  print test_header
1254  print t_prog  print t_prog
1255  # print t_prog_with_tags  # print t_prog_with_tags
1256  print test_tail            print test_tail
1257  1/0  1/0
1258    
1259  #=======================================================================================================  #==============================================================================
1260  # eigenvalues  # eigenvalues
1261  #=======================================================================================================  #==============================================================================
1262  import numarray.linear_algebra  import numarray.linear_algebra
1263  name="eigenvalues"  name="eigenvalues"
1264  for case0 in ["array","Symbol","constData","taggedData","expandedData"]:  for case0 in ["array","Symbol","constData","taggedData","expandedData"]:
1265    for sh0 in [ (1,1), (2,2), (3,3)]:    for sh0 in [ (1,1), (2,2), (3,3)]:
1266                text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"                text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
1267                tname="test_%s_%s_dim%s"%(name,case0,sh0[0])                tname="test_%s_%s_dim%s"%(name,case0,sh0[0])
# Line 1276  for case0 in ["array","Symbol","constDat Line 1276  for case0 in ["array","Symbol","constDat
1276                    ev1=numarray.linear_algebra.eigenvalues(a1_0)                    ev1=numarray.linear_algebra.eigenvalues(a1_0)
1277                    ev1.sort()                    ev1.sort()
1278                else:                else:
1279                    a1_0=a_0                                      a1_0=a_0
1280                    ev1=ev                    ev1=ev
1281                text+=mkText(case0,"arg",a_0,a1_0)                text+=mkText(case0,"arg",a_0,a1_0)
1282                text+="      res=%s(arg)\n"%name                text+="      res=%s(arg)\n"%name
# Line 1287  for case0 in ["array","Symbol","constDat Line 1287  for case0 in ["array","Symbol","constDat
1287                   text+=mkText("array","ref",ev,ev1)                   text+=mkText("array","ref",ev,ev1)
1288                else:                else:
1289                   res="res"                   res="res"
1290                   text+=mkText(case0,"ref",ev,ev1)                     text+=mkText(case0,"ref",ev,ev1)
1291                text+=mkTypeAndShapeTest(case0,(sh0[0],),"res")                text+=mkTypeAndShapeTest(case0,(sh0[0],),"res")
1292                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res
1293                  
1294                if case0 == "taggedData" :                if case0 == "taggedData" :
1295                    t_prog_with_tags+=text                    t_prog_with_tags+=text
1296                else:                              else:
1297                    t_prog+=text                    t_prog+=text
1298  print test_header  print test_header
1299  # print t_prog  # print t_prog
1300  print t_prog_with_tags  print t_prog_with_tags
1301  print test_tail            print test_tail
1302  1/0  1/0
1303    
1304  #=======================================================================================================  #==============================================================================
1305  # get slices  # get slices
1306  #=======================================================================================================  #==============================================================================
1307  for case0 in ["constData","taggedData","expandedData","Symbol"]:  for case0 in ["constData","taggedData","expandedData","Symbol"]:
1308    for sh0 in [ (3,), (3,4), (3,4,3) ,(4,3,5,3)]:    for sh0 in [ (3,), (3,4), (3,4,3) ,(4,3,5,3)]:
1309      # get perm:      # get perm:
1310      if len(sh0)==2:      if len(sh0)==2:
# Line 1320  for case0 in ["constData","taggedData"," Line 1320  for case0 in ["constData","taggedData","
1320                 [0,2,1,3],                 [0,2,1,3],
1321                 [0,2,3,1],                 [0,2,3,1],
1322                 [0,3,2,1],                 [0,3,2,1],
1323                 [0,3,1,2] ,                           [0,3,1,2] ,
1324                 [1,0,2,3],                 [1,0,2,3],
1325                 [1,0,3,2],                 [1,0,3,2],
1326                 [1,2,0,3],                 [1,2,0,3],
# Line 1341  for case0 in ["constData","taggedData"," Line 1341  for case0 in ["constData","taggedData","
1341                 [3,2,0,1]]                 [3,2,0,1]]
1342      else:      else:
1343           check=[]           check=[]
1344        
1345      # create the test cases:      # create the test cases:
1346      processed=[]      processed=[]
1347      l=["R","U","L","P","C","N"]      l=["R","U","L","P","C","N"]
# Line 1364  for case0 in ["constData","taggedData"," Line 1364  for case0 in ["constData","taggedData","
1364        for i in range(len(ci)):        for i in range(len(ci)):
1365            if ci[i]=="R":            if ci[i]=="R":
1366               s="%s:%s"%(1,sh0[i]-1)               s="%s:%s"%(1,sh0[i]-1)
1367               sh=sh+(sh0[i]-2,)                           sh=sh+(sh0[i]-2,)
1368            if ci[i]=="U":            if ci[i]=="U":
1369                s=":%s"%(sh0[i]-1)                s=":%s"%(sh0[i]-1)
1370                sh=sh+(sh0[i]-1,)                            sh=sh+(sh0[i]-1,)
1371            if ci[i]=="L":            if ci[i]=="L":
1372                s="2:"                s="2:"
1373                sh=sh+(sh0[i]-2,)                            sh=sh+(sh0[i]-2,)
1374            if ci[i]=="P":            if ci[i]=="P":
1375                s="%s"%(int(sh0[i]/2))                s="%s"%(int(sh0[i]/2))
1376            if ci[i]=="C":            if ci[i]=="C":
1377                s=":"                s=":"
1378                sh=sh+(sh0[i],)                            sh=sh+(sh0[i],)
1379            if ci[i]=="N":            if ci[i]=="N":
1380                s=""                s=""
1381                sh=sh+(sh0[i],)                sh=sh+(sh0[i],)
# Line 1397  for case0 in ["constData","taggedData"," Line 1397  for case0 in ["constData","taggedData","
1397           for ci2 in processed:           for ci2 in processed:
1398             for chi in check:             for chi in check:
1399                 is_perm=True                 is_perm=True
1400                 for i in range(len(chi)):                 for i in range(len(chi)):
1401                     if not ci[i]==ci2[chi[i]]: is_perm=False                     if not ci[i]==ci2[chi[i]]: is_perm=False
1402                 if is_perm: process=False                 if is_perm: process=False
1403        # if not process: print ci," rejected"        # if not process: print ci," rejected"
1404        if process:        if process:
1405         processed.append(ci)         processed.append(ci)
1406         text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"         text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
# Line 1425  for case0 in ["constData","taggedData"," Line 1425  for case0 in ["constData","taggedData","
1425             text+=mkText(case0,"ref",r,r1)             text+=mkText(case0,"ref",r,r1)
1426         text+=mkTypeAndShapeTest(case0,sh,"res")         text+=mkTypeAndShapeTest(case0,sh,"res")
1427         text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res         text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res
1428                  
1429         if case0 == "taggedData" :         if case0 == "taggedData" :
1430              t_prog_with_tags+=text              t_prog_with_tags+=text
1431         else:                       else:
1432              t_prog+=text              t_prog+=text
1433    
1434  print test_header  print test_header
1435  # print t_prog  # print t_prog
1436  print t_prog_with_tags  print t_prog_with_tags
1437  print test_tail            print test_tail
1438  1/0  1/0
1439  #============================================================================================  #==============================================================================
1440  def innerTEST(arg0,arg1):  def innerTEST(arg0,arg1):
1441      if isinstance(arg0,float):      if isinstance(arg0,float):
1442         out=numarray.array(arg0*arg1)         out=numarray.array(arg0*arg1)
# Line 1449  def outerTEST(arg0,arg1): Line 1449  def outerTEST(arg0,arg1):
1449         out=numarray.array(arg0*arg1)         out=numarray.array(arg0*arg1)
1450      elif isinstance(arg1,float):      elif isinstance(arg1,float):
1451         out=numarray.array(arg0*arg1)         out=numarray.array(arg0*arg1)
1452      else:            else:
1453         out=numarray.outerproduct(arg0,arg1).resize(arg0.shape+arg1.shape)         out=numarray.outerproduct(arg0,arg1).resize(arg0.shape+arg1.shape)
1454      return out      return out
1455    
# Line 1475  def tensorProductTest(arg0,arg1,sh_s): Line 1475  def tensorProductTest(arg0,arg1,sh_s):
1475                for i in range(ls): out2[i0,i1]+=out1[i0,i,i,i1]                for i in range(ls): out2[i0,i1]+=out1[i0,i,i,i1]
1476         out=out2.resize(sh0+sh1)         out=out2.resize(sh0+sh1)
1477      return out      return out
1478          
1479  def testMatrixMult(arg0,arg1,sh_s):  def testMatrixMult(arg0,arg1,sh_s):
1480       return numarray.matrixmultiply(arg0,arg1)       return numarray.matrixmultiply(arg0,arg1)
1481    
# Line 1533  def testReduce(arg0,init_val,test_expr,p Line 1533  def testReduce(arg0,init_val,test_expr,p
1533           for i1 in range(arg0.shape[1]):           for i1 in range(arg0.shape[1]):
1534             for i2 in range(arg0.shape[2]):             for i2 in range(arg0.shape[2]):
1535               for i3 in range(arg0.shape[3]):               for i3 in range(arg0.shape[3]):
1536                 out=eval(test_expr.replace("%a1%","arg0[i0,i1,i2,i3]"))                           out=eval(test_expr.replace("%a1%","arg0[i0,i1,i2,i3]"))
1537       return eval(post_expr)       return eval(post_expr)
1538        
1539  def clipTEST(arg0,mn,mx):  def clipTEST(arg0,mn,mx):
1540       if isinstance(arg0,float):       if isinstance(arg0,float):
1541            return max(min(arg0,mx),mn)            return max(min(arg0,mx),mn)
# Line 1559  def clipTEST(arg0,mn,mx): Line 1559  def clipTEST(arg0,mn,mx):
1559               for i3 in range(arg0.shape[3]):               for i3 in range(arg0.shape[3]):
1560                  out[i0,i1,i2,i3]=max(min(arg0[i0,i1,i2,i3],mx),mn)                  out[i0,i1,i2,i3]=max(min(arg0[i0,i1,i2,i3],mx),mn)
1561       return out       return out
1562    
1563  def minimumTEST(arg0,arg1):  def minimumTEST(arg0,arg1):
1564       if isinstance(arg0,float):       if isinstance(arg0,float):
1565         if isinstance(arg1,float):         if isinstance(arg1,float):
# Line 1608  def minimumTEST(arg0,arg1): Line 1609  def minimumTEST(arg0,arg1):
1609                else:                else:
1610                 out[i0,i1,i2,i3]=arg0[i0,i1,i2,i3]                 out[i0,i1,i2,i3]=arg0[i0,i1,i2,i3]
1611       return out       return out
1612        
1613  def unrollLoops(a,b,o,arg,tap="",x="x"):  def unrollLoops(a,b,o,arg,tap="",x="x"):
1614      out=""      out=""
1615      if a.rank==1:      if a.rank==1:
# Line 1678  def unrollLoopsOfGrad(a,b,o,arg,tap=""): Line 1679  def unrollLoopsOfGrad(a,b,o,arg,tap=""):
1679      out=""      out=""
1680      if a.rank==1:      if a.rank==1:
1681               for i99 in range(a.shape[0]):               for i99 in range(a.shape[0]):
1682                 if o=="1":                 if o=="1":
1683                    out+=tap+"%s[%s]=(%s)\n"%(arg,i99,a[i99]+b[i99])                    out+=tap+"%s[%s]=(%s)\n"%(arg,i99,a[i99]+b[i99])
1684                 else:                 else:
1685                    out+=tap+"%s[%s]=o*(%s)*x_ref[%s]**(o-1)+(%s)\n"%(arg,i99,a[i99],i99,b[i99])                    out+=tap+"%s[%s]=o*(%s)*x_ref[%s]**(o-1)+(%s)\n"%(arg,i99,a[i99],i99,b[i99])
# Line 1710  def unrollLoopsOfGrad(a,b,o,arg,tap=""): Line 1711  def unrollLoopsOfGrad(a,b,o,arg,tap=""):
1711                 else:                 else:
1712                   out+=tap+"%s[%s,%s,%s,%s]=o*(%s)*x_ref[%s]**(o-1)+(%s)\n"%(arg,i0,i1,i2,i99,a[i0,i1,i2,i99],i99,b[i0,i1,i2,i99])                   out+=tap+"%s[%s,%s,%s,%s]=o*(%s)*x_ref[%s]**(o-1)+(%s)\n"%(arg,i0,i1,i2,i99,a[i0,i1,i2,i99],i99,b[i0,i1,i2,i99])
1713      return out      return out
1714    
1715  def unrollLoopsOfDiv(a,b,o,arg,tap=""):  def unrollLoopsOfDiv(a,b,o,arg,tap=""):
1716      out=tap+arg+"="      out=tap+arg+"="
1717      if o=="1":      if o=="1":
1718         z=0.         z=0.
1719         for i99 in range(a.shape[0]):         for i99 in range(a.shape[0]):
1720              z+=b[i99,i99]+a[i99,i99]              z+=b[i99,i99]+a[i99,i99]
1721         out+="(%s)"%z             out+="(%s)"%z
1722      else:      else:
1723         z=0.         z=0.
1724         for i99 in range(a.shape[0]):         for i99 in range(a.shape[0]):
1725              z+=b[i99,i99]              z+=b[i99,i99]
1726              if i99>0: out+="+"              if i99>0: out+="+"
1727              out+="o*(%s)*x_ref[%s]**(o-1)"%(a[i99,i99],i99)              out+="o*(%s)*x_ref[%s]**(o-1)"%(a[i99,i99],i99)
1728         out+="+(%s)"%z             out+="+(%s)"%z
1729      return out      return out
1730    
1731  def unrollLoopsOfInteriorIntegral(a,b,where,arg,tap=""):  def unrollLoopsOfInteriorIntegral(a,b,where,arg,tap=""):
# Line 1845  def unrollLoopsOfInteriorIntegral(a,b,wh Line 1847  def unrollLoopsOfInteriorIntegral(a,b,wh
1847                 out+="+(%s)*0.5**o\n"%zop                 out+="+(%s)*0.5**o\n"%zop
1848    
1849      return out      return out
1850    
1851  def unrollLoopsSimplified(b,arg,tap=""):  def unrollLoopsSimplified(b,arg,tap=""):
1852      out=""      out=""
1853      if isinstance(b,float) or b.rank==0:      if isinstance(b,float) or b.rank==0:
# Line 1880  def unrollLoopsOfL2(b,where,arg,tap=""): Line 1883  def unrollLoopsOfL2(b,where,arg,tap=""):
1883               z.append(b[i0]**2)               z.append(b[i0]**2)
1884      elif b.rank==2:      elif b.rank==2:
1885          for i1 in range(b.shape[1]):          for i1 in range(b.shape[1]):
1886             s=0             s=0
1887             for i0 in range(b.shape[0]):             for i0 in range(b.shape[0]):
1888                s+=b[i0,i1]**2                s+=b[i0,i1]**2
1889             z.append(s)             z.append(s)
# Line 1899  def unrollLoopsOfL2(b,where,arg,tap=""): Line 1902  def unrollLoopsOfL2(b,where,arg,tap=""):
1902             for i1 in range(b.shape[1]):             for i1 in range(b.shape[1]):
1903                for i2 in range(b.shape[2]):                for i2 in range(b.shape[2]):
1904                   s+=b[i0,i1,i2,i3]**2                   s+=b[i0,i1,i2,i3]**2
1905           z.append(s)                   z.append(s)
1906      if where=="Function":      if where=="Function":
1907         xfac_o=1.         xfac_o=1.
1908         xfac_op=0.         xfac_op=0.
# Line 1916  def unrollLoopsOfL2(b,where,arg,tap=""): Line 1919  def unrollLoopsOfL2(b,where,arg,tap=""):
1919         xfac_o=0.         xfac_o=0.
1920         xfac_op=1.         xfac_op=1.
1921         z_fac_s=""         z_fac_s=""
1922         zo_fac_s=""             zo_fac_s=""
1923         zo_fac=1./3.             zo_fac=1./3.
1924      zo=0.      zo=0.
1925      zop=0.      zop=0.
1926      for i99 in range(len(z)):      for i99 in range(len(z)):
# Line 1932  def unrollLoopsOfL2(b,where,arg,tap=""): Line 1935  def unrollLoopsOfL2(b,where,arg,tap=""):
1935      else:      else:
1936         out+="+(%s))\n"%(zop*0.5**2)         out+="+(%s))\n"%(zop*0.5**2)
1937      return out      return out
1938  #=======================================================================================================  #==============================================================================
1939  # transpose  # transpose
1940  #=======================================================================================================  #==============================================================================
1941  def transposeTest(r,offset):  def transposeTest(r,offset):
1942      if isinstance(r,float): return r      if isinstance(r,float): return r
1943      s=r.shape      s=r.shape
# Line 1947  def transposeTest(r,offset): Line 1950  def transposeTest(r,offset):
1950      return numarray.resize(out,s[offset:]+s[:offset])      return numarray.resize(out,s[offset:]+s[:offset])
1951    
1952  name,tt="transpose",transposeTest  name,tt="transpose",transposeTest
1953  for case0 in ["array","Symbol","constData","taggedData","expandedData"]:  for case0 in ["array","Symbol","constData","taggedData","expandedData"]:
1954    for sh0 in [ (), (3,), (4,5), (6,2,2),(3,2,3,4)]:    for sh0 in [ (), (3,), (4,5), (6,2,2),(3,2,3,4)]:
1955      for offset in range(len(sh0)+1):      for offset in range(len(sh0)+1):
1956                text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"                text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
# Line 1960  for case0 in ["array","Symbol","constDat Line 1963  for case0 in ["array","Symbol","constDat
1963  #              sh_t=tuple(sh_t)  #              sh_t=tuple(sh_t)
1964  #              sh_r=[]  #              sh_r=[]
1965  #              for i in range(offset): sh_r.append(sh0[i])  #              for i in range(offset): sh_r.append(sh0[i])
1966  #              for i in range(offset+2,len(sh0)): sh_r.append(sh0[i])                #              for i in range(offset+2,len(sh0)): sh_r.append(sh0[i])
1967  #              sh_r=tuple(sh_r)  #              sh_r=tuple(sh_r)
1968    
1969                a_0=makeArray(sh0,[-1.,1])                a_0=makeArray(sh0,[-1.,1])
# Line 1982  for case0 in ["array","Symbol","constDat Line 1985  for case0 in ["array","Symbol","constDat
1985                   text+=mkText(case0,"ref",r,r1)                   text+=mkText(case0,"ref",r,r1)
1986                text+=mkTypeAndShapeTest(case0,sh_t,"res")                text+=mkTypeAndShapeTest(case0,sh_t,"res")
1987                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res
1988                  
1989                if case0 == "taggedData" :                if case0 == "taggedData" :
1990                    t_prog_with_tags+=text                    t_prog_with_tags+=text
1991                else:                              else:
1992                    t_prog+=text                    t_prog+=text
1993    
1994  print test_header  print test_header
1995  # print t_prog  # print t_prog
1996  print t_prog_with_tags  print t_prog_with_tags
1997  print test_tail            print test_tail
1998  1/0  1/0
1999  #=======================================================================================================  #==============================================================================
2000  # L2  # L2
2001  #=======================================================================================================  #==============================================================================
2002  for where in ["Function","FunctionOnBoundary","FunctionOnContactZero","FunctionOnContactOne"]:  for where in ["Function","FunctionOnBoundary","FunctionOnContactZero","FunctionOnContactOne"]:
2003    for data in ["Data","Symbol"]:    for data in ["Data","Symbol"]:
2004      for sh in [ (),(2,), (4,5), (6,2,2),(4,5,3,2)]:      for sh in [ (),(2,), (4,5), (6,2,2),(4,5,3,2)]:
2005           text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"           text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
2006           tname="test_L2_on%s_from%s_rank%s"%(where,data,len(sh))           tname="test_L2_on%s_from%s_rank%s"%(where,data,len(sh))
# Line 2012  for where in ["Function","FunctionOnBoun Line 2015  for where in ["Function","FunctionOnBoun
2015           o="1"           o="1"
2016           if len(sh)>0:           if len(sh)>0:
2017              sh_2=sh[:len(sh)-1]+(2,)              sh_2=sh[:len(sh)-1]+(2,)
2018              sh_3=sh[:len(sh)-1]+(3,)                          sh_3=sh[:len(sh)-1]+(3,)
2019              b_2=makeArray(sh[:len(sh)-1]+(2,),[-1.,1])              b_2=makeArray(sh[:len(sh)-1]+(2,),[-1.,1])
2020              b_3=makeArray(sh[:len(sh)-1]+(3,),[-1.,1])              b_3=makeArray(sh[:len(sh)-1]+(3,),[-1.,1])
2021           else:           else:
# Line 2037  for where in ["Function","FunctionOnBoun Line 2040  for where in ["Function","FunctionOnBoun
2040           text+="\n      else:\n"           text+="\n      else:\n"
2041           if data=="Symbol":           if data=="Symbol":
2042                 text+="        arg=Symbol(shape=%s,dim=dim)\n"%str(sh_3)                 text+="        arg=Symbol(shape=%s,dim=dim)\n"%str(sh_3)
2043           text+="        %s=Data(0,%s,w)\n"%(val,sh_3)                   text+="        %s=Data(0,%s,w)\n"%(val,sh_3)
2044           text+=unrollLoopsSimplified(b_3,val,tap="        ")           text+=unrollLoopsSimplified(b_3,val,tap="        ")
2045           text+=unrollLoopsOfL2(b_3,where,"ref",tap="        ")           text+=unrollLoopsOfL2(b_3,where,"ref",tap="        ")
2046           text+="\n      res=L2(arg)\n"           text+="\n      res=L2(arg)\n"
# Line 2052  for where in ["Function","FunctionOnBoun Line 2055  for where in ["Function","FunctionOnBoun
2055  print t_prog  print t_prog
2056  1/0  1/0
2057    
2058  #=======================================================================================================  #==============================================================================
2059  # div  # div
2060  #=======================================================================================================  #==============================================================================
2061  for where in ["Function","FunctionOnBoundary","FunctionOnContactZero","FunctionOnContactOne"]:  for where in ["Function","FunctionOnBoundary","FunctionOnContactZero","FunctionOnContactOne"]:
2062    for data in ["Data","Symbol"]:    for data in ["Data","Symbol"]:
2063       for case in ["ContinuousFunction","Solution","ReducedSolution"]:       for case in ["ContinuousFunction","Solution","ReducedSolution"]:
2064           text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"           text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
2065           tname="test_div_on%s_from%s_%s"%(where,data,case)           tname="test_div_on%s_from%s_%s"%(where,data,case)
# Line 2069  for where in ["Function","FunctionOnBoun Line 2072  for where in ["Function","FunctionOnBoun
2072           if case=="ReducedSolution":           if case=="ReducedSolution":
2073              text+="      o=1\n"              text+="      o=1\n"
2074              o="1"              o="1"
2075           else:           else:
2076              text+="      o=self.order\n"              text+="      o=self.order\n"
2077              o="o"              o="o"
2078           text+="      dim=self.domain.getDim()\n"           text+="      dim=self.domain.getDim()\n"
# Line 2093  for where in ["Function","FunctionOnBoun Line 2096  for where in ["Function","FunctionOnBoun
2096           text+=unrollLoops(a_2,b_2,o,val,tap="        ")           text+=unrollLoops(a_2,b_2,o,val,tap="        ")
2097           text+=unrollLoopsOfDiv(a_2,b_2,o,"ref",tap="        ")           text+=unrollLoopsOfDiv(a_2,b_2,o,"ref",tap="        ")
2098           text+="\n      else:\n"           text+="\n      else:\n"
2099            
2100           text+=unrollLoops(a_3,b_3,o,val,tap="        ")           text+=unrollLoops(a_3,b_3,o,val,tap="        ")
2101           text+=unrollLoopsOfDiv(a_3,b_3,o,"ref",tap="        ")           text+=unrollLoopsOfDiv(a_3,b_3,o,"ref",tap="        ")
2102           text+="\n      res=div(arg,where=w_ref)\n"           text+="\n      res=div(arg,where=w_ref)\n"
# Line 2109  for where in ["Function","FunctionOnBoun Line 2112  for where in ["Function","FunctionOnBoun
2112  print t_prog  print t_prog
2113  1/0  1/0
2114    
2115  #=======================================================================================================  #==============================================================================
2116  # interpolation  # interpolation
2117  #=======================================================================================================  #==============================================================================
2118  for where in ["Function","FunctionOnBoundary","FunctionOnContactZero","FunctionOnContactOne","Solution","ReducedSolution"]:  for where in ["Function","FunctionOnBoundary","FunctionOnContactZero","FunctionOnContactOne","Solution","ReducedSolution"]:
2119    for data in ["Data","Symbol"]:    for data in ["Data","Symbol"]:
2120       for case in ["ContinuousFunction","Solution","ReducedSolution","Function","FunctionOnBoundary","FunctionOnContactZero","FunctionOnContactOne"]:       for case in ["ContinuousFunction","Solution","ReducedSolution","Function","FunctionOnBoundary","FunctionOnContactZero","FunctionOnContactOne"]:
2121        for sh in [ (),(2,), (4,5), (6,2,2),(4,5,3,2)]:        for sh in [ (),(2,), (4,5), (6,2,2),(4,5,3,2)]:
2122          if  where==case or \          if  where==case or \
# Line 2121  for where in ["Function","FunctionOnBoun Line 2124  for where in ["Function","FunctionOnBoun
2124              ( case in ["FunctionOnContactZero","FunctionOnContactOne"] and where in ["FunctionOnContactZero","FunctionOnContactOne"] ) or \              ( case in ["FunctionOnContactZero","FunctionOnContactOne"] and where in ["FunctionOnContactZero","FunctionOnContactOne"] ) or \
2125              (case=="ContinuousFunction" and  where in ["Solution","ReducedSolution"]) or \              (case=="ContinuousFunction" and  where in ["Solution","ReducedSolution"]) or \
2126              (case=="Solution" and  where=="ReducedSolution") :              (case=="Solution" and  where=="ReducedSolution") :
2127                
2128    
2129           text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"           text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
2130           tname="test_interpolation_on%s_from%s_%s_rank%s"%(where,data,case,len(sh))           tname="test_interpolation_on%s_from%s_%s_rank%s"%(where,data,case,len(sh))
2131           text+="   def %s(self):\n"%tname           text+="   def %s(self):\n"%tname
2132           text+="      \"\"\"\n"           text+="      \"\"\"\n"
2133           text+="      tests interpolation for rank %s %s onto the %s\n\n"%(len(sh),data,where)           text+="      tests interpolation for rank %s %s onto the %s\n\n"%(len(sh),data,where)
2134           text+="      assumptions: self.domain supports inpterpolation from %s onto %s\n"%(case,where)           text+="      assumptions: self.domain supports interpolation from %s onto %s\n"%(case,where)
2135           text+="      \"\"\"\n"           text+="      \"\"\"\n"
2136           if case=="ReducedSolution" or where=="ReducedSolution":           if case=="ReducedSolution" or where=="ReducedSolution":
2137              text+="      o=1\n"              text+="      o=1\n"
2138              o="1"              o="1"
2139           else:           else:
2140              text+="      o=self.order\n"              text+="      o=self.order\n"
2141              o="o"              o="o"
2142           text+="      dim=self.domain.getDim()\n"           text+="      dim=self.domain.getDim()\n"
# Line 2158  for where in ["Function","FunctionOnBoun Line 2161  for where in ["Function","FunctionOnBoun
2161           text+=unrollLoops(a_2,b_2,o,val,tap="        ")           text+=unrollLoops(a_2,b_2,o,val,tap="        ")
2162           text+=unrollLoops(a_2,b_2,o,"ref",tap="        ",x="x_ref")           text+=unrollLoops(a_2,b_2,o,"ref",tap="        ",x="x_ref")
2163           text+="      else:\n"           text+="      else:\n"
2164            
2165           text+=unrollLoops(a_3,b_3,o,val,tap="        ")           text+=unrollLoops(a_3,b_3,o,val,tap="        ")
2166           text+=unrollLoops(a_3,b_3,o,"ref",tap="        ",x="x_ref")           text+=unrollLoops(a_3,b_3,o,"ref",tap="        ",x="x_ref")
2167           text+="      res=interpolate(arg,where=w_ref)\n"           text+="      res=interpolate(arg,where=w_ref)\n"
# Line 2171  for where in ["Function","FunctionOnBoun Line 2174  for where in ["Function","FunctionOnBoun
2174           t_prog+=text           t_prog+=text
2175  print test_header  print test_header
2176  print t_prog  print t_prog
2177  print test_tail            print test_tail
2178  1/0  1/0
2179    
2180  #=======================================================================================================  #==============================================================================
2181  # grad  # grad
2182  #=======================================================================================================  #==============================================================================
2183  for where in ["Function","FunctionOnBoundary","FunctionOnContactZero","FunctionOnContactOne"]:  for where in ["Function","FunctionOnBoundary","FunctionOnContactZero","FunctionOnContactOne"]:
2184    for data in ["Data","Symbol"]:    for data in ["Data","Symbol"]:
2185       for case in ["ContinuousFunction","Solution","ReducedSolution"]:       for case in ["ContinuousFunction","Solution","ReducedSolution"]:
2186         for sh in [ (),(2,), (4,5), (6,2,2)]:         for sh in [ (),(2,), (4,5), (6,2,2)]:
2187           text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"           text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
# Line 2187  for where in ["Function","FunctionOnBoun Line 2190  for where in ["Function","FunctionOnBoun
2190           text+="      \"\"\"\n"           text+="      \"\"\"\n"
2191           text+="      tests gradient for rank %s %s on the %s\n\n"%(len(sh),data,where)           text+="      tests gradient for rank %s %s on the %s\n\n"%(len(sh),data,where)
2192           text+="      assumptions: %s(self.domain) exists\n"%case           text+="      assumptions: %s(self.domain) exists\n"%case
2193           text+="                   self.domain supports gardient on %s\n"%where           text+="                   self.domain supports gradient on %s\n"%where
2194           text+="      \"\"\"\n"           text+="      \"\"\"\n"
2195           if case=="ReducedSolution":           if case=="ReducedSolution":
2196              text+="      o=1\n"              text+="      o=1\n"
2197              o="1"              o="1"
2198           else:           else:
2199              text+="      o=self.order\n"              text+="      o=self.order\n"
2200              o="o"              o="o"
2201           text+="      dim=self.domain.getDim()\n"           text+="      dim=self.domain.getDim()\n"
# Line 2217  for where in ["Function","FunctionOnBoun Line 2220  for where in ["Function","FunctionOnBoun
2220           text+=unrollLoops(a_2,b_2,o,val,tap="        ")           text+=unrollLoops(a_2,b_2,o,val,tap="        ")
2221           text+=unrollLoopsOfGrad(a_2,b_2,o,"ref",tap="        ")           text+=unrollLoopsOfGrad(a_2,b_2,o,"ref",tap="        ")
2222           text+="      else:\n"           text+="      else:\n"
2223            
2224           text+=unrollLoops(a_3,b_3,o,val,tap="        ")           text+=unrollLoops(a_3,b_3,o,val,tap="        ")
2225           text+=unrollLoopsOfGrad(a_3,b_3,o,"ref",tap="        ")           text+=unrollLoopsOfGrad(a_3,b_3,o,"ref",tap="        ")
2226           text+="      res=grad(arg,where=w_ref)\n"           text+="      res=grad(arg,where=w_ref)\n"
# Line 2231  for where in ["Function","FunctionOnBoun Line 2234  for where in ["Function","FunctionOnBoun
2234           t_prog+=text           t_prog+=text
2235  print test_header  print test_header
2236  print t_prog  print t_prog
2237  print test_tail            print test_tail
2238  1/0  1/0
2239    
2240    
2241  #=======================================================================================================  #==============================================================================
2242  # integrate  # integrate
2243  #=======================================================================================================  #==============================================================================
2244  for where in ["Function","FunctionOnBoundary","FunctionOnContactZero","FunctionOnContactOne"]:  for where in ["Function","FunctionOnBoundary","FunctionOnContactZero","FunctionOnContactOne"]:
2245    for data in ["Data","Symbol"]:    for data in ["Data","Symbol"]:
2246      for case in ["ContinuousFunction","Solution","ReducedSolution","Function","FunctionOnBoundary","FunctionOnContactZero","FunctionOnContactOne"]:      for case in ["ContinuousFunction","Solution","ReducedSolution","Function","FunctionOnBoundary","FunctionOnContactZero","FunctionOnContactOne"]:
2247        for sh in [ (),(2,), (4,5), (6,2,2),(4,5,3,2)]:        for sh in [ (),(2,), (4,5), (6,2,2),(4,5,3,2)]:
2248          if (not case in ["Function","FunctionOnBoundary","FunctionOnContactZero","FunctionOnContactOne"]) or where==case:            if (not case in ["Function","FunctionOnBoundary","FunctionOnContactZero","FunctionOnContactOne"]) or where==case:
2249           text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"           text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
2250           tname="test_integrate_on%s_from%s_%s_rank%s"%(where,data,case,len(sh))           tname="test_integrate_on%s_from%s_%s_rank%s"%(where,data,case,len(sh))
2251           text+="   def %s(self):\n"%tname           text+="   def %s(self):\n"%tname
# Line 2255  for where in ["Function","FunctionOnBoun Line 2258  for where in ["Function","FunctionOnBoun
2258           if case=="ReducedSolution":           if case=="ReducedSolution":
2259              text+="      o=1\n"              text+="      o=1\n"
2260              o="1"              o="1"
2261           else:           else:
2262              text+="      o=self.order\n"              text+="      o=self.order\n"
2263              o="o"              o="o"
2264           text+="      dim=self.domain.getDim()\n"           text+="      dim=self.domain.getDim()\n"
# Line 2273  for where in ["Function","FunctionOnBoun Line 2276  for where in ["Function","FunctionOnBoun
2276           else:           else:
2277              val="arg"              val="arg"
2278              res="res"              res="res"
2279                
2280           text+="      %s=Data(0,%s,w)\n"%(val,str(sh))           text+="      %s=Data(0,%s,w)\n"%(val,str(sh))
2281           if not len(sh)==0:           if not len(sh)==0:
2282              text+="      ref=numarray.zeros(%s,numarray.Float)\n"%str(sh)              text+="      ref=numarray.zeros(%s,numarray.Float)\n"%str(sh)
# Line 2281  for where in ["Function","FunctionOnBoun Line 2284  for where in ["Function","FunctionOnBoun
2284           text+=unrollLoops(a_2,b_2,o,val,tap="        ")           text+=unrollLoops(a_2,b_2,o,val,tap="        ")
2285           text+=unrollLoopsOfInteriorIntegral(a_2,b_2,where,"ref",tap="        ")           text+=unrollLoopsOfInteriorIntegral(a_2,b_2,where,"ref",tap="        ")
2286           text+="      else:\n"           text+="      else:\n"
2287            
2288           text+=unrollLoops(a_3,b_3,o,val,tap="        ")           text+=unrollLoops(a_3,b_3,o,val,tap="        ")
2289           text+=unrollLoopsOfInteriorIntegral(a_3,b_3,where,"ref",tap="        ")           text+=unrollLoopsOfInteriorIntegral(a_3,b_3,where,"ref",tap="        ")
2290           if case in ["ContinuousFunction","Solution","ReducedSolution"]:           if case in ["ContinuousFunction","Solution","ReducedSolution"]:
# Line 2306  for where in ["Function","FunctionOnBoun Line 2309  for where in ["Function","FunctionOnBoun
2309           t_prog+=text           t_prog+=text
2310  print test_header  print test_header
2311  print t_prog  print t_prog
2312  print test_tail            print test_tail
2313  1/0  1/0
2314  #=======================================================================================================  #==============================================================================
2315  # inverse  # inverse
2316  #=======================================================================================================  #==============================================================================
2317  name="inverse"  name="inverse"
2318  for case0 in ["array","Symbol","constData","taggedData","expandedData"]:  for case0 in ["array","Symbol","constData","taggedData","expandedData"]:
2319    for sh0 in [ (1,1), (2,2), (3,3)]:    for sh0 in [ (1,1), (2,2), (3,3)]:
2320                text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"                text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
2321                tname="test_%s_%s_dim%s"%(name,case0,sh0[0])                tname="test_%s_%s_dim%s"%(name,case0,sh0[0])
# Line 2324  for case0 in ["array","Symbol","constDat Line 2327  for case0 in ["array","Symbol","constDat
2327                    for i in range(sh0[0]): a1_0[i,i]+=3                    for i in range(sh0[0]): a1_0[i,i]+=3
2328                else:                else:
2329                    a1_0=a_0                    a1_0=a_0
2330                      
2331                text+=mkText(case0,"arg",a_0,a1_0)                text+=mkText(case0,"arg",a_0,a1_0)
2332                text+="      res=%s(arg)\n"%name                text+="      res=%s(arg)\n"%name
2333                if case0=="Symbol":                if case0=="Symbol":
# Line 2337  for case0 in ["array","Symbol","constDat Line 2340  for case0 in ["array","Symbol","constDat
2340                   res="res"                   res="res"
2341                text+=mkTypeAndShapeTest(case0,sh0,"res")                text+=mkTypeAndShapeTest(case0,sh0,"res")
2342                text+="      self.failUnless(Lsup(matrixmult(%s,%s)-kronecker(%s))<=self.RES_TOL,\"wrong result\")\n"%(res,ref,sh0[0])                text+="      self.failUnless(Lsup(matrixmult(%s,%s)-kronecker(%s))<=self.RES_TOL,\"wrong result\")\n"%(res,ref,sh0[0])
2343                  
2344                if case0 == "taggedData" :                if case0 == "taggedData" :
2345                    t_prog_with_tags+=text                    t_prog_with_tags+=text
2346                else:                              else:
2347                    t_prog+=text                    t_prog+=text
2348    
2349  print test_header  print test_header
2350  # print t_prog  # print t_prog
2351  print t_prog_with_tags  print t_prog_with_tags
2352  print test_tail            print test_tail
2353  1/0  1/0
2354    
2355  #=======================================================================================================  #==============================================================================
2356  # trace  # trace
2357  #=======================================================================================================  #==============================================================================
2358  def traceTest(r,offset):  def traceTest(r,offset):
2359      sh=r.shape      sh=r.shape
2360      r1=1      r1=1
# Line 2365  def traceTest(r,offset): Line 2368  def traceTest(r,offset):
2368              for j in range(sh[offset]): s[i1,i2]+=r_s[i1,j,j,i2]              for j in range(sh[offset]): s[i1,i2]+=r_s[i1,j,j,i2]
2369      return s.resize(sh[:offset]+sh[offset+2:])      return s.resize(sh[:offset]+sh[offset+2:])
2370  name,tt="trace",traceTest  name,tt="trace",traceTest
2371  for case0 in ["array","Symbol","constData","taggedData","expandedData"]:  for case0 in ["array","Symbol","constData","taggedData","expandedData"]:
2372    for sh0 in [ (4,5), (6,2,2),(3,2,3,4)]:    for sh0 in [ (4,5), (6,2,2),(3,2,3,4)]:
2373      for offset in range(len(sh0)-1):      for offset in range(len(sh0)-1):
2374                text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"                text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
# Line 2376  for case0 in ["array","Symbol","constDat Line 2379  for case0 in ["array","Symbol","constDat
2379                sh_t=tuple(sh_t)                sh_t=tuple(sh_t)
2380                sh_r=[]                sh_r=[]
2381                for i in range(offset): sh_r.append(sh0[i])                for i in range(offset): sh_r.append(sh0[i])
2382                for i in range(offset+2,len(sh0)): sh_r.append(sh0[i])                              for i in range(offset+2,len(sh0)): sh_r.append(sh0[i])
2383                sh_r=tuple(sh_r)                sh_r=tuple(sh_r)
2384                a_0=makeArray(sh_t,[-1.,1])                a_0=makeArray(sh_t,[-1.,1])
2385                if case0 in ["taggedData", "expandedData"]:                if case0 in ["taggedData", "expandedData"]:
# Line 2397  for case0 in ["array","Symbol","constDat Line 2400  for case0 in ["array","Symbol","constDat
2400                   text+=mkText(case0,"ref",r,r1)                   text+=mkText(case0,"ref",r,r1)
2401                text+=mkTypeAndShapeTest(case0,sh_r,"res")                text+=mkTypeAndShapeTest(case0,sh_r,"res")
2402                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res
2403                  
2404                if case0 == "taggedData" :                if case0 == "taggedData" :
2405                    t_prog_with_tags+=text                    t_prog_with_tags+=text
2406                else:                              else:
2407                    t_prog+=text                    t_prog+=text
2408    
2409  print test_header  print test_header
2410  # print t_prog  # print t_prog
2411  print t_prog_with_tags  print t_prog_with_tags
2412  print test_tail            print test_tail
2413  1/0  1/0
2414    
2415  #=======================================================================================================  #==============================================================================
2416  # clip  # clip
2417  #=======================================================================================================  #==============================================================================
2418  oper_L=[["clip",clipTEST]]  oper_L=[["clip",clipTEST]]
2419  for oper in oper_L:  for oper in oper_L:
2420   for case0 in ["float","array","Symbol","constData","taggedData","expandedData"]:   for case0 in ["float","array","Symbol","constData","taggedData","expandedData"]:
2421    for sh0 in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:    for sh0 in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:
2422          if len(sh0)==0 or not case0=="float":          if len(sh0)==0 or not case0=="float":
2423                text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"                text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
# Line 2440  for oper in oper_L: Line 2443  for oper in oper_L:
2443                   text+=mkText(case0,"ref",r,r1)                   text+=mkText(case0,"ref",r,r1)
2444                text+=mkTypeAndShapeTest(case0,sh0,"res")                text+=mkTypeAndShapeTest(case0,sh0,"res")
2445                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res
2446                  
2447                if case0 == "taggedData" :                if case0 == "taggedData" :
2448                    t_prog_with_tags+=text                    t_prog_with_tags+=text
2449                else:                              else:
2450                    t_prog+=text                    t_prog+=text
2451    
2452  print test_header  print test_header
2453  # print t_prog  # print t_prog
2454  print t_prog_with_tags  print t_prog_with_tags
2455  print test_tail            print test_tail
2456  1/0  1/0
2457    
2458  #=======================================================================================================  #==============================================================================
2459  # maximum, minimum, clipping  # maximum, minimum, clipping
2460  #=======================================================================================================  #==============================================================================
2461  oper_L=[ ["maximum",maximumTEST],  oper_L=[ ["maximum",maximumTEST],
2462           ["minimum",minimumTEST]]           ["minimum",minimumTEST]]
2463  for oper in oper_L:  for oper in oper_L:
2464   for case0 in ["float","array","Symbol","constData","taggedData","expandedData"]:   for case0 in ["float","array","Symbol","constData","taggedData","expandedData"]:
2465    for sh1 in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:    for sh1 in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:
2466     for case1 in ["float","array","Symbol","constData","taggedData","expandedData"]:     for case1 in ["float","array","Symbol","constData","taggedData","expandedData"]:
2467       for sh0 in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:       for sh0 in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:
# Line 2485  for oper in oper_L: Line 2488  for oper in oper_L:
2488                text+=mkText(case0,"arg0",a_0,a1_0,use_tagging_for_expanded_data)                text+=mkText(case0,"arg0",a_0,a1_0,use_tagging_for_expanded_data)
2489                text+=mkText(case1,"arg1",a_1,a1_1,use_tagging_for_expanded_data)                text+=mkText(case1,"arg1",a_1,a1_1,use_tagging_for_expanded_data)
2490                text+="      res=%s(arg0,arg1)\n"%oper[0]                text+="      res=%s(arg0,arg1)\n"%oper[0]
2491                case=getResultCaseForBin(case0,case1)                              case=getResultCaseForBin(case0,case1)
2492                if case=="Symbol":                if case=="Symbol":
2493                   c0_res,c1_res=case0,case1                   c0_res,c1_res=case0,case1
2494                   subs="{"                   subs="{"
2495                   if case0=="Symbol":                           if case0=="Symbol":
2496                      text+=mkText("array","s0",a_0,a1_0)                      text+=mkText("array","s0",a_0,a1_0)
2497                      subs+="arg0:s0"                      subs+="arg0:s0"
2498                      c0_res="array"                      c0_res="array"
2499                   if case1=="Symbol":                           if case1=="Symbol":
2500                      text+=mkText("array","s1",a_1,a1_1)                      text+=mkText("array","s1",a_1,a1_1)
2501                      if not subs.endswith("{"): subs+=","                      if not subs.endswith("{"): subs+=","
2502                      subs+="arg1:s1"                      subs+="arg1:s1"
2503                      c1_res="array"                      c1_res="array"
2504                   subs+="}"                     subs+="}"
2505                   text+="      sub=res.substitute(%s)\n"%subs                   text+="      sub=res.substitute(%s)\n"%subs
2506                   res="sub"                   res="sub"
2507                   text+=mkText(getResultCaseForBin(c0_res,c1_res),"ref",r,r1)                   text+=mkText(getResultCaseForBin(c0_res,c1_res),"ref",r,r1)
# Line 2510  for oper in oper_L: Line 2513  for oper in oper_L:
2513                else:                else:
2514                    text+=mkTypeAndShapeTest(case,sh1,"res")                    text+=mkTypeAndShapeTest(case,sh1,"res")
2515                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res
2516                  
2517                if case0 == "taggedData" or case1 == "taggedData":                if case0 == "taggedData" or case1 == "taggedData":
2518                    t_prog_with_tags+=text                    t_prog_with_tags+=text
2519                else:                              else:
2520                    t_prog+=text                    t_prog+=text
2521    
2522  print test_header  print test_header
2523  # print t_prog  # print t_prog
2524  print t_prog_with_tags  print t_prog_with_tags
2525  print test_tail            print test_tail
2526  1/0  1/0
2527    
2528    
2529  #=======================================================================================================  #==============================================================================
2530  # outer inner  # outer inner
2531  #=======================================================================================================  #==============================================================================
2532  oper=["outer",outerTEST]  oper=["outer",outerTEST]
2533  # oper=["inner",innerTEST]  # oper=["inner",innerTEST]
2534  for case0 in ["float","array","Symbol","constData","taggedData","expandedData"]:  for case0 in ["float","array","Symbol","constData","taggedData","expandedData"]:
2535    for sh1 in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:    for sh1 in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:
2536     for case1 in ["float","array","Symbol","constData","taggedData","expandedData"]:     for case1 in ["float","array","Symbol","constData","taggedData","expandedData"]:
2537       for sh0 in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:       for sh0 in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:
2538          if (len(sh0)==0 or not case0=="float") and (len(sh1)==0 or not case1=="float") \          if (len(sh0)==0 or not case0=="float") and (len(sh1)==0 or not case1=="float") \
2539             and len(sh0+sh1)<5:               and len(sh0+sh1)<5:
2540                use_tagging_for_expanded_data= case0=="taggedData" or case1=="taggedData"                use_tagging_for_expanded_data= case0=="taggedData" or case1=="taggedData"
2541    
2542                text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"                text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
# Line 2555  for case0 in ["float","array","Symbol"," Line 2558  for case0 in ["float","array","Symbol","
2558                text+=mkText(case0,"arg0",a_0,a1_0,use_tagging_for_expanded_data)                text+=mkText(case0,"arg0",a_0,a1_0,use_tagging_for_expanded_data)
2559                text+=mkText(case1,"arg1",a_1,a1_1,use_tagging_for_expanded_data)                text+=mkText(case1,"arg1",a_1,a1_1,use_tagging_for_expanded_data)
2560                text+="      res=%s(arg0,arg1)\n"%oper[0]                text+="      res=%s(arg0,arg1)\n"%oper[0]
2561                case=getResultCaseForBin(case0,case1)                              case=getResultCaseForBin(case0,case1)
2562                if case=="Symbol":                if case=="Symbol":
2563                   c0_res,c1_res=case0,case1                   c0_res,c1_res=case0,case1
2564                   subs="{"                   subs="{"
2565                   if case0=="Symbol":                           if case0=="Symbol":
2566                      text+=mkText("array","s0",a_0,a1_0)                      text+=mkText("array","s0",a_0,a1_0)
2567                      subs+="arg0:s0"                      subs+="arg0:s0"
2568                      c0_res="array"                      c0_res="array"
2569                   if case1=="Symbol":                           if case1=="Symbol":
2570                      text+=mkText("array","s1",a_1,a1_1)                      text+=mkText("array","s1",a_1,a1_1)
2571                      if not subs.endswith("{"): subs+=","                      if not subs.endswith("{"): subs+=","
2572                      subs+="arg1:s1"                      subs+="arg1:s1"
2573                      c1_res="array"                      c1_res="array"
2574                   subs+="}"                     subs+="}"
2575                   text+="      sub=res.substitute(%s)\n"%subs                   text+="      sub=res.substitute(%s)\n"%subs
2576                   res="sub"                   res="sub"
2577                   text+=mkText(getResultCaseForBin(c0_res,c1_res),"ref",r,r1)                   text+=mkText(getResultCaseForBin(c0_res,c1_res),"ref",r,r1)
# Line 2577  for case0 in ["float","array","Symbol"," Line 2580  for case0 in ["float","array","Symbol","
2580                   text+=mkText(case,"ref",r,r1)                   text+=mkText(case,"ref",r,r1)
2581                text+=mkTypeAndShapeTest(case,sh0+sh1,"res")                text+=mkTypeAndShapeTest(case,sh0+sh1,"res")
2582                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res
2583                  
2584                if case0 == "taggedData" or case1 == "taggedData":                if case0 == "taggedData" or case1 == "taggedData":
2585                    t_prog_with_tags+=text                    t_prog_with_tags+=text
2586                else:                              else:
2587                    t_prog+=text                    t_prog+=text
2588    
2589  print test_header  print test_header
2590  # print t_prog  # print t_prog
2591  print t_prog_with_tags  print t_prog_with_tags
2592  print test_tail            print test_tail
2593  1/0  1/0
2594    
2595  #=======================================================================================================  #==============================================================================
2596  # local reduction  # local reduction
2597  #=======================================================================================================  #==============================================================================
2598  for oper in [["length",0.,"out+%a1%**2","math.sqrt(out)"],  for oper in [["length",0.,"out+%a1%**2","math.sqrt(out)"],
2599               ["maxval",-1.e99,"max(out,%a1%)","out"],               ["maxval",-1.e99,"max(out,%a1%)","out"],
2600               ["minval",1.e99,"min(out,%a1%)","out"] ]:               ["minval",1.e99,"min(out,%a1%)","out"] ]:
2601    for case in case_set:    for case in case_set:
2602       for sh in shape_set:       for sh in shape_set:
2603         if not case=="float" or len(sh)==0:         if not case=="float" or len(sh)==0:
2604           text=""           text=""
2605           text+="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"           text+="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
2606           tname="def test_%s_%s_rank%s"%(oper[0],case,len(sh))           tname="def test_%s_%s_rank%s"%(oper[0],case,len(sh))
2607           text+="   %s(self):\n"%tname           text+="   %s(self):\n"%tname
2608           a=makeArray(sh,[-1.,1.])                       a=makeArray(sh,[-1.,1.])
2609           a1=makeArray(sh,[-1.,1.])           a1=makeArray(sh,[-1.,1.])
2610           r1=testReduce(a1,oper[1],oper[2],oper[3])           r1=testReduce(a1,oper[1],oper[2],oper[3])
2611           r=testReduce(a,oper[1],oper[2],oper[3])           r=testReduce(a,oper[1],oper[2],oper[3])
2612            
2613           text+=mkText(case,"arg",a,a1)           text+=mkText(case,"arg",a,a1)
2614           text+="      res=%s(arg)\n"%oper[0]           text+="      res=%s(arg)\n"%oper[0]
2615           if case=="Symbol":                   if case=="Symbol":
2616               text+=mkText("array","s",a,a1)               text+=mkText("array","s",a,a1)
2617               text+="      sub=res.substitute({arg:s})\n"                       text+="      sub=res.substitute({arg:s})\n"
2618               text+=mkText("array","ref",r,r1)               text+=mkText("array","ref",r,r1)
2619               res="sub"               res="sub"
2620           else:           else:
2621               text+=mkText(case,"ref",r,r1)               text+=mkText(case,"ref",r,r1)
2622               res="res"               res="res"
2623           if oper[0]=="length":                         if oper[0]=="length":
2624                 text+=mkTypeAndShapeTest(case,(),"res")                 text+=mkTypeAndShapeTest(case,(),"res")
2625           else:                       else:
2626              if case=="float" or case=="array":                      if case=="float" or case=="array":
2627                 text+=mkTypeAndShapeTest("float",(),"res")                 text+=mkTypeAndShapeTest("float",(),"res")
2628              else:                        else:
2629                 text+=mkTypeAndShapeTest(case,(),"res")                 text+=mkTypeAndShapeTest(case,(),"res")
2630           text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res           text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res
2631           if case == "taggedData":           if case == "taggedData":
# Line 2632  for oper in [["length",0.,"out+%a1%**2", Line 2635  for oper in [["length",0.,"out+%a1%**2",
2635  print test_header  print test_header
2636  # print t_prog  # print t_prog
2637  print t_prog_with_tags  print t_prog_with_tags
2638  print test_tail            print test_tail
2639  1/0  1/0
2640              
2641  #=======================================================================================================  #==============================================================================
2642  # tensor multiply  # tensor multiply
2643  #=======================================================================================================  #==============================================================================
2644  # oper=["generalTensorProduct",tensorProductTest]  # oper=["generalTensorProduct",tensorProductTest]
2645  # oper=["matrixmult",testMatrixMult]  # oper=["matrixmult",testMatrixMult]
2646  oper=["tensormult",testTensorMult]  oper=["tensormult",testTensorMult]
2647    
2648  for case0 in ["float","array","Symbol","constData","taggedData","expandedData"]:  for case0 in ["float","array","Symbol","constData","taggedData","expandedData"]:
2649    for sh0 in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:    for sh0 in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:
2650     for case1 in ["float","array","Symbol","constData","taggedData","expandedData"]:     for case1 in ["float","array","Symbol","constData","taggedData","expandedData"]:
2651       for sh1 in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:       for sh1 in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:
# Line 2651  for case0 in ["float","array","Symbol"," Line 2654  for case0 in ["float","array","Symbol","
2654                 and len(sh0+sh1)<5 and len(sh0+sh_s)<5 and len(sh1+sh_s)<5:                 and len(sh0+sh1)<5 and len(sh0+sh_s)<5 and len(sh1+sh_s)<5:
2655              # if len(sh_s)==1 and len(sh0+sh_s)==2 and (len(sh_s+sh1)==1 or len(sh_s+sh1)==2)): # test for matrixmult              # if len(sh_s)==1 and len(sh0+sh_s)==2 and (len(sh_s+sh1)==1 or len(sh_s+sh1)==2)): # test for matrixmult
2656              if ( len(sh_s)==1 and len(sh0+sh_s)==2 and ( len(sh1+sh_s)==2 or len(sh1+sh_s)==1 )) or (len(sh_s)==2 and len(sh0+sh_s)==4 and (len(sh1+sh_s)==2 or len(sh1+sh_s)==3 or len(sh1+sh_s)==4)):  # test for tensormult              if ( len(sh_s)==1 and len(sh0+sh_s)==2 and ( len(sh1+sh_s)==2 or len(sh1+sh_s)==1 )) or (len(sh_s)==2 and len(sh0+sh_s)==4 and (len(sh1+sh_s)==2 or len(sh1+sh_s)==3 or len(sh1+sh_s)==4)):  # test for tensormult
2657                case=getResultCaseForBin(case0,case1)                  case=getResultCaseForBin(case0,case1)
2658                use_tagging_for_expanded_data= case0=="taggedData" or case1=="taggedData"                use_tagging_for_expanded_data= case0=="taggedData" or case1=="taggedData"
2659                text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"                text="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
2660                # tname="test_generalTensorProduct_%s_rank%s_%s_rank%s_offset%s"%(case0,len(sh0+sh_s),case1,len(sh_s+sh1),len(sh_s))                # tname="test_generalTensorProduct_%s_rank%s_%s_rank%s_offset%s"%(case0,len(sh0+sh_s),case1,len(sh_s+sh1),len(sh_s))
# Line 2681  for case0 in ["float","array","Symbol"," Line 2684  for case0 in ["float","array","Symbol","
2684                if case=="Symbol":                if case=="Symbol":
2685                   c0_res,c1_res=case0,case1                   c0_res,c1_res=case0,case1
2686                   subs="{"                   subs="{"
2687                   if case0=="Symbol":                           if case0=="Symbol":
2688                      text+=mkText("array","s0",a_0,a1_0)                      text+=mkText("array","s0",a_0,a1_0)
2689                      subs+="arg0:s0"                      subs+="arg0:s0"
2690                      c0_res="array"                      c0_res="array"
2691                   if case1=="Symbol":                           if case1=="Symbol":
2692                      text+=mkText("array","s1",a_1,a1_1)                      text+=mkText("array","s1",a_1,a1_1)
2693                      if not subs.endswith("{"): subs+=","                      if not subs.endswith("{"): subs+=","
2694                      subs+="arg1:s1"                      subs+="arg1:s1"
2695                      c1_res="array"                      c1_res="array"
2696                   subs+="}"                     subs+="}"
2697                   text+="      sub=res.substitute(%s)\n"%subs                   text+="      sub=res.substitute(%s)\n"%subs
2698                   res="sub"                   res="sub"
2699                   text+=mkText(getResultCaseForBin(c0_res,c1_res),"ref",r,r1)                   text+=mkText(getResultCaseForBin(c0_res,c1_res),"ref",r,r1)
# Line 2701  for case0 in ["float","array","Symbol"," Line 2704  for case0 in ["float","array","Symbol","
2704                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res
2705                if case0 == "taggedData" or case1 == "taggedData":                if case0 == "taggedData" or case1 == "taggedData":
2706                    t_prog_with_tags+=text                    t_prog_with_tags+=text
2707                else:                              else:
2708                    t_prog+=text                    t_prog+=text
2709  print test_header  print test_header
2710  # print t_prog  # print t_prog
2711  print t_prog_with_tags  print t_prog_with_tags
2712  print test_tail            print test_tail
2713  1/0  1/0
2714  #=======================================================================================================  #==============================================================================
2715  # basic binary operation overloading (tests only!)  # basic binary operation overloading (tests only!)
2716  #=======================================================================================================  #==============================================================================
2717  oper_range=[-5.,5.]  oper_range=[-5.,5.]
2718  for oper in [["add" ,"+",[-5.,5.]],  for oper in [["add" ,"+",[-5.,5.]],
2719               ["sub" ,"-",[-5.,5.]],               ["sub" ,"-",[-5.,5.]],
2720               ["mult","*",[-5.,5.]],               ["mult","*",[-5.,5.]],
2721               ["div" ,"/",[-5.,5.]],               ["div" ,"/",[-5.,5.]],
2722               ["pow" ,"**",[0.01,5.]]]:                 ["pow" ,"**",[0.01,5.]]]:
2723     for case0 in case_set:     for case0 in case_set:
2724       for sh0 in shape_set:       for sh0 in shape_set:
2725         for case1 in case_set:         for case1 in case_set:
2726           for sh1 in shape_set:           for sh1 in shape_set:
2727             if not case0=="array" and \             if not case0=="array" and \
2728                 (not case0=="float" or len(sh0)==0) and (not case1=="float" or len(sh1)==0) and \                 (not case0=="float" or len(sh0)==0) and (not case1=="float" or len(sh1)==0) and \
# Line 2745  for oper in [["add" ,"+",[-5.,5.]], Line 2748  for oper in [["add" ,"+",[-5.,5.]],
2748                text+=mkText(case0,"arg0",a_0,a1_0,use_tagging_for_expanded_data)                text+=mkText(case0,"arg0",a_0,a1_0,use_tagging_for_expanded_data)
2749                text+=mkText(case1,"arg1",a_1,a1_1,use_tagging_for_expanded_data)                text+=mkText(case1,"arg1",a_1,a1_1,use_tagging_for_expanded_data)
2750                text+="      res=arg0%sarg1\n"%oper[1]                text+="      res=arg0%sarg1\n"%oper[1]
2751                  
2752                case=getResultCaseForBin(case0,case1)                              case=getResultCaseForBin(case0,case1)
2753                if case=="Symbol":                if case=="Symbol":
2754                   c0_res,c1_res=case0,case1                   c0_res,c1_res=case0,case1
2755                   subs="{"                   subs="{"
2756                   if case0=="Symbol":                           if case0=="Symbol":
2757                      text+=mkText("array","s0",a_0,a1_0)                      text+=mkText("array","s0",a_0,a1_0)
2758                      subs+="arg0:s0"                      subs+="arg0:s0"
2759                      c0_res="array"                      c0_res="array"
2760                   if case1=="Symbol":                           if case1=="Symbol":
2761                      text+=mkText("array","s1",a_1,a1_1)                      text+=mkText("array","s1",a_1,a1_1)
2762                      if not subs.endswith("{"): subs+=","                      if not subs.endswith("{"): subs+=","
2763                      subs+="arg1:s1"                      subs+="arg1:s1"
2764                      c1_res="array"                      c1_res="array"
2765                   subs+="}"                     subs+="}"
2766                   text+="      sub=res.substitute(%s)\n"%subs                   text+="      sub=res.substitute(%s)\n"%subs
2767                   res="sub"                   res="sub"
2768                   text+=mkText(getResultCaseForBin(c0_res,c1_res),"ref",r,r1)                   text+=mkText(getResultCaseForBin(c0_res,c1_res),"ref",r,r1)
2769                else:                else:
2770                   res="res"                   res="res"
2771                   text+=mkText(case,"ref",r,r1)                   text+=mkText(case,"ref",r,r1)
2772                if isinstance(r,float):                              if isinstance(r,float):
2773                   text+=mkTypeAndShapeTest(case,(),"res")                   text+=mkTypeAndShapeTest(case,(),"res")
2774                else:                else:
2775                   text+=mkTypeAndShapeTest(case,r.shape,"res")                   text+=mkTypeAndShapeTest(case,r.shape,"res")
2776                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res
2777                  
2778                if case0 in [ "constData","taggedData","expandedData"] and case1 == "Symbol":                if case0 in [ "constData","taggedData","expandedData"] and case1 == "Symbol":
2779                   t_prog_failing+=text                   t_prog_failing+=text
2780                else:                else:
2781                   if case0 == "taggedData" or case1 == "taggedData":                   if case0 == "taggedData" or case1 == "taggedData":
2782                      t_prog_with_tags+=text                      t_prog_with_tags+=text
2783                   else:                                 else:
2784                      t_prog+=text                      t_prog+=text
2785    
2786        
2787  print test_header  print test_header
2788  # print t_prog  # print t_prog
2789  # print t_prog_with_tags  # print t_prog_with_tags
2790  print t_prog_failing  print t_prog_failing
2791  print test_tail            print test_tail
2792  1/0  1/0
2793  #=======================================================================================================  #==============================================================================
2794  # basic binary operations (tests only!)  # basic binary operations (tests only!)
2795  #=======================================================================================================  #==============================================================================
2796  oper_range=[-5.,5.]  oper_range=[-5.,5.]
2797  for oper in [["add" ,"+",[-5.,5.]],  for oper in [["add" ,"+",[-5.,5.]],
2798               ["mult","*",[-5.,5.]],               ["mult","*",[-5.,5.]],
2799               ["quotient" ,"/",[-5.,5.]],               ["quotient" ,"/",[-5.,5.]],
2800               ["power" ,"**",[0.01,5.]]]:               ["power" ,"**",[0.01,5.]]]:
2801     for case0 in case_set:     for case0 in case_set:
2802       for case1 in case_set:       for case1 in case_set:
2803         for sh in shape_set:         for sh in shape_set:
2804           for sh_p in shape_set:           for sh_p in shape_set:
2805             if len(sh_p)>0:             if len(sh_p)>0:
# Line 2810  for oper in [["add" ,"+",[-5.,5.]], Line 2813  for oper in [["add" ,"+",[-5.,5.]],
2813              else:              else:
2814                 sh1=sh                 sh1=sh
2815                 sh0=sh+sh_p                 sh0=sh+sh_p
2816                
2817              if (not case0=="float" or len(sh0)==0) and (not case1=="float" or len(sh1)==0) and \              if (not case0=="float" or len(sh0)==0) and (not case1=="float" or len(sh1)==0) and \
2818                 len(sh0)<5 and len(sh1)<5:                 len(sh0)<5 and len(sh1)<5:
2819                use_tagging_for_expanded_data= case0=="taggedData" or case1=="taggedData"                use_tagging_for_expanded_data= case0=="taggedData" or case1=="taggedData"
# Line 2833  for oper in [["add" ,"+",[-5.,5.]], Line 2836  for oper in [["add" ,"+",[-5.,5.]],
2836                text+=mkText(case0,"arg0",a_0,a1_0,use_tagging_for_expanded_data)                text+=mkText(case0,"arg0",a_0,a1_0,use_tagging_for_expanded_data)
2837                text+=mkText(case1,"arg1",a_1,a1_1,use_tagging_for_expanded_data)                text+=mkText(case1,"arg1",a_1,a1_1,use_tagging_for_expanded_data)
2838                text+="      res=%s(arg0,arg1)\n"%oper[0]                text+="      res=%s(arg0,arg1)\n"%oper[0]
2839                  
2840                case=getResultCaseForBin(case0,case1)                              case=getResultCaseForBin(case0,case1)
2841                if case=="Symbol":                if case=="Symbol":
2842                   c0_res,c1_res=case0,case1                   c0_res,c1_res=case0,case1
2843                   subs="{"                   subs="{"
2844                   if case0=="Symbol":                           if case0=="Symbol":
2845                      text+=mkText("array","s0",a_0,a1_0)                      text+=mkText("array","s0",a_0,a1_0)
2846                      subs+="arg0:s0"                      subs+="arg0:s0"
2847                      c0_res="array"                      c0_res="array"
2848                   if case1=="Symbol":                           if case1=="Symbol":
2849                      text+=mkText("array","s1",a_1,a1_1)                      text+=mkText("array","s1",a_1,a1_1)
2850                      if not subs.endswith("{"): subs+=","                      if not subs.endswith("{"): subs+=","
2851                      subs+="arg1:s1"                      subs+="arg1:s1"
2852                      c1_res="array"                      c1_res="array"
2853                   subs+="}"                     subs+="}"
2854                   text+="      sub=res.substitute(%s)\n"%subs                   text+="      sub=res.substitute(%s)\n"%subs
2855                   res="sub"                   res="sub"
2856                   text+=mkText(getResultCaseForBin(c0_res,c1_res),"ref",r,r1)                   text+=mkText(getResultCaseForBin(c0_res,c1_res),"ref",r,r1)
2857                else:                else:
2858                   res="res"                   res="res"
2859                   text+=mkText(case,"ref",r,r1)                   text+=mkText(case,"ref",r,r1)
2860                if isinstance(r,float):                              if isinstance(r,float):
2861                   text+=mkTypeAndShapeTest(case,(),"res")                   text+=mkTypeAndShapeTest(case,(),"res")
2862                else:                else:
2863                   text+=mkTypeAndShapeTest(case,r.shape,"res")                   text+=mkTypeAndShapeTest(case,r.shape,"res")
2864                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res
2865                  
2866                if case0 == "taggedData" or case1 == "taggedData":                if case0 == "taggedData" or case1 == "taggedData":
2867                    t_prog_with_tags+=text                    t_prog_with_tags+=text
2868                else:                              else:
2869                    t_prog+=text                    t_prog+=text
2870  print test_header  print test_header
2871  # print t_prog  # print t_prog
# Line 2875  for oper in [["add" ,"+",[-5.,5.]], Line 2878  for oper in [["add" ,"+",[-5.,5.]],
2878               ["sub" ,"-",[-5.,5.]],               ["sub" ,"-",[-5.,5.]],
2879               ["mult","*",[-5.,5.]],               ["mult","*",[-5.,5.]],
2880               ["div" ,"/",[-5.,5.]],               ["div" ,"/",[-5.,5.]],
2881               ["pow" ,"**",[0.01,5.]]]:                 ["pow" ,"**",[0.01,5.]]]:
2882     for case0 in case_set:     for case0 in case_set:
2883       for sh0 in shape_set:       for sh0 in shape_set:
2884         for case1 in case_set:         for case1 in case_set:
2885           for sh1 in shape_set:           for sh1 in shape_set:
2886             if (not case0=="float" or len(sh0)==0) and (not case1=="float" or len(sh1)==0) and \             if (not case0=="float" or len(sh0)==0) and (not case1=="float" or len(sh1)==0) and \
2887                 (sh0==() or sh1==() or sh1==sh0) and \                 (sh0==() or sh1==() or sh1==sh0) and \
# Line 2902  for oper in [["add" ,"+",[-5.,5.]], Line 2905  for oper in [["add" ,"+",[-5.,5.]],
2905                text+=mkText(case0,"arg0",a_0,a1_0)                text+=mkText(case0,"arg0",a_0,a1_0)
2906                text+=mkText(case1,"arg1",a_1,a1_1)                text+=mkText(case1,"arg1",a_1,a1_1)
2907                text+="      res=arg0%sarg1\n"%oper[1]                text+="      res=arg0%sarg1\n"%oper[1]
2908                  
2909                case=getResultCaseForBin(case0,case1)                              case=getResultCaseForBin(case0,case1)
2910                if case=="Symbol":                if case=="Symbol":
2911                   c0_res,c1_res=case0,case1                   c0_res,c1_res=case0,case1
2912                   subs="{"                   subs="{"
2913                   if case0=="Symbol":                           if case0=="Symbol":
2914                      text+=mkText("array","s0",a_0,a1_0)                      text+=mkText("array","s0",a_0,a1_0)
2915                      subs+="arg0:s0"                      subs+="arg0:s0"
2916                      c0_res="array"                      c0_res="array"
2917                   if case1=="Symbol":                           if case1=="Symbol":
2918                      text+=mkText("array","s1",a_1,a1_1)                      text+=mkText("array","s1",a_1,a1_1)
2919                      if not subs.endswith("{"): subs+=","                      if not subs.endswith("{"): subs+=","
2920                      subs+="arg1:s1"                      subs+="arg1:s1"
2921                      c1_res="array"                      c1_res="array"
2922                   subs+="}"                     subs+="}"
2923                   text+="      sub=res.substitute(%s)\n"%subs                   text+="      sub=res.substitute(%s)\n"%subs
2924                   res="sub"                   res="sub"
2925                   text+=mkText(getResultCaseForBin(c0_res,c1_res),"ref",r,r1)                   text+=mkText(getResultCaseForBin(c0_res,c1_res),"ref",r,r1)
2926                else:                else:
2927                   res="res"                   res="res"
2928                   text+=mkText(case,"ref",r,r1)                   text+=mkText(case,"ref",r,r1)
2929                if isinstance(r,float):                              if isinstance(r,float):
2930                   text+=mkTypeAndShapeTest(case,(),"res")                   text+=mkTypeAndShapeTest(case,(),"res")
2931                else:                else:
2932                   text+=mkTypeAndShapeTest(case,r.shape,"res")                   text+=mkTypeAndShapeTest(case,r.shape,"res")
2933                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res                text+="      self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res
2934                  
2935                if case0 in [ "constData","taggedData","expandedData"] and case1 == "Symbol":                if case0 in [ "constData","taggedData","expandedData"] and case1 == "Symbol":
2936                   t_prog_failing+=text                   t_prog_failing+=text
2937                else:                else:
2938                   if case0 == "taggedData" or case1 == "taggedData":                   if case0 == "taggedData" or case1 == "taggedData":
2939                      t_prog_with_tags+=text                      t_prog_with_tags+=text
2940                   else:                                 else:
2941                      t_prog+=text                      t_prog+=text
2942    
2943        
2944  # print u_prog  # print u_prog
2945  # 1/0  # 1/0
2946  print test_header  print test_header
# Line 2948  print test_tail Line 2951  print test_tail
2951  # print t_prog_failing  # print t_prog_failing
2952  print test_tail  print test_tail
2953    
2954  #=======================================================================================================  #==============================================================================
2955  # unary operations:  # unary operations:
2956  #=======================================================================================================  #==============================================================================
2957  func= [  func= [
2958  OPERATOR(nickname="log10",\  OPERATOR(nickname="log10",\
2959           rng=[1.e-3,100.],\           rng=[1.e-3,100.],\
2960           test_expr="math.log10(%a1%)",\           test_expr="math.log10(%a1%)",\
2961           math_expr="math.log10(%a1%)",\           math_expr="math.log10(%a1%)",\
2962           numarray_expr="numarray.log10(%a1%)",\           numarray_expr="numarray.log10(%a1%)",\
2963           symbol_expr="log(%a1%)/log(10.)",\           symbol_expr="log(%a1%)/log(10.)",\
2964           name="base-10 logarithm"),                 name="base-10 logarithm"),
2965  OPERATOR(nickname="wherePositive",\  OPERATOR(nickname="wherePositive",\
2966           rng=[-100.,100.],\           rng=[-100.,100.],\
2967           test_expr="wherepos(%a1%)",\           test_expr="wherepos(%a1%)",\
# Line 3058  OPERATOR(nickname="asinh",\ Line 3061  OPERATOR(nickname="asinh",\
3061           math_expr="numarray.arcsinh(%a1%)",           math_expr="numarray.arcsinh(%a1%)",
3062           numarray_expr="numarray.arcsinh(%a1%)",           numarray_expr="numarray.arcsinh(%a1%)",
3063           diff="1./sqrt(%a1%**2+1)",           diff="1./sqrt(%a1%**2+1)",
3064           name="inverse hyperbolic sine"),           name="inverse hyperbolic sine"),
3065  OPERATOR(nickname="acosh",\  OPERATOR(nickname="acosh",\
3066           rng=[1.001,100.],\           rng=[1.001,100.],\
3067           test_expr="numarray.arccosh(%a1%)",           test_expr="numarray.arccosh(%a1%)",
3068           math_expr="numarray.arccosh(%a1%)",           math_expr="numarray.arccosh(%a1%)",
3069           numarray_expr="numarray.arccosh(%a1%)",           numarray_expr="numarray.arccosh(%a1%)",
3070           diff="1./sqrt(%a1%**2-1)",           diff="1./sqrt(%a1%**2-1)",
3071           name="inverse hyperolic cosine"),           name="inverse hyperbolic cosine"),
3072  OPERATOR(nickname="atanh",\  OPERATOR(nickname="atanh",\
3073           rng=[-0.99,0.99], \           rng=[-0.99,0.99], \
3074           test_expr="numarray.arctanh(%a1%)",           test_expr="numarray.arctanh(%a1%)",
# Line 3084  OPERATOR(nickname="sqrt",\ Line 3087  OPERATOR(nickname="sqrt",\
3087           test_expr="math.sqrt(%a1%)",           test_expr="math.sqrt(%a1%)",
3088           numarray_expr="numarray.sqrt(%a1%)",           numarray_expr="numarray.sqrt(%a1%)",
3089           diff="0.5/self",           diff="0.5/self",
3090           name="square root"),           name="square root"),
3091  OPERATOR(nickname="log",    \  OPERATOR(nickname="log",    \
3092           rng=[1.e-3,100.],\           rng=[1.e-3,100.],\
3093           test_expr="math.log(%a1%)",           test_expr="math.log(%a1%)",
# Line 3105  OPERATOR(nickname="abs",\ Line 3108  OPERATOR(nickname="abs",\
3108           numarray_expr="abs(%a1%)",           numarray_expr="abs(%a1%)",
3109           diff="sign(%a1%)",           diff="sign(%a1%)",
3110           name="absolute value")           name="absolute value")
3111            
3112                ]                        ]
3113  for f in func:  for f in func:
3114     symbol_name=f.nickname[0].upper()+f.nickname[1:]     symbol_name=f.nickname[0].upper()+f.nickname[1:]
3115     if f.nickname!="abs":     if f.nickname!="abs":
# Line 3145  for f in func: Line 3148  for f in func:
3148        u_prog+="      @type arg: typically L{Symbol}.\n"        u_prog+="      @type arg: typically L{Symbol}.\n"
3149        u_prog+="      \"\"\"\n"        u_prog+="      \"\"\"\n"
3150        u_prog+="      DependendSymbol.__init__(self,args=[arg],shape=arg.getShape(),dim=arg.getDim())\n"        u_prog+="      DependendSymbol.__init__(self,args=[arg],shape=arg.getShape(),dim=arg.getDim())\n"
3151        u_prog+="\n"          u_prog+="\n"
3152      
3153        u_prog+="   def getMyCode(self,argstrs,format=\"escript\"):\n"        u_prog+="   def getMyCode(self,argstrs,format=\"escript\"):\n"
3154        u_prog+="      \"\"\"\n"        u_prog+="      \"\"\"\n"
3155        u_prog+="      returns a program code that can be used to evaluate the symbol.\n\n"        u_prog+="      returns a program code that can be used to evaluate the symbol.\n\n"
# Line 3165  for f in func: Line 3168  for f in func:
3168        u_prog+="         return \"%s(%%s)\"%%argstrs\n"%f.nickname        u_prog+="         return \"%s(%%s)\"%%argstrs\n"%f.nickname
3169        u_prog+="      else:\n"        u_prog+="      else:\n"
3170        u_prog+="         raise NotImplementedError,\"%s_Symbol does not provide program code for format %%s.\"%%format\n"%symbol_name        u_prog+="         raise NotImplementedError,\"%s_Symbol does not provide program code for format %%s.\"%%format\n"%symbol_name
3171        u_prog+="\n"              u_prog+="\n"
3172    
3173        u_prog+="   def substitute(self,argvals):\n"        u_prog+="   def substitute(self,argvals):\n"
3174        u_prog+="      \"\"\"\n"        u_prog+="      \"\"\"\n"
# Line 3204  for f in func: Line 3207  for f in func:
3207           u_prog+="         val=matchShape(%s,self.getDifferentiatedArguments(arg)[0])\n"%f.diff.replace("%a1%","myarg")           u_prog+="         val=matchShape(%s,self.getDifferentiatedArguments(arg)[0])\n"%f.diff.replace("%a1%","myarg")
3208           u_prog+="         return val[0]*val[1]\n\n"           u_prog+="         return val[0]*val[1]\n\n"
3209    
3210     for case in case_set:     for case in case_set:
3211       for sh in shape_set:       for sh in shape_set:
3212         if not case=="float" or len(sh)==0:         if not case=="float" or len(sh)==0:
3213           text=""           text=""
3214           text+="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"           text+="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
3215           tname="def test_%s_%s_rank%s"%(f.nickname,case,len(sh))           tname="def test_%s_%s_rank%s"%(f.nickname,case,len(sh))
3216           text+="   %s(self):\n"%tname           text+="   %s(self):\n"%tname
3217           a=makeArray(sh,f.rng)                       a=makeArray(sh,f.rng)
3218           a1=makeArray(sh,f.rng)           a1=makeArray(sh,f.rng)
3219           r1=makeResult(a1,f.test_expr)           r1=makeResult(a1,f.test_expr)
3220           r=makeResult(a,f.test_expr)           r=makeResult(a,f.test_expr)
3221            
3222           text+=mkText(case,"arg",a,a1)           text+=mkText(case,"arg",a,a1)
3223           text+="      res=%s(arg)\n"%f.nickname           text+="      res=%s(arg)\n"%f.nickname
3224           if case=="Symbol":                   if case=="Symbol":
3225               text+=mkText("array","s",a,a1)               text+=mkText("array","s",a,a1)
3226               text+="      sub=res.substitute({arg:s})\n"                       text+="      sub=res.substitute({arg:s})\n"
3227               text+=mkText("array","ref",r,r1)               text+=mkText("array","ref",r,r1)
3228               res="sub"               res="sub"
3229           else:           else:
# Line 3232  for f in func: Line 3235  for f in func:
3235             t_prog_with_tags+=text             t_prog_with_tags+=text
3236           else:           else:
3237             t_prog+=text             t_prog+=text
3238              
3239  #=========== END OF GOOD CODE +++++++++++++++++++++++++++        #=========== END OF GOOD CODE +++++++++++++++++++++++++++
3240    
3241  1/0  1/0
3242    
# Line 3257  def X(): Line 3260  def X():
3260                t_prog+="      ref=numarray.array(%s)\n"%r.tolist()                t_prog+="      ref=numarray.array(%s)\n"%r.tolist()
3261             t_prog+="      res=%s(%a1%)\n"%f.nickname             t_prog+="      res=%s(%a1%)\n"%f.nickname
3262             t_prog+="      self.failUnlessEqual(res.shape,%s,\"wrong shape of result.\")\n"%str(sh)             t_prog+="      self.failUnlessEqual(res.shape,%s,\"wrong shape of result.\")\n"%str(sh)
3263             t_prog+="      self.failUnless(Lsup(res-ref)<=self.tol*Lsup(ref),\"wrong result\")\n"                       t_prog+="      self.failUnless(Lsup(res-ref)<=self.tol*Lsup(ref),\"wrong result\")\n"
3264           elif args== "constData":           elif args== "constData":
3265             a=makeArray(sh,f[RANGE])             a=makeArray(sh,f[RANGE])
3266             r=makeResult(a,f)             r=makeResult(a,f)
# Line 3311  def X(): Line 3314  def X():
3314                t_prog+="      ref=numarray.array(%s)\n"%r.tolist()                t_prog+="      ref=numarray.array(%s)\n"%r.tolist()
3315                t_prog+="      self.failUnlessEqual(res.getShape(),%s,\"wrong shape of substitution result.\")\n"%str(sh)                t_prog+="      self.failUnlessEqual(res.getShape(),%s,\"wrong shape of substitution result.\")\n"%str(sh)
3316             t_prog+="      self.failUnless(Lsup(res-ref)<=self.tol*Lsup(ref),\"wrong result\")\n"             t_prog+="      self.failUnless(Lsup(res-ref)<=self.tol*Lsup(ref),\"wrong result\")\n"
3317    
3318             if len(sh)==0:             if len(sh)==0:
3319                 t_prog+="      # test derivative with respect to itself:\n"                 t_prog+="      # test derivative with respect to itself:\n"
3320                 t_prog+="      dvdv=v.diff(v)\n"                 t_prog+="      dvdv=v.diff(v)\n"
# Line 3340  def X(): Line 3343  def X():
3343                           else:                           else:
3344                              v=0.                              v=0.
3345                           t_prog+="      self.failUnlessEqual(dvdv[%s,%s,%s,%s],%s,\"derivative with respect to self: [%s,%s,%s,%s] is not %s\")\n"%(i0_l,i1_l,i0_r,i1_r,v,i0_l,i1_l,i0_r,i1_r,v)                           t_prog+="      self.failUnlessEqual(dvdv[%s,%s,%s,%s],%s,\"derivative with respect to self: [%s,%s,%s,%s] is not %s\")\n"%(i0_l,i1_l,i0_r,i1_r,v,i0_l,i1_l,i0_r,i1_r,v)
3346    
3347             for sh_in in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:             for sh_in in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:
3348               if len(sh_in)+len(sh)<=4:               if len(sh_in)+len(sh)<=4:
3349    
# Line 3584  for case in range(len(cases)): Line 3587  for case in range(len(cases)):
3587                 t_prog+="      s=%sSymbol(dim=self.functionspace)\n"%(cases[case])                 t_prog+="      s=%sSymbol(dim=self.functionspace)\n"%(cases[case])
3588                 t_prog+="      d=self.functionspace.getDim()\n"                 t_prog+="      d=self.functionspace.getDim()\n"
3589                 sh="("                 sh="("
3590                 for i in range(case):                 for i in range(case):
3591                   if i==0:                   if i==0:
3592                    sh+=d                    sh+=d
3593                   else:                   else:
3594                    sh+=","+d                                  sh+=","+d
3595                 sh+=")"                 sh+=")"
3596              else:              else:
3597                 t_prog+="      s=%sSymbol(dim=%s)\n"%(cases[case],d)                 t_prog+="      s=%sSymbol(dim=%s)\n"%(cases[case],d)
# Line 3598  for case in range(len(cases)): Line 3601  for case in range(len(cases)):
3601              t_prog+="      self.failUnlessEqual(s.getShape(),%s,\"wrong shape.\")\n"%str(sh)              t_prog+="      self.failUnlessEqual(s.getShape(),%s,\"wrong shape.\")\n"%str(sh)
3602              t_prog+="      self.failUnlessEqual(s.getDim(),%s,\"wrong spatial dimension.\")\n"%d              t_prog+="      self.failUnlessEqual(s.getDim(),%s,\"wrong spatial dimension.\")\n"%d
3603              t_prog+="      self.failUnlessEqual(s.getArgument(),[],\"wrong arguments.\")\n"              t_prog+="      self.failUnlessEqual(s.getArgument(),[],\"wrong arguments.\")\n"
3604            
3605  print t_prog              print t_prog
3606  1/0  1/0
3607  for sh in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:  for sh in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:
3608    for d in [ None , "domain", 1, 2 , 3]:    for d in [ None , "domain", 1, 2 , 3]:
# Line 3618  for sh in [ (),(2,), (4,5), (6,2,2),(3,2 Line 3621  for sh in [ (),(2,), (4,5), (6,2,2),(3,2
3621           else:           else:
3622              t_prog+="      s=Symbol(shape=%s,dim=%s,args=%s)\n"%(sh,d,a)              t_prog+="      s=Symbol(shape=%s,dim=%s,args=%s)\n"%(sh,d,a)
3623              d2=str(d)              d2=str(d)
3624          
3625           t_prog+="      self.failUnlessEqual(s.getRank(),%s,\"wrong rank.\")\n"%len(sh)           t_prog+="      self.failUnlessEqual(s.getRank(),%s,\"wrong rank.\")\n"%len(sh)
3626           t_prog+="      self.failUnlessEqual(s.getShape(),%s,\"wrong shape.\")\n"%str(sh)           t_prog+="      self.failUnlessEqual(s.getShape(),%s,\"wrong shape.\")\n"%str(sh)
3627           t_prog+="      self.failUnlessEqual(s.getDim(),%s,\"wrong spatial dimension.\")\n"%d2           t_prog+="      self.failUnlessEqual(s.getDim(),%s,\"wrong spatial dimension.\")\n"%d2
# Line 3629  for sh in [ (),(2,), (4,5), (6,2,2),(3,2 Line 3632  for sh in [ (),(2,), (4,5), (6,2,2),(3,2
3632    
3633           t_prog+="      try:\n        s.substitute({s:numarray.zeros((5,))})\n        fail(\"illegal substition was successful\")\n"           t_prog+="      try:\n        s.substitute({s:numarray.zeros((5,))})\n        fail(\"illegal substition was successful\")\n"
3634           t_prog+="      except TypeError:\n        pass\n\n"           t_prog+="      except TypeError:\n        pass\n\n"
3635            
3636           ###           ###
3637           for sh2 in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:           for sh2 in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:
3638               if len(sh+sh2)<5:               if len(sh+sh2)<5:
3639                   t_prog+="      dsdarg=s.diff(Symbol(shape=%s))\n"%str(sh2)                   t_prog+="      dsdarg=s.diff(Symbol(shape=%s))\n"%str(sh2)
3640                   if  len(sh+sh2)==0:                   if  len(sh+sh2)==0:
3641                      t_prog+="      self.failUnless(isinstance(dsdarg,float),\"ds/ds() has wrong type.\")\n"                      t_prog+="      self.failUnless(isinstance(dsdarg,float),\"ds/ds() has wrong type.\")\n"
3642                   else:                           else:
3643                      t_prog+="      self.failUnless(isinstance(dsdarg,numarray.NumArray),\"ds/ds%s has wrong type.\")\n"%str(sh2)                      t_prog+="      self.failUnless(isinstance(dsdarg,numarray.NumArray),\"ds/ds%s has wrong type.\")\n"%str(sh2)
3644                      
3645                      t_prog+="      self.failUnlessEqual(dsdarg.shape,%s,\"ds/ds%s has wrong shape.\")\n"%(str(sh+sh2),str(sh2))                      t_prog+="      self.failUnlessEqual(dsdarg.shape,%s,\"ds/ds%s has wrong shape.\")\n"%(str(sh+sh2),str(sh2))
3646                   t_prog+="      self.failIf(Lsup(dsdarg)>0.,\"ds/ds%s has wrong value.\")\n"%str(sh2)                   t_prog+="      self.failIf(Lsup(dsdarg)>0.,\"ds/ds%s has wrong value.\")\n"%str(sh2)
3647           if len(sh)<3:           if len(sh)<3:
# Line 3646  for sh in [ (),(2,), (4,5), (6,2,2),(3,2 Line 3649  for sh in [ (),(2,), (4,5), (6,2,2),(3,2
3649              if  len(sh)==0:              if  len(sh)==0:
3650                 t_prog+="      self.failUnless(isinstance(dsds,float),\"ds/ds has wrong type.\")\n"                 t_prog+="      self.failUnless(isinstance(dsds,float),\"ds/ds has wrong type.\")\n"
3651                 t_prog+="      self.failUnlessEqual(dsds,1.,\"ds/ds has wrong value.\")\n"                 t_prog+="      self.failUnlessEqual(dsds,1.,\"ds/ds has wrong value.\")\n"
3652              else:                      else:
3653                 t_prog+="      self.failUnless(isinstance(dsds,numarray.NumArray),\"ds/ds has wrong type.\")\n"                 t_prog+="      self.failUnless(isinstance(dsds,numarray.NumArray),\"ds/ds has wrong type.\")\n"
3654                 t_prog+="      self.failUnlessEqual(dsds.shape,%s,\"ds/ds has wrong shape.\")\n"%str(sh+sh)                 t_prog+="      self.failUnlessEqual(dsds.shape,%s,\"ds/ds has wrong shape.\")\n"%str(sh+sh)
3655                 if len(sh)==1:                 if len(sh)==1:
3656                     for i0 in range(sh[0]):                     for i0 in range(sh[0]):
# Line 3667  for sh in [ (),(2,), (4,5), (6,2,2),(3,2 Line 3670  for sh in [ (),(2,), (4,5), (6,2,2),(3,2
3670                                 else:                                 else:
3671                                      v=0.                                      v=0.
3672                                 t_prog+="      self.failUnlessEqual(dsds[%s,%s,%s,%s],%s,\"ds/ds has wrong value at (%s,%s,%s,%s).\")\n"%(i0,i1,i2,i3,v,i0,i1,i2,i3)                                 t_prog+="      self.failUnlessEqual(dsds[%s,%s,%s,%s],%s,\"ds/ds has wrong value at (%s,%s,%s,%s).\")\n"%(i0,i1,i2,i3,v,i0,i1,i2,i3)
3673                
3674           ###               ###
3675           t_prog+="\n"               t_prog+="\n"
3676           for i in range(len(args)):           for i in range(len(args)):
3677               t_prog+="      self.failUnlessEqual(s.getArgument(%s),%s,\"wrong argument %s.\")\n"%(i,str(args[i]),i)               t_prog+="      self.failUnlessEqual(s.getArgument(%s),%s,\"wrong argument %s.\")\n"%(i,str(args[i]),i)
3678           t_prog+="      sa=s.getSubstitutedArguments({s2:-10})\n"           t_prog+="      sa=s.getSubstitutedArguments({s2:-10})\n"
# Line 3679  for sh in [ (),(2,), (4,5), (6,2,2),(3,2 Line 3682  for sh in [ (),(2,), (4,5), (6,2,2),(3,2
3682           else:           else:
3683               for i in range(len(args)):               for i in range(len(args)):
3684                  t_prog+="      self.failUnlessEqual(sa[%s],%s,\"wrongly substituted argument %s.\")\n"%(i,str(args[i]),i)                  t_prog+="      self.failUnlessEqual(sa[%s],%s,\"wrongly substituted argument %s.\")\n"%(i,str(args[i]),i)
3685            
3686           t_prog+="\n"           t_prog+="\n"
3687           for arg in ["10.", "10", "SymbolMatch", "SymbolMisMatch", \           for arg in ["10.", "10", "SymbolMatch", "SymbolMisMatch", \
3688                                         "DataMatch","DataMisMatch", "NumArrayMatch", "NumArrayMisMatch"]:                                         "DataMatch","DataMisMatch", "NumArrayMatch", "NumArrayMisMatch"]:
# Line 3713  print t_prog Line 3716  print t_prog
3716    
3717    
3718  for case in ["Lsup", "sup", "inf"]:  for case in ["Lsup", "sup", "inf"]:
3719     for args in ["float","array","constData","taggedData","expandedData"]:     for args in ["float","array","constData","taggedData","expandedData"]:
3720       for sh in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:       for sh in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:
3721         if not args=="float" or len(sh)==0:         if not args=="float" or len(sh)==0:
3722           t_prog+="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"           t_prog+="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
# Line 3771  print t_prog Line 3774  print t_prog
3774    
3775  1/0  1/0
3776    
3777            
3778  for case in ["Lsup", "sup", "inf"]:  for case in ["Lsup", "sup", "inf"]:
3779     for args in ["float","array","constData","taggedData","expandedData"]:     for args in ["float","array","constData","taggedData","expandedData"]:
3780       for sh in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:       for sh in [ (),(2,), (4,5), (6,2,2),(3,2,3,4)]:
3781         if not args=="float" or len(sh)==0:         if not args=="float" or len(sh)==0:
3782           t_prog+="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"           t_prog+="   #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
# Line 3830  for case in ["Lsup", "sup", "inf"]: Line 3833  for case in ["Lsup", "sup", "inf"]:
3833  print t_prog  print t_prog
3834    
3835  1/0  1/0
3836    

Legend:
Removed from v.1388  
changed lines
  Added in v.2169

  ViewVC Help
Powered by ViewVC 1.1.26