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 4236, Wed Jul 20 03:02:00 2016 UTC revision 4237, Wed Jul 20 17:26:21 2016 UTC
# Line 254  Line 254 
254      else:      else:
255          raise "unsupported type for norm"          raise "unsupported type for norm"
256    
257    #[0]
258    def fn_slicev0(fld1):
259        exp1 = field.get_data(fld1)
260        ityp1 = field.get_ty(fld1)
261        return exp1[0]
262    
263    
264  #evaluate slice  #evaluate slice
265  def fn_slice(fld1):  #[1]
266    def fn_slicev1(fld1):
267        exp1 = field.get_data(fld1)
268        ityp1 = field.get_ty(fld1)
269        return exp1[1]
270    
271    #evaluate slice
272    #[1,:]
273    def fn_slicem0(fld1):
274      exp1 = field.get_data(fld1)      exp1 = field.get_data(fld1)
275      ityp1 = field.get_ty(fld1)      ityp1 = field.get_ty(fld1)
276      rtn=[]      rtn=[]
277      if(fty.is_Matrix(ityp1)):      if(fty.is_Matrix(ityp1)):
278          [n2,n3] = fty.get_shape(ityp1)          [n2,n3] = fty.get_shape(ityp1)
279          for j in range(n3):          for i in range(n3):
280              rtn.append(exp1[j][0])              rtn.append(exp1[1][i])
281          return rtn          return rtn
282      else:      else:
283          raise "unsupported type for slice"          raise "unsupported type for slice"
284    
285    #evaluate slice
286    #[:,0]
287    def fn_slicem1(fld1):
288        exp1 = field.get_data(fld1)
289        ityp1 = field.get_ty(fld1)
290        rtn=[]
291        if(fty.is_Matrix(ityp1)):
292            [n2,n3] = fty.get_shape(ityp1)
293            for i in range(n2):
294                rtn.append(exp1[i][0])
295            return rtn
296        else:
297            raise "unsupported type for slice"
298    
299    
300  #evaluate trace  #evaluate trace
301  def fn_trace(fld):  def fn_trace(fld):
302      exp = field.get_data(fld)      exp = field.get_data(fld)
# Line 555  Line 585 
585          return fn_curl(fld)          return fn_curl(fld)
586      elif(op_jacob==fn_name): #jacob      elif(op_jacob==fn_name): #jacob
587          return fn_jacob(fld)          return fn_jacob(fld)
588        elif(op_slicev0==fn_name) :
589            return fn_slicev0(fld)
590        elif(op_slicev1==fn_name):
591            return fn_slicev1(fld)
592      else:      else:
593          raise Exception("unsupported unary operator:"+ fn_name.name)          raise Exception("unsupported unary operator:"+ fn_name.name)
594    
# Line 566  Line 600 
600          return applyToM(exp, fn_negation)          return applyToM(exp, fn_negation)
601      elif(op_jacob==fn_name): #jacob      elif(op_jacob==fn_name): #jacob
602          return fn_jacob(fld)          return fn_jacob(fld)
603      elif(op_slice==fn_name):      elif(op_slicem0==fn_name) :
604          return fn_slice(fld)          return fn_slicem0(fld)
605        elif(op_slicem1==fn_name):
606            return fn_slicem1(fld)
607      elif(op_trace == fn_name):      elif(op_trace == fn_name):
608          return fn_trace(fld)          return fn_trace(fld)
609      elif(op_transpose==fn_name):      elif(op_transpose==fn_name):

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

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