From: dpvc v. a. <we...@ma...> - 2007-10-31 01:42:35
|
Log Message: ----------- Fix LimitedPolynomial-Strict to check for singlePowers (there was a typo) and to consider constants to be coefficients of x^0. Give better error messages in some cases. Modified Files: -------------- pg/macros: contextLimitedPolynomial.pl Revision Data ------------- Index: contextLimitedPolynomial.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedPolynomial.pl,v retrieving revision 1.17 retrieving revision 1.18 diff -Lmacros/contextLimitedPolynomial.pl -Lmacros/contextLimitedPolynomial.pl -u -r1.17 -r1.18 --- macros/contextLimitedPolynomial.pl +++ macros/contextLimitedPolynomial.pl @@ -139,6 +139,7 @@ # # Mark a variable as having power 1 +# Mark a number as being present (when strict coefficients are used) # Mark a monomial as having its given powers # sub markPowers { @@ -148,6 +149,8 @@ $self->{index} = $vIndex->{$self->{name}}; $self->{exponents} = [(0) x scalar(keys %{$vIndex})]; $self->{exponents}[$self->{index}] = 1; + } elsif ($self->class eq 'Number') { + $self->{exponents} = [] if $self->context->flag("strictCoefficients"); } if ($self->{exponents}) { my $power = join(',',@{$self->{exponents}}); @@ -199,11 +202,6 @@ $self->checkPowers; } -sub checkStrict { - my $self = shift; - $self->Error("You can only use addition for the terms of a polynomial",$self->{bop}); -} - ############################################## package LimitedPolynomial::BOP::subtract; @@ -216,11 +214,6 @@ $self->checkPowers; } -sub checkStrict { - my $self = shift; - $self->Error("You can only use subtraction between the terms of a polynomial",$self->{bop}); -} - ############################################## package LimitedPolynomial::BOP::multiply; @@ -263,7 +256,7 @@ sub checkStrict { my $self = shift; - $self->Error("You can only use '%s' to form fractions",$self->{bop}) if $self->{lop}->class eq 'BOP'; + $self->Error("You can only use '%s' to form numeric fractions",$self->{bop}) if $self->{lop}->class eq 'BOP'; } ############################################## @@ -431,7 +424,7 @@ # A context where coefficients can't include operations # $context = $main::context{"LimitedPolynomial-Strict"} = $context->copy; - $context->flags->set(strictCoefficients=>1, singelPowers=>1, reduceConstants=>0); + $context->flags->set(strictCoefficients=>1, singlePowers=>1, reduceConstants=>0); $context->functions->disable("All"); # can be re-enabled if needed main::Context("LimitedPolynomial"); ### FIXME: probably should require author to set this explicitly |