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

# SCM Repository

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

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

revision 3997, Sun Jun 19 15:55:49 2016 UTC revision 3998, Sun Jun 19 17:12:03 2016 UTC
# Line 3  Line 3
3  from __future__ import unicode_literals  from __future__ import unicode_literals
4
5  class operator:  class operator:
6      def __init__(self, id, name, arity, symb):      def __init__(self, id, name, arity, symb, placement):
7          self.id=id          self.id=id
8          self.name=name          self.name=name
9          self.arity=arity          self.arity=arity
10          self.symb=symb          self.symb=symb
11            self.placement=placement
12      def toStr(self):      def toStr(self):
13          self.name, str(arity)          self.name, str(arity)
14      def get_name(self):      def get_name(self):
# Line 21  Line 22
22  #  Constants  #  Constants
23  # id, name, arity, symbol  # id, name, arity, symbol
24  #unay operators  #unay operators
25  op_probe = operator(0,"probe", 1,"")  place_left = "left"
26  op_negation = operator(1,"neg", 1,"-")  place_right = "right"
27  op_gradient = operator(2,"grad", 1, u'∇')  place_middle = "middle"
28  op_divergence = operator(3,"div", 1, u'∇•')  place_split = "split"
29  op_curl= operator(4,"curl", 1, u'∇×')  place_special = "-special"
30  op_jacob= operator(5,"jacob", 1, u'∇⊗')
31    id=0
32  op_unary = [op_probe, op_negation, op_gradient,op_divergence,op_curl,op_jacob]  op_probe = operator(id,"probe", 1,"", place_left)
33    op_negation = operator(id+1,"neg", 1,"-", place_left)
34    op_gradient = operator(id+2,"grad", 1, u'∇', place_left)
35    op_divergence = operator(id+3,"div", 1, u'∇•', place_left)
36    op_curl= operator(id+4,"curl", 1, u'∇×',place_left)
37    op_jacob= operator(id+5,"jacob", 1, u'∇⊗', place_left)
38    op_slice = operator(id+6,"slice", 1, u'[:,0]', place_right)
39    op_norm = operator(id+6,"norm", 1, u'|', place_split)
40    op_normalize = operator(id+7,"normalize", 1, u'normalize', place_left)
41    op_trace = operator(id+8,"trace", 1, u'trace', place_left)
42    op_transpose = operator(id+9,"transpose", 1, u'transpose', place_left)
43    op_det = operator(id+10,"det", 1, u'det', place_left)
44    op_unary = [op_probe, op_negation, op_gradient, op_divergence,
45                op_curl, op_jacob, op_norm, op_normalize, op_trace, op_transpose,op_det]
46  #binary operators  #binary operators
47  op_add = operator(6,"addition", 2,"+")  id=id+11
48  op_subtract = operator(7,"subtraction", 2, "-")  op_add = operator(id,"addition", 2,"+", place_middle)
49  op_cross = operator(8,"cross product", 2, u'×')  op_subtract = operator(id+1,"subtraction", 2, "-", place_middle)
50  op_outer = operator(9,"outer product", 2, u'⊗')  op_cross = operator(id+2,"cross product", 2, u'×', place_middle)
51  op_inner = operator(10,"inner product", 2, u'•')  op_outer = operator(id+3,"outer product", 2, u'⊗', place_middle)
52  op_scale = operator(11,"multiplication", 2, u'*')  op_inner = operator(id+4,"inner product", 2, u'•', place_middle)
53    op_scale = operator(id+5,"multiplication", 2, u'*', place_middle)
54    op_division = operator(id+6,"division", 2, u'/', place_middle)
55    op_binary = [op_add, op_subtract, op_cross, op_outer, op_inner, op_scale, op_division]
op_binary = [op_add, op_subtract, op_cross, op_outer, op_inner, op_scale]
56  #:,*,|()|,normalize,transpose,trace..  #:,*,|()|,normalize,transpose,trace..
57
58  def idToStr(n):  def idToStr(n):

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

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