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

SCM Repository

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

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

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

revision 4237, Wed Jul 20 17:26:21 2016 UTC revision 4243, Thu Jul 21 17:54:34 2016 UTC
# Line 18  Line 18 
18      return exp1+exp2      return exp1+exp2
19  def fn_subtract(exp1,exp2):  def fn_subtract(exp1,exp2):
20      return exp1-exp2      return exp1-exp2
21    def fn_modulate(exp1,exp2):
22        return exp1*exp2
23  # scaling operator  # scaling operator
24  def fn_multiplication(exp_s, t):  def fn_multiplication(exp_s, t):
25      exp_t = field.get_data(t)      exp_t = field.get_data(t)
# Line 296  Line 298 
298      else:      else:
299          raise "unsupported type for slice"          raise "unsupported type for slice"
300    
301    #evaluate slice
302    #[:,1,:]
303    def fn_slicet0(fld1):
304        exp1 = field.get_data(fld1)
305        ityp1 = field.get_ty(fld1)
306        rtn=[]
307        if(fty.is_Ten3(ityp1)):
308            [n1, n2,n3] = fty.get_shape(ityp1)
309            for i in range(n1):
310                rtnj=[]
311                for j in range(n3):
312                    rtnj.append(exp1[i][1][j])
313                rtn.append(rtnj)
314            return rtn
315        else:
316            raise "unsupported type for slice"
317    
318    #evaluate slice
319    #[1,0,:]
320    def fn_slicet1(fld1):
321        exp1 = field.get_data(fld1)
322        ityp1 = field.get_ty(fld1)
323        rtn=[]
324        if(fty.is_Ten3(ityp1)):
325            [n1, n2, n3] = fty.get_shape(ityp1)
326            for i in range(n3):
327                rtn.append(exp1[1][0][i])
328            return rtn
329        else:
330            raise "unsupported type for slice"
331    
332    
333    
334    
335  #evaluate trace  #evaluate trace
336  def fn_trace(fld):  def fn_trace(fld):
# Line 618  Line 653 
653      if(op_probe==fn_name): #probing      if(op_probe==fn_name): #probing
654          return exp          return exp
655      elif(op_negation==fn_name): #negation      elif(op_negation==fn_name): #negation
   
656          return applyToT3(exp, fn_negation)          return applyToT3(exp, fn_negation)
657      elif(op_jacob==fn_name): #jacob      elif(op_jacob==fn_name): #jacob
658          return fn_jacob(fld)          return fn_jacob(fld)
659        elif(op_slicet0==fn_name) :
660            return fn_slicet0(fld)
661        elif(op_slicet1==fn_name):
662            return fn_slicet1(fld)
663      else:      else:
664          raise Exception("unsupported unary operator:"+ fn_name.name)          raise Exception("unsupported unary operator:"+ fn_name.name)
665    
# Line 637  Line 675 
675          return fn_add(exp1,exp2)          return fn_add(exp1,exp2)
676      elif(op_subtract==fn_name):#subtract      elif(op_subtract==fn_name):#subtract
677          return fn_subtract(exp1,exp2)          return fn_subtract(exp1,exp2)
678        elif(op_modulate==fn_name):#modulate
679            return fn_modulate(exp1,exp2)
680      elif(op_scale==fn_name): #scaling      elif(op_scale==fn_name): #scaling
681          return fn_scaling(fld1,fld2)          return fn_scaling(fld1,fld2)
682      elif(op_division==fn_name): #division      elif(op_division==fn_name): #division
# Line 671  Line 711 
711          return applyToVectors(exp1, exp2,  fn_add)          return applyToVectors(exp1, exp2,  fn_add)
712      elif(op_subtract==fn_name):#subtract      elif(op_subtract==fn_name):#subtract
713          return  applyToVectors(exp1, exp2, fn_subtract)          return  applyToVectors(exp1, exp2, fn_subtract)
714        elif(op_modulate==fn_name):#modulate
715            return applyToVectors(exp1,exp2 ,fn_modulate)
716      elif(op_cross==fn_name):      elif(op_cross==fn_name):
717          return fn_cross(fld1, fld2)          return fn_cross(fld1, fld2)
718      else:      else:
# Line 685  Line 727 
727          return applyToMs(exp1, exp2,  fn_add)          return applyToMs(exp1, exp2,  fn_add)
728      elif(op_subtract==fn_name):#subtract      elif(op_subtract==fn_name):#subtract
729          return  applyToMs(exp1, exp2, fn_subtract)          return  applyToMs(exp1, exp2, fn_subtract)
730        elif(op_modulate==fn_name):#modulate
731            return applyToMs(exp1,exp2,fn_modulate)
732      else:      else:
733          return applyToExp_B_uneven(e)          return applyToExp_B_uneven(e)
734    

Legend:
Removed from v.4237  
changed lines
  Added in v.4243

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