[system] / trunk / pg / lib / Value / Formula.pm Repository:
ViewVC logotype

Diff of /trunk/pg/lib/Value/Formula.pm

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

Revision 2624 Revision 2625
13 '+' => \&add, 13 '+' => \&add,
14 '-' => \&sub, 14 '-' => \&sub,
15 '*' => \&mult, 15 '*' => \&mult,
16 '/' => \&div, 16 '/' => \&div,
17 '**' => \&power, 17 '**' => \&power,
18 '.' => \&Value::_dot, 18 '.' => \&dot,
19 'x' => \&cross, 19 'x' => \&cross,
20 '<=>' => \&compare, 20 '<=>' => \&compare,
21 'cmp' => \&compare, 21 'cmp' => \&Value::cmp,
22 '~' => sub {Parser::Function->call('conj',$_[0])}, 22 '~' => sub {Parser::Function->call('conj',$_[0])},
23 'neg' => sub {$_[0]->neg}, 23 'neg' => sub {$_[0]->neg},
24 'sin' => sub {Parser::Function->call('sin',$_[0])}, 24 'sin' => sub {Parser::Function->call('sin',$_[0])},
25 'cos' => sub {Parser::Function->call('cos',$_[0])}, 25 'cos' => sub {Parser::Function->call('cos',$_[0])},
26 'exp' => sub {Parser::Function->call('exp',$_[0])}, 26 'exp' => sub {Parser::Function->call('exp',$_[0])},
90sub add {bop(@_,'+')} 90sub add {bop(@_,'+')}
91sub sub {bop(@_,'-')} 91sub sub {bop(@_,'-')}
92sub mult {bop(@_,'*')} 92sub mult {bop(@_,'*')}
93sub div {bop(@_,'/')} 93sub div {bop(@_,'/')}
94sub power {bop(@_,'**')} 94sub power {bop(@_,'**')}
95sub dot {bop(@_,'.')}
96sub cross {bop(@_,'x')} 95sub cross {bop(@_,'><')}
96
97#
98# Make dot work for vector operands
99#
100sub dot {
101 my ($l,$r,$flag) = @_;
102 if ($l->promotePrecedence($r)) {return $r->compare($l,!$flag)}
103 return bop(@_,'.') if $l->type eq 'Vector' &&
104 Value::isValue($r) && $r->type eq 'Vector';
105 Value::_dot(@_);
106}
97 107
98############################################ 108############################################
99# 109#
100# Form the negation of a formula 110# Form the negation of a formula
101# 111#
112# 122#
113# Form the function atan2 function call on two operands 123# Form the function atan2 function call on two operands
114# 124#
115sub atan2 { 125sub atan2 {
116 my ($l,$r,$flag) = @_; 126 my ($l,$r,$flag) = @_;
127 if ($l->promotePrecedence($r)) {return $r->compare($l,!$flag)}
117 if ($flag) {my $tmp = $l; $l = $r; $r = $tmp} 128 if ($flag) {my $tmp = $l; $l = $r; $r = $tmp}
118 Parser::Function->call('atan2',$l,$r); 129 Parser::Function->call('atan2',$l,$r);
119} 130}
120 131
121############################################ 132############################################

Legend:
Removed from v.2624  
changed lines
  Added in v.2625

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9