From: dpvc v. a. <we...@ma...> - 2008-10-07 23:20:13
|
Log Message: ----------- Use a compiled vesion of the MathObjects formula rather than the less-efficient eval method. This should bring graphing speeds back in line with the original non-MathObject version. Modified Files: -------------- pg/macros: PGgraphmacros.pl Revision Data ------------- Index: PGgraphmacros.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PGgraphmacros.pl,v retrieving revision 1.11 retrieving revision 1.12 diff -Lmacros/PGgraphmacros.pl -Lmacros/PGgraphmacros.pl -u -r1.11 -r1.12 --- macros/PGgraphmacros.pl +++ macros/PGgraphmacros.pl @@ -322,14 +322,14 @@ # a workaround to call Parser code without loading MathObjects. my $localContext= Parser::Context->current(\%main::context)->copy; $localContext->variables->add($var=>'Real') unless $localContext->variables->get($var); - my $formula = Value->Package("Formula()")->new($localContext,$rule); + my $formula = Value->Package("Formula()")->new($localContext,$rule)->perlFunction(undef,[$var]); my $subRef = sub { my $x = shift; - my $y = Parser::Evaluate($formula, $var=>$x); + my $y = Parser::Eval($formula,$x); # traps errors, e.g. graph domain is larger than + # the function's domain. $y = $y->value if defined $y; - return $y + return $y; }; - # traps errors when graph domain is larger than the function's domain. #my $subRef = string_to_sub($rule,$var); my $funRef = new Fun($subRef,$graph); $funRef->color($color); @@ -489,14 +489,6 @@ $out; } - - - - - - - - ######################################################### 1; |