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

SCM Repository

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

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

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

revision 4242, Thu Jul 21 14:43:40 2016 UTC revision 4243, Thu Jul 21 17:54:34 2016 UTC
# Line 246  Line 246 
246          return (true, fty.convertTy(getTy(), k))          return (true, fty.convertTy(getTy(), k))
247      elif(op_normalize==op1):            # apply op_normalize      elif(op_normalize==op1):            # apply op_normalize
248          return (true, ityp1)          return (true, ityp1)
249        elif(op_slicev0==op1):            # apply op_slice [0]
250            if(fty.is_Vector(ityp1)):
251                k = ityp1.k
252                dim = ityp1.dim
253                fty1 = shapeToTy([], dim)
254                return (true, fty.convertTy(fty1, k))
255            else:
256                return (false, " can not apply slice to non vector")
257        elif(op_slicev1 ==op1):            # apply op_slice [1]
258            if(fty.is_Vector(ityp1)):
259                k = ityp1.k
260                dim = ityp1.dim
261                fty1 = shapeToTy([], dim)
262                return (true, fty.convertTy(fty1, k))
263            else:
264                return (false, " can not apply slice to non vector ")
265      elif(op_slicem1 ==op1):            # apply op_slice [:,0]      elif(op_slicem1 ==op1):            # apply op_slice [:,0]
266          if(fty.is_Matrix(ityp1)):          if(fty.is_Matrix(ityp1)):
267              k = ityp1.k              k = ityp1.k
# Line 264  Line 280 
280              return (true, fty.convertTy(fty1, k))              return (true, fty.convertTy(fty1, k))
281          else:          else:
282              return (false, " can not apply slice to non matrix")              return (false, " can not apply slice to non matrix")
283      elif(op_slicev0==op1):            # apply op_slice [0]      elif(op_slicet0==op1):            # apply op_slice [:,1,:]
284          if(fty.is_Vector(ityp1)):          if(fty.is_Ten3(ityp1)):
285              k = ityp1.k              k = ityp1.k
286              dim = ityp1.dim              dim = ityp1.dim
287              fty1 = shapeToTy([], dim)              shape = ityp1.shape
288                print "shape",shape
289                [a, _, c] = shape
290                fty1 = shapeToTy([a,c], dim)
291              return (true, fty.convertTy(fty1, k))              return (true, fty.convertTy(fty1, k))
292          else:          else:
293              return (false, " can not apply slice to non vector")              return (false, " can not apply slice to non vector")
294      elif(op_slicev1 ==op1):            # apply op_slice [1]      elif(op_slicet1 ==op1):            # apply op_slice [1,0,:]
295          if(fty.is_Vector(ityp1)):          if(fty.is_Ten3(ityp1)):
296              k = ityp1.k              k = ityp1.k
297              dim = ityp1.dim              dim = ityp1.dim
298              fty1 = shapeToTy([], dim)              [_,_,c] = ityp1.shape
299                fty1 = shapeToTy([c], dim)
300              return (true, fty.convertTy(fty1, k))              return (true, fty.convertTy(fty1, k))
301          else:          else:
302              return (false, " can not apply slice to non vector ")              return (false, " can not apply slice to non vector ")
# Line 389  Line 409 
409              else:              else:
410                  return  (false, ("cross product needs to be applied to vectors of the same size", op1.name))                  return  (false, ("cross product needs to be applied to vectors of the same size", op1.name))
411          return  (false, ("cross product needs to be applied to vectors", op1.name))          return  (false, ("cross product needs to be applied to vectors", op1.name))
412        elif(op_modulate==op1):
413            if(fty.is_Scalar(ityp1) or fty.is_Scalar(ityp2)):
414                return  (false,  "modulate applied to scalar fields")
415            return (true, fldty)
416      else:      else:
417          raise Exception("operation not represented in binary operations"+ op1.name)          raise Exception("operation not represented in binary operations"+ op1.name)
418    

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

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