Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/ein16/synth/d2/fold.py
ViewVC logotype

Diff of /branches/ein16/synth/d2/fold.py

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

revision 4482, Thu Sep 1 20:43:01 2016 UTC revision 4483, Fri Sep 2 05:07:01 2016 UTC
# Line 1  Line 1 
1  import sys  import sys
2  import re  import re
3  import os  import os
4    import time
5    
6  from obj_apply import *  from obj_apply import *
7  from obj_ex import  *  from obj_ex import  *
# Line 27  Line 28 
28      n = len(es)      n = len(es)
29      l = pre+" length: "+str(n)+" : "      l = pre+" length: "+str(n)+" : "
30      for i in es:      for i in es:
31          l+=fty.toStr(i)+","          if(i==None):
32      print l              l+=" None,"
33            else:
34                l+=(i.name)+","
35        #print l
36    
37    
38    
# Line 38  Line 42 
42  # ty1 : types with specific shapes (ty_vecFT, ty_vecF_d1..)  # ty1 : types with specific shapes (ty_vecFT, ty_vecF_d1..)
43  # exp1: specific types on ty1s list ^  # exp1: specific types on ty1s list ^
44    
45  # inner operation is binary  def core_ops(exps, dim, tshape1, tshape2, opr_inner, opr_outer, title, testing_frame, cnt):
 # outer operation is unary  
 def core_binary_unary(exp1, exp2, dim, tshape1, tshape2, opr_inner, opr_outer, title, testing_frame, cnt):  
     print "\n--------------------------- core_binary_unary  ---------------------------"  
46      # can apply (shape1*shape2)* shape3 ->tshape2      # can apply (shape1*shape2)* shape3 ->tshape2
47      # assuming shape_to_fty() is ordered by dimension      # assuming shape_to_fty() is ordered by dimension
48      counter.inc_total(cnt)      counter.inc_total(cnt)
     print "dim", dim  
     exps =  [exp1,  exp2]  
49      convert_fields(exps, testing_frame)      convert_fields(exps, testing_frame)
     #tshape2 = convert_rst_unary(tshape1, tshape2_shape, dim)  
     #print "   tshape2 ",   tshape2.name, fty.toStr(  tshape2 )  
50      create_embed_app_passed(exps, tshape1, tshape2, opr_inner, opr_outer, title, testing_frame, cnt)      create_embed_app_passed(exps, tshape1, tshape2, opr_inner, opr_outer, title, testing_frame, cnt)
51      return      return
52    
53    
54    
55  # both operations are binary so there are three expressions  # inner operation is binary
56  # we have three expressions in function  # outer operation is unary
57  def core_binary_binary(exp1, exp2, exp3, dim, tshape1, tshape2_shape, opr_inner, opr_outer, title, testing_frame, cnt):  def core_binary_unary(exp1, exp2, dim, tshape1, tshape2, opr_inner, opr_outer, title, testing_frame, cnt):
58      print "\n---------------------------core_binary_binary ---------------------------"      #print "\n--------------------------- core_binary_unary  ---------------------------"
59      # can apply (shape1*shape2)* shape3 ->tshape2      exps =  [exp1,  exp2]
60      # assuming shape_to_fty() is ordered by dimension      core_ops(exps, dim, tshape1, tshape2, opr_inner, opr_outer, title, testing_frame, cnt)
     counter.inc_total(cnt)  
     #print "dim", dim  
     exps =  [exp1,  exp2,  exp3]  
     convert_fields(exps, testing_frame)  
     tshape2 = convert_rst_binary(tshape1, exp3, tshape2_shape, dim)  
     #print "   tshape2 ",   tshape2.name, fty.toStr(  tshape2 )  
     create_embed_app_passed(exps, tshape1, tshape2, opr_inner, opr_outer, title, testing_frame, cnt)  
