Home My Page Projects Code Snippets Project Openings diderot

# SCM Repository

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

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

revision 3997, Sun Jun 19 15:55:49 2016 UTC revision 3998, Sun Jun 19 17:12:03 2016 UTC
# Line 136  Line 136
136          dim2=b.dim          dim2=b.dim
137          return (fld.dim==dim2)          return (fld.dim==dim2)
138
139    def get_scaF():
140        rtn = []
141        # binary operator
142        for f in l_all_F:
143            if(fty.is_Scalar(f)):
144                rtn.append(f)
145        return rtn
146
147  #list of vector fields  #list of vector fields
148  def get_vecF():  def get_vecF():
149      rtn = []      rtn = []
# Line 144  Line 152
152          if(fty.is_Vector(f)):          if(fty.is_Vector(f)):
153              rtn.append(f)              rtn.append(f)
154      return rtn      return rtn
155  def get_scaF():
156    #list of matrix fields
157    def get_matF():
158      rtn = []      rtn = []
159      # binary operator      # binary operator
160      for f in l_all_F:      for f in l_all_F:
161          if(fty.is_Scalar(f)):          if(fty.is_Matrix(f)):
162              rtn.append(f)              rtn.append(f)
163      return rtn      return rtn
164
165
166
167  # types for multiplication  # types for multiplication
168    #one has to be a scalar, and one has to a be a field
169  def get_mul():  def get_mul():
170      rtn = []      rtn = []
171      # binary operator      # binary operator
# Line 166  Line 178
178              elif (fty.is_Scalar(sf) or fty.is_Scalar(a)):              elif (fty.is_Scalar(sf) or fty.is_Scalar(a)):
179                  #print ("["+sf.name+","+a.name+"]")                  #print ("["+sf.name+","+a.name+"]")
180                  rtn.append([sf,a])                  rtn.append([sf,a])
181                    rtn.append([a,sf])
182        return rtn
183
184    # types for division
185    #one has to be a scalar, and one has to a be a field
186    def get_division():
187        rtn = []
188        # binary operator
189        for sf in l_all_F:
190            for a in l_all:
191                # check equal dim
192                if(fty.is_Field(a) and (not check_dim(sf, a))):
193                    continue
194                # one arg needs to be a scalar
195                elif (fty.is_Scalar(sf)):
196                    rtn.append([a, sf])
197                elif (fty.is_Scalar(a)):
198                    rtn.append([sf,a])
199      return rtn      return rtn
200
201
203    # one has to be a field
204    # must have same type.
206        rtn = []
207        # binary operator
208        for f in l_all_F:
209            for a in l_all:
210                # check equal dim if seecond arg is a field
211                if(fty.is_Field(a) and (not check_dim(f, a))):
212                    continue
213                # needs to have same type
214                elif (fty.get_shape(f) == fty.get_shape(a)):
215                    rtn.append([f, a])
216        return rtn
217
218
219  #list of types  #list of types
220  #fields that we can create data  #fields that we can create data
221  l_all_F= [ty_scalarF_d2, ty_vec2F_d2, ty_scalarF_d3, ty_vec3F_d3]  l_all_F= [ty_scalarF_d2, ty_vec2F_d2, ty_scalarF_d3, ty_vec3F_d3]
222  l_all_FT = [ty_scalarFT, ty_vec2FT, ty_vec3FT, ty_mat2x2FT, ty_mat3x3FT, ty_mat2x2x2FT, ty_mat3x3x3FT]  l_all_FT = [ty_scalarFT, ty_vec2FT, ty_vec3FT, ty_mat2x2FT, ty_mat3x3FT, ty_mat2x2x2FT, ty_mat3x3x3FT]
223  l_all= l_all_F + l_all_FT  l_all= l_all_F + l_all_FT
224  # list of fields by type  # list of fields by type
vectorFlds = get_vecF()
225  scalarFlds = get_scaF()  scalarFlds = get_scaF()
226    vectorFlds = get_vecF()
227    matrixFlds = get_matF()
228
229
230  #binary operator so two args  #binary operator so two args

Legend:
 Removed from v.3997 changed lines Added in v.3998