Log Message:
-----------
BACKPORT: 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.
Tags:
----
rel-2-4-patches
Modified Files:
--------------
pg/macros:
PGgraphmacros.pl
Revision Data
-------------
Index: PGgraphmacros.pl
===================================================================
RCS file: /webwork/cvs/system/pg/macros/PGgraphmacros.pl,v
retrieving revision 1.6.6.1.2.2
retrieving revision 1.6.6.1.2.3
diff -Lmacros/PGgraphmacros.pl -Lmacros/PGgraphmacros.pl -u -r1.6.6.1.2.2 -r1.6.6.1.2.3
--- 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;
|