61      return      return
62    
63    
64  ##################################################################################################  ##################################################################################################
65  ##################################################################################################  ##################################################################################################
66    
67  # all of the type choosing split into multiple function  # all of the type choosing split into multiple function
68  # iterate over third type  # iterate over third type
69  def pick_ty_to_exp3(exp1, exp2, dim, ty3s, tshape1, tshape2_shape, opr_inner, opr_outer, title, testing_frame, cnt):  def pick_ty_to_exp3(exps, dim, ty3s, tshape1, tshape2_shape, opr_inner, opr_outer, title, testing_frame, cnt):
70      # terating over tyes that are possible      # terating over tyes that are possible
71      print "\n---------------------------pick_third_type ---------------------------"      #print "\n---------------------------pick_third_type ---------------------------"
72      # can apply (shape1*shape2)* shape3 ->tshape2      # can apply (shape1*shape2)* shape3 ->tshape2
73      # assuming shape_to_fty() is ordered by dimension      # assuming shape_to_fty() is ordered by dimension
74      [t3, f3d1, f3d2, f3d3] = ty3s      [t3, f3d1, f3d2, f3d3] = ty3s
   
     #m="\n\t**** Types: ("+exp1.name+","+exp2.name+")"  
     #writenow(m)  
   
   
75      # now get exp3      # now get exp3
76      def instance(exp3, dim):      def instance(exp3, dim):
77          if(exp3 == None):          if(exp3 == None):
78              return              return
79          else:          else:
80              exps = [exp1, exp2, exp3]              t = exps+[exp3]
81              return core_binary_binary(exp1, exp2, exp3, dim, tshape1, tshape2_shape, opr_inner, opr_outer, title, testing_frame, cnt)              #print "tshape1:", tshape1, "tshape2_shape:",tshape2_shape
82                tshape2 = convert_rst_binary(tshape1, exp3, tshape2_shape, dim)
83                if(not(tshape2 == None)):
84                    # both operations are binary so there are three expressions
85                    core_ops(t, dim, tshape1, tshape2, opr_inner, opr_outer, title, testing_frame, cnt)
86                    return
87      if(dim==0):      if(dim==0):
88          # tensors for exp1,exp2          # tensors for exp1,exp2
89          for exp3 in ty3s:          for exp3 in ty3s:
# Line 105  Line 96 
96              instance(exp3, dim)              instance(exp3, dim)
97          return          return
98    
99  # iterate over third type  
100    #opr_inner arity == 2,  opr_outer.arity == _
101  def pick_ty_to_exp2(exp1, dim, ty2s, ty3s, tshape1_shape, tshape2_shape, opr_inner, opr_outer, title, testing_frame, cnt):  def pick_ty_to_exp2(exp1, dim, ty2s, ty3s, tshape1_shape, tshape2_shape, opr_inner, opr_outer, title, testing_frame, cnt):
102      # terating over tyes that are possible      # terating over tyes that are possible
103      #writeCumulative(cnt)      #writeCumulative(cnt)
104      print "\n---------------------------pick_second_type ---------------------------"      #print "\n---------------------------pick_second_type ---------------------------"
105      #m = title + "Types: ("+exp1.name+", _)"      #m = title + "Types: ("+exp1.name+", _)"
106      #writenow(m)      #writenow(m)
107      title = ""      title = ""
# Line 124  Line 116 
116              return              return
117          else:          else:
118              # current dim: dimension should be based on exp1*exp2              # current dim: dimension should be based on exp1*exp2
119              print "  mark: convert_rst_binary"              #print "  mark: convert_rst_binary"
120              tshape1 = convert_rst_binary(exp1, exp2, tshape1_shape, dim)              tshape1 = convert_rst_binary(exp1, exp2, tshape1_shape, dim)
121                if(not (tshape1==None)):
122               # then we iterate over tys3s               # then we iterate over tys3s
123              if (opr_outer.arity == 2):              if (opr_outer.arity == 2):
124                         # opr_outer.arity == 2, opr_inner arity == 2
125    
126                  # so then we do iterate over tys3s                  # so then we do iterate over tys3s
127                  pick_ty_to_exp3(exp1, exp2, dim, ty3s, tshape1, tshape2_shape, opr_inner, opr_outer, title, testing_frame, cnt)                      exps = [exp1, exp2]
128                        pick_ty_to_exp3(exps, dim, ty3s, tshape1, tshape2_shape, opr_inner, opr_outer, title, testing_frame, cnt)
129              else:              else:
130                    # opr_outer.arity == 1,opr_inner arity == 2
131    
132                   # third type not needed                   # third type not needed
133                   ## need to check actual expression                   ## need to check actual expression
134                  print "  mark: check_tshape"                   #print "  mark: check_tshape"
135                  print "pre",tshape1,"op1",opr_outer.name                   #print "pre",tshape1,"op1",opr_outer.name
136                  # converts shape to type (tshape2_shape)                  # converts shape to type (tshape2_shape)
137                  # check to see if it is expression (tshape1) is a  differentiable field (if needed)                  # check to see if it is expression (tshape1) is a  differentiable field (if needed)
138                  tshape2 = check_tshape(opr_outer,  tshape1, tshape2_shape, dim)                  tshape2 = check_tshape(opr_outer,  tshape1, tshape2_shape, dim)
139                  if(tshape2 == None):                  if(not(tshape2 == None)):
140                      print "can not be differentiated"                      #print "can not be differentiated"
141                        # go straigh to core
142                        #print "dim", dim, "post",tshape1.name
143                        core_binary_unary(exp1, exp2, dim, tshape1, tshape2, opr_inner, opr_outer, title, testing_frame, cnt)
144    
145        # run multiple instance
146        def iter(exp2s, dim):
147            # [tensor, field,_]
148            for exp2 in exp2s:
149                instance(exp2, dim)
150        # choose t1 as first argument
151        if(dim==0):
152            # [tensor,_, _]
153            # [tensor, tensor,_]
154            exp2 = t2
155            instance(exp2, dim)
156            # [tensor, field,_]
157            # create second field type
158            for d in range(3):
159                d+=1
160                exp2 = ty2s[d]
161                instance(exp2, d)
162        else:
163            #[field, _,_]
164            exp2s = [t2, ty2s[dim]]
165            iter(exp2s, dim)
166    
167    
168    ##################################################################################################
169    # iterate over third type
170    def backwards_ty_to_exp2(exp1, dim, ty2s, tshape1, tshape2, opr_inner, opr_outer, title, testing_frame, cnt):
171        # terating over tyes that are possible
172        #writeCumulative(cnt)
173        #print "\n---------------------------pick_second_type ---------------------------"
174        #m = title + "Types: ("+exp1.name+", _)"
175        #writenow("Types: ("+exp1.name+", _)")
176        title = ""
177        # can apply (shape1*shape2)* shape3 ->tshape2
178        # assuming shape_to_fty() is ordered by dimension
179        [t2, f2d1, f2d2, f2d3] = ty2s
180        #print "t2:",t2, "f2d1",f2d1
181        # run single instance
182        def instance(exp2, dim):
183            if(exp2 == None):
184                      return                      return
185                  else:                  else:
186                      print "mark-else"              #print "\n\t exp2"+exp2.name
                     # go straigh to core  
                     print "dim", dim, "post",tshape1.name  
