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 4209, Thu Jul 14 17:37:50 2016 UTC revision 4210, Thu Jul 14 18:01:19 2016 UTC
# Line 88  Line 88 
88  # shorthand used to refer to different types  # shorthand used to refer to different types
89  # the helper functions match shorthand to other properties and creates ty object  # the helper functions match shorthand to other properties and creates ty object
90    
91    def tyToStr(s):
92        n=len(s)
93        if(n==0):
94            return "s"
95        elif(n==1):
96            [v] = s
97            return "v"+str(v)
98        elif(n==2):
99            [v,m] = s
100            return "m"+str(v)+"x"+str(m)
101        elif(n==3):
102            [v,m,l] = s
103            return "t"+str(v)+"x"+str(m)+"x"+str(l)
104        return "t"
105    
106    def mkTensor(id, shape):
107        #print "id",str(id)
108        name = "T_"+tyToStr(shape)
109        return tty(id, name, shape)
110    
111    ty_noneT = mkTensor(id,[])
112    def mkNoneField(id, shape):
113        #print "id",str(id)
114        name = "N_"+tyToStr(shape)
115        return fty(id, name, 0, shape, ty_noneT, -1)
116    
117    #fields:  #id,name, dim, shape in string form,probe field type returns tensor type
118    def mkField(id, dim, outputtensor):
119        #print "id",str(id)
120        name = "F_"+tyToStr(outputtensor.shape)+"_d"+str(dim)
121        return fty(id, name, dim, outputtensor.shape, outputtensor, k_init)
122    
123    def get_Tshape(ty):
124        return ty.shape
125    
126  #tensors  #tensors
127  id=0  id=0
128  ty_noneT = tty(id,"none",[])  ty_scalarT = mkTensor(id+1,[])
129  ty_scalarT = tty(id+1,"scalar",[])  ty_vec1T = mkTensor(id+2,[1])
130  ty_vec1T = tty(id+2,"vec1",[1])  ty_vec2T = mkTensor(id+3,[2])
131  ty_vec2T = tty(id+3,"vec2",[2])  ty_vec3T = mkTensor(id+4,[3])
132  ty_vec3T = tty(id+4,"vec3",[3])  ty_mat1x1T = mkTensor(id+5,[1,1])
133  ty_mat1x1T = tty(id+5,"mat2x2",[1,1])  ty_mat2x2T = mkTensor(id+6,[2,2])
134  ty_mat2x2T = tty(id+6,"mat2x2",[2,2])  ty_mat3x3T = mkTensor(id+7,[3,3])
135  ty_mat3x3T = tty(id+7,"mat3x3",[3,3])  ty_ten2x2x2T = mkTensor(id+8,[2,2,2])
136  ty_ten2x2x2T = tty(id+8,"ten2x2x2",[2,2,2])  ty_ten3x3x3T = mkTensor(id+9,[3,3,3])
 ty_ten3x3x3T = tty(id+9,"ten3x3x3",[3,3,3])  
137    
138  id=0  id=0
   
139  #lift tensor to field level  #lift tensor to field level
140  ty_scalarFT = fty(id,"scalartensor",0, [],ty_noneT,-1)  ty_scalarFT = mkNoneField(id,[] )
141  ty_vec1FT = fty(id+1,"vec2tensor",0, [2],ty_noneT,-1)  ty_vec1FT = mkNoneField(id+1, [2] )
142  ty_vec2FT = fty(id+2,"vec2tensor",0, [2],ty_noneT,-1)  ty_vec2FT = mkNoneField(id+2, [2] )
143  ty_vec3FT = fty(id+3,"vec3tensor",0,[3],ty_noneT,-1)  ty_vec3FT = mkNoneField(id+3, [3] )
144  ty_mat2x2FT = fty(id+4,"mat2x2tensor",0,[2,2],ty_noneT,-1)  ty_mat2x2FT = mkNoneField(id+4, [2,2] )
145  ty_mat3x3FT = fty(id+5,"mat3x3tensor",0,[3,3],ty_noneT,-1)  ty_mat3x3FT =mkNoneField(id+5, [3,3] )
146  ty_mat2x2x2FT = fty(id+6,"mat2x2x2tensor",0,[2,2,2],ty_noneT,-1)  ty_mat2x2x2FT = mkNoneField(id+6, [2,2,2] )
147  ty_mat3x3x3FT = fty(id+7,"mat3x3tx3ensor",0,[3,3,3],ty_noneT,-1)  ty_mat3x3x3FT = mkNoneField(id+7, [3,3,3] )
148    
149  def get_Tshape(ty):  #dimension 1
     return ty.shape  
   
 #fields:  #id,name, dim, shape in string form,probe field type returns tensor type  
