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

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

Revision 4821 Revision 4822
200 # to the ORIGINAL correct answer. (This will have to be 200 # to the ORIGINAL correct answer. (This will have to be
201 # fixed if we ever do adaptive parameters for non-real formulas) 201 # fixed if we ever do adaptive parameters for non-real formulas)
202 # 202 #
205 my \$tolerance = \$self->getFlag('tolerance',1E-4); 205 my \$tolerance = \$self->getFlag('tolerance',1E-4);
206 my \$isRelative = \$self->getFlag('tolType','relative') eq 'relative'; 206 my \$isRelative = \$self->getFlag('tolType','relative') eq 'relative';
207 my \$zeroLevel = \$self->getFlag('zeroLevel',1E-14); 207 my \$zeroLevel = \$self->getFlag('zeroLevel',1E-14);
208 my \$zeroLevelTol = \$self->getFlag('zeroLevelTol',1E-12);
208 foreach \$i (0..scalar(@{\$lvalues})-1) { 209 foreach \$i (0..scalar(@{\$lvalues})-1) {
209 my \$tol = \$tolerance; 210 my \$tol = \$tolerance;
210 my (\$lv,\$rv,\$av) = (\$lvalues->[\$i]->value,\$rvalues->[\$i]->value,\$avalues->[\$i]->value); 211 my (\$lv,\$rv,\$av) = (\$lvalues->[\$i]->value,\$rvalues->[\$i]->value,\$avalues->[\$i]->value);
211 \$tol *= abs(\$lv) if \$isRelative && abs(\$lv) > \$zeroLevel; 212 if (\$isRelative) {
213 if (abs(\$lv) <= \$zeroLevel) {\$tol = \$zeroLevelTol}
214 else {\$tol *= abs(\$lv)}
215 }
212 return \$rv <=> \$av unless abs(\$rv - \$av) < \$tol; 216 return \$rv <=> \$av unless abs(\$rv - \$av) < \$tol;
213 } 217 }
214 return 0; 218 return 0;
215 } 219 }
216 220

Legend:
 Removed from v.4821 changed lines Added in v.4822