187                      core_binary_unary(exp1, exp2, dim, tshape1, tshape2, opr_inner, opr_outer, title, testing_frame, cnt)                      core_binary_unary(exp1, exp2, dim, tshape1, tshape2, opr_inner, opr_outer, title, testing_frame, cnt)
188                      return                      return
189    
# Line 153  Line 191 
191      def iter(exp2s, dim):      def iter(exp2s, dim):
192          # [tensor, field,_]          # [tensor, field,_]
193          for exp2 in exp2s:          for exp2 in exp2s:
194                #print "\n\t exp2-attempt"
195              instance(exp2, dim)              instance(exp2, dim)
196      # choose t1 as first argument      # choose t1 as first argument
197      if(dim==0):      if(dim==0):
198            #print "dim=0"
199          # [tensor,_, _]          # [tensor,_, _]
200          # [tensor, tensor,_]          # [tensor, tensor,_]
201          exp2 = t2          exp2 = t2
# Line 168  Line 208 
208              instance(exp2, d)              instance(exp2, d)
209      else:      else:
210          #[field, _,_]          #[field, _,_]
211            #print "dimmorethan 0"
212          exp2s = [t2, ty2s[dim]]          exp2s = [t2, ty2s[dim]]
213          iter(exp2s, dim)          iter(exp2s, dim)
214    
215    def backwards_ty_to_exp1(ty1s, dim, exp2, tshape1, tshape2, opr_inner, opr_outer, title, testing_frame, cnt):
216        # terating over tyes that are possible
217        #writeCumulative(cnt)
218        #print "\n---------------------------pick_second_type ---------------------------"
219        #m = title + "Types: ("+exp1.name+", _)"
220        #writenow(m)
221        title = ""
222        # can apply (shape1*shape2)* shape3 ->tshape2
223        # assuming shape_to_fty() is ordered by dimension
224        [t2, f2d1, f2d2, f2d3] = ty1s
225    
226        # run single instance
227        def instance(exp1, dim):
228            if(exp1 == None):
229                return
230            else:
231                core_binary_unary(exp1, exp2, dim, tshape1, tshape2, opr_inner, opr_outer, title, testing_frame, cnt)
232                return
233    
234        # run multiple instance
235        def iter(exp1s, dim):
236            # [tensor, field,_]
237            for exp1 in exp1s:
238                instance(exp1, dim)
239            # choose t1 as first argument
240        if(dim==0):
241            # [tensor,_, _]
242            # [tensor, tensor,_]
243            exp1 = t2
244            instance(exp1, dim)
245            # [tensor, field,_]
246            # create second field type
247            for d in range(3):
248                d+=1
249                exp2 = ty1s[d]
250                instance(exp1, d)
251        else:
252            #[field, _,_]
253            exp1s = [t2, ty1s[dim]]
254            iter(exp1s, dim)
255    
256    
257    
258    ##################################################################################################
259  # iterate over third type  # iterate over third type
260  def pick_ty_to_exp1(ty1s, ty2s, ty3s, tshape1_shape, tshape2_shape, opr_inner, opr_outer, title, testing_frame, cnt):  def pick_ty_to_exp1(ty1s, ty2s, ty3s, tshape1_shape, tshape2_shape, opr_inner, opr_outer, title, testing_frame, cnt):
261      # terating over tyes that are possible      # terating over tyes that are possible
262      #writeCumulative(cnt)      #writeCumulative(cnt)
263      print "\n---------------------------pick_first_type ---------------------------"      #print "\n---------------------------pick_first_type ---------------------------"
264      # can apply (shape1*shape2)* shape3 ->tshape2      # can apply (shape1*shape2)* shape3 ->tshape2
265      # assuming shape_to_fty() is ordered by dimension      # assuming shape_to_fty() is ordered by dimension
266      dim = 0      dim = 0
267      for exp1 in ty1s:      for exp1 in ty1s:
268           #[t1, f1d1, f1d2, f1d3] = ty1s           #[t1, f1d1, f1d2, f1d3] = ty1s
269          if(exp1 == None):          if(not(exp1 == None)):
             continue  
         else:  
