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

SCM Repository

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

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

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

revision 4235, Tue Jul 19 22:26:44 2016 UTC revision 4236, Wed Jul 20 03:02:00 2016 UTC
# Line 182  Line 182 
182  ty_ten2x2x2F_d3 = mkField(id+7, dim, ty_ten2x2x2T)  ty_ten2x2x2F_d3 = mkField(id+7, dim, ty_ten2x2x2T)
183  ty_ten3x3x3F_d3 = mkField(id+8, dim, ty_ten3x3x3T)  ty_ten3x3x3F_d3 = mkField(id+8, dim, ty_ten3x3x3T)
184    
185    #list of types
186    #fields that we can create data
187    l_all_F= [ty_scalarF_d1, ty_scalarF_d2, ty_vec2F_d2, ty_mat2x2F_d2, ty_scalarF_d3, ty_vec3F_d3,ty_mat2x2F_d3]#, ty_mat3x3F_d3]
188    l_all_FT = [ty_scalarFT, ty_vec2FT, ty_vec3FT, ty_mat2x2FT, ty_mat3x3FT, ty_mat2x2x2FT, ty_mat3x3x3FT]
189    l_all= l_all_F + l_all_FT
190    
191    
192  # check equal dim  # check equal dim
193  def check_dim(fld,b):  def check_dim(fld,b):
# Line 282  Line 288 
288                      rtn.append([a, f])                      rtn.append([a, f])
289      return rtn      return rtn
290    
   
 #list of types  
 #fields that we can create data  
 l_all_F= [ty_scalarF_d1, ty_scalarF_d2, ty_vec2F_d2, ty_mat2x2F_d2, ty_scalarF_d3, ty_vec3F_d3]#, ty_mat3x3F_d3]  
 l_all_FT = [ty_scalarFT, ty_vec2FT, ty_vec3FT, ty_mat2x2FT, ty_mat3x3FT, ty_mat2x2x2FT, ty_mat3x3x3FT]  
 l_all= l_all_F + l_all_FT  
291  # list of fields by type  # list of fields by type
292  scalarFlds = get_scaF()  scalarFlds = get_scaF()
293  scalarFldsnotd1 = get_scaFnotd1()  scalarFldsnotd1 = get_scaFnotd1()
# Line 309  Line 309 
309          return (False, None)          return (False, None)
310    
311  #shape to type  #shape to type
312  def shapeToTy(shapeout, dim):  #shape to type
313    def shapeToTyhelper(shapeout, dim):
314      if (dim==1):      if (dim==1):
315          if (shapeout==[]):          if (shapeout==[]):
316              return ty_scalarF_d1              return (True, ty_scalarF_d1)
317          elif (shapeout==[1]):          elif (shapeout==[1]):
318              return ty_vec1F_d1              return (True, ty_vec1F_d1)
319          elif (shapeout==[2]):          elif (shapeout==[2]):
320              return   ty_vec2F_d1              return  (True,  ty_vec2F_d1)
321          elif (shapeout==[3]):          elif (shapeout==[3]):
322              return   ty_vec3F_d1              return  (True,  ty_vec3F_d1)
323          elif(shapeout==[1,1]):          elif(shapeout==[1,1]):
324              return ty_mat1x1F_d1              return (True, ty_mat1x1F_d1)
325          elif(shapeout==[2,2]):          elif(shapeout==[2,2]):
326              return ty_mat2x2F_d1              return (True, ty_mat2x2F_d1)
327          elif(shapeout==[3,3]):          elif(shapeout==[3,3]):
328              return ty_mat3x3F_d1              return (True, ty_mat3x3F_d1)
329          elif (shapeout==[2,2,2]):          elif (shapeout==[2,2,2]):
330              return ty_ten2x2x2F_d1              return (True, ty_ten2x2x2F_d1)
331          elif(shapeout==[3,3, 3]):          elif(shapeout==[3,3, 3]):
332              return ty_ten3x3x3F_d1              return (True, ty_ten3x3x3F_d1)
333          else:          else:
334              #print "shapeout",shapeout,"dim", dim              #print "shapeout",shapeout,"dim", dim
335              raise Exception ("unsupported shapeout", str(shapeout))              return (False, ("unsupported shapeout dim-1 "+ str(shapeout)))
336      elif (dim==2):      elif (dim==2):
337          if (shapeout==[]):          if (shapeout==[]):
338              return ty_scalarF_d2              return (True, ty_scalarF_d2)
339          elif (shapeout==[2]):          elif (shapeout==[2]):
340              return ty_vec2F_d2              return (True, ty_vec2F_d2)
341          elif(shapeout==[3]):          elif(shapeout==[3]):
342              return ty_vec3F_d2              return (True, ty_vec3F_d2)
343          elif (shapeout==[2,2]):          elif (shapeout==[2,2]):
344              return ty_mat2x2F_d2              return (True, ty_mat2x2F_d2)
345          elif (shapeout==[3,3]):          elif (shapeout==[3,3]):
346              return ty_mat3x3F_d2              return (True, ty_mat3x3F_d2)
347          elif (shapeout==[2,2,2]):          elif (shapeout==[2,2,2]):
348              return ty_ten2x2x2F_d2              return (True,  ty_ten2x2x2F_d2)
349          elif(shapeout==[3,3, 3]):          elif(shapeout==[3,3, 3]):
350              return ty_ten3x3x3F_d2              return (True, ty_ten3x3x3F_d2)
351          else:          else:
352              #print "shapeout",shapeout,"dim", dim              #print "shapeout",shapeout,"dim", dim
353              raise Exception ("unsupported shapeout", str(shapeout))              return(False, "unsupported shapeout dim-2 "+str(shapeout))
354      elif (dim==3):      elif (dim==3):
355          if (shapeout==[]):          if (shapeout==[]):
356              return ty_scalarF_d3              return (True, ty_scalarF_d3)
357          elif(shapeout==[3]):          elif(shapeout==[3]):
358              return ty_vec3F_d3              return (True, ty_vec3F_d3)
359          elif(shapeout==[3,3]):          elif(shapeout==[3,3]):
360              return ty_mat3x3F_d3              return (True, ty_mat3x3F_d3)
   
361          elif(shapeout==[3,3, 3]):          elif(shapeout==[3,3, 3]):
362              return ty_ten3x3x3F_d3              return(True,  ty_ten3x3x3F_d3)
363          elif(shapeout==[2]):          elif(shapeout==[2]):
364              return ty_vec2F_d3              return (True,  ty_vec2F_d3)
365          elif(shapeout==[2,2]):          elif(shapeout==[2,2]):
366              return ty_mat2x2F_d3              return (True, ty_mat2x2F_d3)
367          elif(shapeout==[2,2,2]):          elif(shapeout==[2,2,2]):
368              return ty_ten2x2x2F_d3              return (True, ty_ten2x2x2F_d3)
369          else:          else:
370              raise "unsupported shapeout"              return (False, "unsupported shapeout dim-3"+str(shapeout))
371      else:      else:
372          raise "unsupported dim"          return (False, "unsupported dim")
373    
374    def shapeToTy(shapeout, dim):
375        (_, shape) = shapeToTyhelper(shapeout, dim)
376        return shape
377    
378  #concat two types to form a new type  #concat two types to form a new type
379  def concatTys(ty1, ty2):  def concatTys(ty1, ty2):

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

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