[system] / trunk / pg / macros / PGanswermacros.pl Repository:
ViewVC logotype

Diff of /trunk/pg/macros/PGanswermacros.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 4927 Revision 4928
1050 # 1050 #
1051 # Get an apppropriate context based on the mode 1051 # Get an apppropriate context based on the mode
1052 # 1052 #
1053 my $context; 1053 my $context;
1054 for ($mode) { 1054 for ($mode) {
1055 /^strict$/i and do { 1055 /^strict$/i and do {
1056 $context = $Parser::Context::Default::context{LimitedNumeric}->copy; 1056 $context = Parser::Context->getCopy($user_context,"LimitedNumeric");
1057 last; 1057 last;
1058 }; 1058 };
1059 /^arith$/i and do { 1059 /^arith$/i and do {
1060 $context = $Parser::Context::Default::context{LegacyNumeric}->copy; 1060 $context = Parser::Context->getCopy($user_context,"LegacyNumeric");
1061 $context->functions->disable('All'); 1061 $context->functions->disable('All');
1062 last; 1062 last;
1063 }; 1063 };
1064 /^frac$/i and do { 1064 /^frac$/i and do {
1065 $context = $Parser::Context::Default::context{'LimitedNumeric-Fraction'}->copy; 1065 $context = Parser::Context->getCopy($user_context,"LimitedNumeric-Fraction");
1066 last; 1066 last;
1067 }; 1067 };
1068 1068
1069 # default 1069 # default
1070 $context = $Parser::Context::Default::context{LegacyNumeric}->copy; 1070 $context = Parser::Context->getCopy($user_context,"LegacyNumeric");
1071 } 1071 }
1072 $context->{format}{number} = $num_params{'format'}; 1072 $context->{format}{number} = $num_params{'format'};
1073 $context->strings->clear; 1073 $context->strings->clear;
1074 # FIXME: should clear variables as well? Copy them from the current context? 1074 # FIXME: should clear variables as well? Copy them from the current context?
1075 1075
1889 $mode = 'std' unless defined $mode; 1889 $mode = 'std' unless defined $mode;
1890 my @VARS = get_var_array($var); 1890 my @VARS = get_var_array($var);
1891 my @limits = get_limits_array($ra_limits); 1891 my @limits = get_limits_array($ra_limits);
1892 my @PARAMS = @{$func_params{'params'} || []}; 1892 my @PARAMS = @{$func_params{'params'} || []};
1893 1893
1894 if($tolType eq 'relative') { 1894 if ($tolType eq 'relative') {
1895 $tol = $functRelPercentTolDefault unless defined $tol; 1895 $tol = $functRelPercentTolDefault unless defined $tol;
1896 $tol *= .01; 1896 $tol *= .01;
1897 } else { 1897 } else {
1898 $tol = $functAbsTolDefault unless defined $tol; 1898 $tol = $functAbsTolDefault unless defined $tol;
1899 } 1899 }
1954 ); 1954 );
1955 1955
1956 # 1956 #
1957 # Initialize the context for the formula 1957 # Initialize the context for the formula
1958 # 1958 #
1959 my $context = $Parser::Context::Default::context{"LegacyNumeric"}->copy; 1959 my $context = Parser::Context->getCopy($user_context,"LegacyNumeric");
1960 $context->flags->set( 1960 $context->flags->set(
1961 tolerance => $func_params{'tolerance'}, 1961 tolerance => $func_params{'tolerance'},
1962 tolType => $func_params{'tolType'}, 1962 tolType => $func_params{'tolType'},
1963 zeroLevel => $func_params{'zeroLevel'}, 1963 zeroLevel => $func_params{'zeroLevel'},
1964 zeroLevelTol => $func_params{'zeroLevelTol'}, 1964 zeroLevelTol => $func_params{'zeroLevelTol'},
4051 #warn "taking the difference of ", $inVal, " and ", $correctVal, " is ", $diff; 4051 #warn "taking the difference of ", $inVal, " and ", $correctVal, " is ", $diff;
4052 if ( $options{tolType} eq 'relative' ) { #relative tolerance 4052 if ( $options{tolType} eq 'relative' ) { #relative tolerance
4053 #warn "diff = $diff"; 4053 #warn "diff = $diff";
4054 #$diff = ( $inVal - ($correctVal-$instructorVal ) )/abs($instructorVal) -1 if abs($instructorVal) > $options{zeroLevel}; 4054 #$diff = ( $inVal - ($correctVal-$instructorVal ) )/abs($instructorVal) -1 if abs($instructorVal) > $options{zeroLevel};
4055 $diff = ( $inVal - ($correctVal-$instructorVal ) )/$instructorVal -1 if abs($instructorVal) > $options{zeroLevel}; 4055 $diff = ( $inVal - ($correctVal-$instructorVal ) )/$instructorVal -1 if abs($instructorVal) > $options{zeroLevel};
4056# DPVC -- adjust so that a check for tolerance will
4057# do a zeroLevelTol check
4058## $diff *= $options{tolerance}/$options{zeroLevelTol} unless abs($instructorVal) > $options{zeroLevel};
4059# /DPVC
4056 #$diff = ( $inVal - ($correctVal-$instructorVal- $instructorVal ) )/abs($instructorVal) if abs($instructorVal) > $options{zeroLevel}; 4060 #$diff = ( $inVal - ($correctVal-$instructorVal- $instructorVal ) )/abs($instructorVal) if abs($instructorVal) > $options{zeroLevel};
4057 #warn "diff = $diff, ", abs( &$rf_correct_fun(@inputs) ) , "-- $correctVal"; 4061 #warn "diff = $diff, ", abs( &$rf_correct_fun(@inputs) ) , "-- $correctVal";
4058 } 4062 }
4059 } 4063 }
4060 last if $errors; # break if there are any errors. 4064 last if $errors; # break if there are any errors.

Legend:
Removed from v.4927  
changed lines
  Added in v.4928

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9