270              # expressions must be created              # expressions must be created
271              pick_ty_to_exp2(exp1, dim, ty2s, ty3s, tshape1_shape, tshape2_shape, opr_inner, opr_outer, title, testing_frame, cnt)              pick_ty_to_exp2(exp1, dim, ty2s, ty3s, tshape1_shape, tshape2_shape, opr_inner, opr_outer, title, testing_frame, cnt)
272              dim+=1              dim+=1
# Line 201  Line 284 
284          #print "-------------"          #print "-------------"
285          tmp = ""          tmp = ""
286          tmp = title+ " * "+shape3.name+")"          tmp = title+ " * "+shape3.name+")"
287          writenow("\n\t---Shape3:("+tmp)          #writenow("\n\t---Shape3:("+tmp)
288          #writenow("\n shape3: "+shape3.name+"  tshape2_shape: "+tshape2_shape.name)          #writenow("\n shape3: "+shape3.name+"  tshape2_shape: "+tshape2_shape.name)
289          # convert shape to type          # convert shape to type
290          ty3s = shape_to_fty(shape3)          ty3s = shape_to_fty(shape3)
# Line 217  Line 300 
300    
301  # main function  # main function
302  def pick_get_ty2s(ty1s, rtn2s, opr_inner, opr_outer, title, testing_frame, cnt):  def pick_get_ty2s(ty1s, rtn2s, opr_inner, opr_outer, title, testing_frame, cnt):
303      print " --------------second  time---------------"      # print " --------------second  time---------------"
304      print  "opr_inner:", opr_inner.name, "opr_outer:", opr_outer.name      # print  "opr_inner:", opr_inner.name, "opr_outer:", opr_outer.name
305      titlec ="\n\t"      titlec ="\n\t"
306    
307      for (shape2, tshape1_shape) in rtn2s:      for (shape2, tshape1_shape) in rtn2s:
# Line 227  Line 310 
310          ty2s = shape_to_fty(shape2)          ty2s = shape_to_fty(shape2)
311          # pes("ty2s", ty2s)          # pes("ty2s", ty2s)
312          tmp = title+ " * "+shape2.name+")"          tmp = title+ " * "+shape2.name+")"
313          writenow("\n\t--Shape2:("+tmp)          #writenow("\n\t--Shape2:("+tmp)
314          # Do we need  a third type?          # Do we need  a third type?
315          if (opr_outer.arity == 2):          if (opr_outer.arity == 2):
316              # yes if outer operation is binary              # yes if outer operation is binary
317              rtn3s = op_to_shape(opr_outer, tshape1_shape)              rtn3s = op2_to_shape(opr_outer, tshape1_shape)
318              if (len(rtn3s)>0):              if (len(rtn3s)>0):
319                  pick_get_ty3s(ty1s, ty2s, rtn3s, tshape1_shape, opr_inner, opr_outer, tmp, testing_frame, cnt)                  pick_get_ty3s(ty1s, ty2s, rtn3s, tshape1_shape, opr_inner, opr_outer, tmp, testing_frame, cnt)
320              else:              else:
# Line 240  Line 323 
323          else:          else:
324              # outer operation is a unary              # outer operation is a unary
325              tshape2_shape = op1_to_shape(opr_outer, tshape1_shape)              tshape2_shape = op1_to_shape(opr_outer, tshape1_shape)
326                if(not (tshape2_shape == None)):
327              ty3s = None              ty3s = None
328              pick_ty_to_exp1(ty1s, ty2s, ty3s, tshape1_shape, tshape2_shape, opr_inner, opr_outer, titlec, testing_frame, cnt)              pick_ty_to_exp1(ty1s, ty2s, ty3s, tshape1_shape, tshape2_shape, opr_inner, opr_outer, titlec, testing_frame, cnt)
329      return      return
330    
331      #(opr_outer.arity == 1 and opr_inner.arity == 1)
332    def iter_unary_unary(ty1s, shape1, opr_inner, opr_outer, title, testing_frame, cnt):
333        tshape1_shape = op1_to_shape(opr_inner, shape1)
334        # print "opr_outer.arity == 1 and opr_inner.arity == 1"
335        if(not (tshape1_shape == None)):
336            #apply unary
337            tshape2_shape = op1_to_shape(opr_outer, tshape1_shape)
338            if(not (tshape2_shape == None)):
339                # single argument
340                for exp1 in ty1s:
341                    if(not (exp1==None)):
342                        tshape1 = check_tshape(opr_inner, exp1, tshape1_shape, exp1.dim)
343                        if(not (tshape1 == None)):
344                            dim = tshape1.dim
345                            tshape2 = check_tshape(opr_inner, tshape1,  tshape2_shape, dim)
346                            if(not (tshape2 == None)):
347                                exps = [exp1]
348                                core_ops(exps, dim, tshape1, tshape2, opr_inner, opr_outer, title, testing_frame, cnt)
349    
350      #(opr_outer.arity == 2 and opr_inner.arity == 1)
351    def iter_binary_unary(ty1s, shape1, opr_inner, opr_outer, title, testing_frame, cnt):
352        #(opr_outer.arity == 2 and opr_inner.arity == 1)
353        # print "binary_unary opr_inner.arity == 1 and pr_outer.arity == 2 "
354        # apply unary
355        #pes("ty1s",ty1s)
356        #print " shape1: ", shape1.name
357        tshape1_shape = op1_to_shape(opr_inner, shape1)
358        #print "tshape1_shap:",tshape1_shape.name
359        if(not (tshape1_shape == None)):
360            #apply binary
361            rtn3s = op2_to_shape(opr_outer, tshape1_shape)
362            #print "rtn3s:",len(rtn3s)
363            for (shape3, tshape2_shape) in rtn3s:
364                # convert shape to type
365                ty3s = shape_to_fty(shape3)
366                #pes("ty3s",ty3s)
367                # single argument
368                if ((len(ty3s)>0) and  (len(ty1s)>0)):
369                    for exp1 in ty1s:
370                        if(not (exp1==None)):
371                            dim = exp1.dim
372                            exps = [exp1]
373                            tshape1 = check_tshape(opr_inner,  exp1, tshape1_shape, dim)
374                            if(not (tshape1 == None)):
375                                pick_ty_to_exp3(exps, dim, ty3s, tshape1, tshape2_shape, opr_inner, opr_outer, title, testing_frame, cnt)
376    
377    
378    
379    
380  # main function  # main function
381  def pick_get_ty1s(shape1, opr_inner, opr_outer, testing_frame, cnt):  def pick_get_ty1s(shape1, opr_inner, opr_outer, testing_frame, cnt):
382      # apply operation a first time      # apply operation a first time
383      print " --------------first time---------------"      #print " --------------first time---------------"
384      print  "opr_inner:", opr_inner.name, "opr_outer:", opr_outer.name      #print  "\t\topr_inner:", opr_inner.name, opr_inner.arity,"\n\topr_outer:", opr_outer.name,opr_outer.arity
385      ty1s = shape_to_fty(shape1)      ty1s = shape_to_fty(shape1)
386      title = "("+shape1.name      title = "("+shape1.name
387      writenow("\n-Shape1:"+title+" * _)")      #writenow("\n-Shape1:"+title+" * _)")
388        #print "pick_get_ty1s","shape1",shape1.name
389      #pes("ty1s",ty1s)      #pes("ty1s",ty1s)
390      print "attempt:"+opr_inner.name+"shape1", shape1.name      #print "attempt:"+opr_inner.name+"shape1", shape1.name
391      rtn2s = op_to_shape(opr_inner, shape1)      if(opr_inner.arity == 1 and opr_outer.arity == 1): # arity is 1
392            iter_unary_unary(ty1s, shape1, opr_inner, opr_outer, title, testing_frame, cnt)
393        elif(opr_outer.arity == 2 and opr_inner.arity == 1):
394            iter_binary_unary(ty1s, shape1, opr_inner, opr_outer, title, testing_frame, cnt)
395        else:
396            rtn2s = op2_to_shape(opr_inner, shape1)
397      if (len(rtn2s)>0):      if (len(rtn2s)>0):
         print "rtn2-here"  
         print "rtn2s", rtn2s  