150  k_init=0#null k  k_init=0#null k
151  id=10  id=10
 #dimension 1  
 def mkField(id, dim, outputtensor):  
     print "id",str(id)  
     name = "F_"+outputtensor.name+"_d"+str(dim)  
     return fty(id, name, dim, outputtensor.shape, outputtensor, k_init)  
   
   
152  dim = 1  dim = 1
153  ty_scalarF_d1 = mkField(id+1, dim, ty_scalarT)  ty_scalarF_d1 = mkField(id+1, dim, ty_scalarT)
154  ty_vec1F_d1 = mkField(id+2, dim, ty_vec1T)  ty_vec1F_d1 = mkField(id+2, dim, ty_vec1T)
# Line 135  Line 158 
158  ty_mat3x3F_d1 = mkField(id+6, dim, ty_mat3x3T)  ty_mat3x3F_d1 = mkField(id+6, dim, ty_mat3x3T)
159  ty_ten2x2x2F_d1 = mkField(id+7, dim, ty_ten2x2x2T)  ty_ten2x2x2F_d1 = mkField(id+7, dim, ty_ten2x2x2T)
160  ty_ten3x3x3F_d1 = mkField(id+8, dim, ty_ten3x3x3T)  ty_ten3x3x3F_d1 = mkField(id+8, dim, ty_ten3x3x3T)
   
161  #dimension 2  #dimension 2
162  id=20  id=20
163  ty_scalarF_d2 = fty(id+1,"scalarfield_d2", 2, [], ty_scalarT,k_init)  dim=2
164  ty_vec2F_d2 = fty(id+2,"vec2field_d2", 2, [2], ty_vec2T,k_init)  ty_scalarF_d2 = mkField(id+1, dim, ty_scalarT)
165  ty_mat2x2F_d2 = fty(id+3,"mat2x2field_d2", 2, [2,2], ty_mat2x2T,k_init)  ty_vec2F_d2 = mkField(id+3, dim, ty_vec2T)
166  ty_ten2x2x2F_d2 = fty(id+4,"mat2x2x2field_d2", 2, [2,2,2], ty_ten2x2x2T,k_init)  ty_vec3F_d2 = mkField(id+4, dim, ty_vec3T)
167  ty_vec3F_d2 = fty(id+5,"vec3field_d2", 2, [3], ty_vec3T,k_init)  ty_mat2x2F_d2 = mkField(id+5, dim, ty_mat2x2T)
168  ty_mat3x3F_d2 = fty(id+6,"mat3x3field_d2", 2, [3,3], ty_mat3x3T,k_init)  ty_mat3x3F_d2 = mkField(id+6, dim, ty_mat3x3T)
169  ty_ten3x3x3F_d2 = fty(id+7,"ten3x3x3field_d2", 2, [3,3,3], ty_ten3x3x3T,k_init)  ty_ten2x2x2F_d2 = mkField(id+7, dim, ty_ten2x2x2T)
170    ty_ten3x3x3F_d2 = mkField(id+8, dim, ty_ten3x3x3T)
171  #dimension 3  #dimension 3
172  id=30  id=30
173  ty_scalarF_d3 = fty(id+1,"scalarfield_d3", 3, [], ty_scalarT,k_init)  dim=3
174  ty_vec3F_d3 = fty(id+2,"vec3field_d3", 3, [3], ty_vec3T,k_init)  ty_scalarF_d3 = mkField(id+1, dim, ty_scalarT)
175  ty_mat3x3F_d3 = fty(id+3,"mat3x3field_d3", 3, [3,3], ty_mat3x3T,k_init)  ty_vec2F_d3 = mkField(id+3, dim, ty_vec2T)
176  ty_ten3x3x3F_d3 = fty(id+4,"mat3x3x3field_d3", 3, [3,3,3], ty_ten3x3x3T,k_init)  ty_vec3F_d3 = mkField(id+4, dim, ty_vec3T)
177  ty_vec2F_d3 = fty(id+5,"vec2field_d3", 3, [2], ty_vec2T,k_init)  ty_mat2x2F_d3 = mkField(id+5, dim, ty_mat2x2T)
178  ty_mat2x2F_d3 = fty(id+6,"mat2x2field_d3", 3, [2,2], ty_mat2x2T,k_init)  ty_mat3x3F_d3 = mkField(id+6, dim, ty_mat3x3T)
179  ty_ten2x2x2F_d3 = fty(id+7,"ten2x2x2field_d3", 3, [2,2,2], ty_ten2x2x2T,k_init)  ty_ten2x2x2F_d3 = mkField(id+7, dim, ty_ten2x2x2T)
180    ty_ten3x3x3F_d3 = mkField(id+8, dim, ty_ten3x3x3T)
181    
182    
183  # check equal dim  # check equal dim

Legend:
Removed from v.4209  
changed lines
  Added in v.4210

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