[system] / trunk / pg / lib / Value / Formula.pm Repository: Repository Listing bbplugincoursesdistsnplrochestersystemwww

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

Revision 3715 Revision 3716
16 '-' => sub {shift->sub(@_)}, 16 '-' => sub {shift->sub(@_)},
17 '*' => sub {shift->mult(@_)}, 17 '*' => sub {shift->mult(@_)},
18 '/' => sub {shift->div(@_)}, 18 '/' => sub {shift->div(@_)},
19 '**' => sub {shift->power(@_)}, 19 '**' => sub {shift->power(@_)},
20 '.' => sub {shift->dot(@_)}, 20 '.' => sub {shift->_dot(@_)},
21 'x' => sub {shift->cross(@_)}, 21 'x' => sub {shift->cross(@_)},
22 '<=>' => sub {shift->compare(@_)}, 22 '<=>' => sub {shift->compare(@_)},
23 'cmp' => sub {shift->compare_string(@_)}, 23 'cmp' => sub {shift->compare_string(@_)},
24 '~' => sub {shift->call('conj',@_)}, 24 '~' => sub {shift->call('conj',@_)},
25 'neg' => sub {shift->neg}, 25 'neg' => sub {shift->neg},
127sub cross {bop('><',@_)} 127sub cross {bop('><',@_)}
128 128
129# 129#
130# Make dot work for vector operands 130# Make dot work for vector operands
131# 131#
132sub dot { 132sub _dot {
133 my (\$l,\$r,\$flag) = @_; 133 my (\$l,\$r,\$flag) = @_;
134 if (\$l->promotePrecedence(\$r)) {return \$r->dot(\$l,!\$flag)} 134 if (\$l->promotePrecedence(\$r)) {return \$r->_dot(\$l,!\$flag)}
135 return bop('.',@_) if \$l->type eq 'Vector' && 135 return bop('.',@_) if \$l->type eq 'Vector' &&
136 Value::isValue(\$r) && \$r->type eq 'Vector'; 136 Value::isValue(\$r) && \$r->type eq 'Vector';
137 Value::_dot(@_); 137 \$l->SUPER::_dot(\$r,\$flag);
138} 138}
139
140sub pdot {'('.(shift->stringify).')'}
139 141
140# 142#
141# Call the Parser::Function call function 143# Call the Parser::Function call function
142# 144#
143sub call { 145sub call {
153 my \$self = shift; 155 my \$self = shift;
154 my \$formula = \$self->blank; 156 my \$formula = \$self->blank;
155 \$formula->{context} = \$self->{context}; 157 \$formula->{context} = \$self->{context};
156 \$formula->{variables} = \$self->{variables}; 158 \$formula->{variables} = \$self->{variables};
157 \$formula->{tree} = \$formula->{context}{parser}{UOP}->new(\$formula,'u-',\$self->{tree}->copy(\$formula)); 159 \$formula->{tree} = \$formula->{context}{parser}{UOP}->new(\$formula,'u-',\$self->{tree}->copy(\$formula));
158# return \$formula->eval if \$formula->isConstant;
159 return \$formula; 160 return \$formula;
160} 161}
161 162
162# 163#
163# Form the function atan2 function call on two operands 164# Form the function atan2 function call on two operands

Legend:
 Removed from v.3715 changed lines Added in v.3716