398          pick_get_ty2s(ty1s, rtn2s, opr_inner, opr_outer, title, testing_frame, cnt)          pick_get_ty2s(ty1s, rtn2s, opr_inner, opr_outer, title, testing_frame, cnt)
399      else:      else:
400          return          return
401      return      return
402    ##################################################################################################
403    
404    # go backwards
405    def go_backwards(opr_outer, opr_inner, testing_frame, cnt):
406        rst2  =  expected_inshape(opr_outer)
407        # assumes binary outer
408        # assume unary inner
409        for  (tshape1, tshape2) in rst2:
410            # (_,_)-> tshape
411            dim = tshape2.dim
412            # set one of the expressions to be a field
413            ty1s = d_tofield(dim)
414             # (exp1, _)-> tshapes
415             # print "##############################"
416            # print "dim: ", dim, "tshape1:",tshape1.name, "tshape2:",tshape2.name
417            # arity is 2
418            for exp  in ty1s:
419                # needs to find 2nd argument
420                #print "#############"
421                #print "exp:",exp.name
422                exp1 = exp
423                shape2 = backwards_op2_arg1(opr_inner, tshape1, exp1)
424                if(not(shape2==None)):
425                    title= "\t\tex.(exp1:"+exp1.name+", shape2:"+shape2.name+")-> "+tshape2.name
426                    #print(title)
427                    # convert shape to type
428                    ty2s = shape_to_fty(shape2)
429                    #print "(shape2",shape2.name,"ty2s",ty2s
430                    backwards_ty_to_exp2(exp1, dim, ty2s, tshape1, tshape2, opr_inner, opr_outer, title, testing_frame, cnt)
431                exp2 = exp
432                shape1 = backwards_op2_arg2(opr_inner, tshape1, exp1)
433                if(not (shape1==None)):
434                    title= "\t\tex.(shape1:"+shape1.name+", exp2:"+exp2.name+")-> "+tshape2.name
435                    #print(title)
436                    # convert shape to type
437                    # gets duplicated
438                    #ty1s = shape_to_fty(shape1)
439                    #backwards_ty_to_exp1(ty1s, dim, exp2, tshape1, tshape2, opr_inner, opr_outer, title, testing_frame, cnt)
440                    exp1 = shape_to_tensor(shape1)
441                    core_binary_unary(exp1, exp2, dim, tshape1, tshape2, opr_inner, opr_outer, title, testing_frame, cnt)
442    
443    
444    
445  ##################################################################################################  ##################################################################################################
446    ##################################################################################################
447  # main function  # main function
448  def pick_shape1(opr_inner, opr_outer, shape1, testing_frame, cnt):  
449    #handles some backwards
450    def pick(opr_inner, opr_outer, testing_frame, cnt):
451        start = time.time()
452    
453        #writeTitle_outer(opr_inner, opr_outer)
454        # iterate over shapes for first terms
455        backwards= False
456        if(opr_outer.fieldop and backwards):
457            go_backwards(opr_outer, opr_inner, testing_frame, cnt)
458        #print "backwards"
459        elif(opr_inner.arity == 1 and backwards):
460                #print "backwards"
461            go_backwards(opr_outer, opr_inner, testing_frame, cnt)
462            #print "backwards"
463        else:
464            shapes = tvs+tms+tt2+tt3+tt4
465            for shape1 in shapes:
466                #print "shape1 ", shape1
467      pick_get_ty1s(shape1, opr_inner, opr_outer, testing_frame, cnt)      pick_get_ty1s(shape1, opr_inner, opr_outer, testing_frame, cnt)
468                #print "forwards"
469      writeResults_outer(opr_inner, opr_outer, testing_frame, cnt)      writeResults_outer(opr_inner, opr_outer, testing_frame, cnt)
470      #writeCumulative(cnt)      end = time.time()
471        t ="time:"+str(end - start)
472        writeall(t)
473        print (t)
474      return      return
475    
476    #does everything forward
477  # choose operators  def pick2(opr_inner, opr_outer, testing_frame, cnt):
 # main function  
 def pick(opr_inner, opr_outer, testing_frame, cnt):  
478      #writeTitle_outer(opr_inner, opr_outer)      #writeTitle_outer(opr_inner, opr_outer)
479      # iterate over shapes for first terms      # iterate over shapes for first terms
480      vs =  [ty_scalarT, ty_vec2T, ty_vec3T, ty_vec4T]      shapes = tvs+tms+tt2+tt3+tt4
     ms = [ty_mat2x2T, ty_mat2x3T,ty_mat2x4T,ty_mat3x2T,ty_mat3x3T,ty_mat3x4T,ty_mat4x2T,ty_mat4x3T,ty_mat4x4T]  
     t2 = [ty_ten2x2x2T, ty_ten2x2x3T,ty_ten2x2x4T, ty_ten2x3x2T,ty_ten2x3x3T, ty_ten2x3x4T,ty_ten2x4x2T,ty_ten2x4x3T,ty_ten2x4x4T]  
     t3 = [ty_ten3x2x2T, ty_ten3x2x3T,ty_ten3x2x4T, ty_ten3x3x2T,ty_ten3x3x3T, ty_ten3x3x4T,ty_ten3x4x2T,ty_ten3x4x3T,ty_ten3x4x4T]  
     t4 = [ty_ten4x2x2T, ty_ten4x2x3T,ty_ten4x2x4T, ty_ten4x3x2T,ty_ten4x3x3T, ty_ten4x3x4T,ty_ten4x4x2T,ty_ten4x4x3T,ty_ten4x4x4T]  
   
     shapes = vs+ms+t2+t3+t4  
481      for shape1 in shapes:      for shape1 in shapes:
482           pick_shape1(opr_inner, opr_outer, shape1, testing_frame, cnt)          pick_get_ty1s(shape1, opr_inner, opr_outer, testing_frame, cnt)
483        writeResults_outer(opr_inner, opr_outer, testing_frame, cnt)
484        writeCumulative(cnt)
485      return      return

Legend:
Removed from v.4482  
changed lines
  Added in v.4483

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0