version 1.48, 2010/11/24 15:30:45
|
version 1.49, 2010/12/03 00:52:59
|
Line 943 sub functionplotrulecheck {
|
Line 943 sub functionplotrulecheck {
|
$percent=($percent>0?$percent:5); |
$percent=($percent>0?$percent:5); |
&addlog("================="); |
&addlog("================="); |
&addlog("Rule $label for ".($derivative<0?'integral':('function itself','first derivative','second derivative')[$derivative])." $relationship $value"); |
&addlog("Rule $label for ".($derivative<0?'integral':('function itself','first derivative','second derivative')[$derivative])." $relationship $value"); |
|
if ((defined($minimumlength)) || (defined($maximumlength))) { |
|
&addlog("Minimumlength $minimumlength Maximumlength $maximumlength"); |
|
} |
my $li=0; |
my $li=0; |
my $lh=400; |
my $lh=400; |
|
|
Line 1037 sub functionplotrulecheck {
|
Line 1040 sub functionplotrulecheck {
|
&addlog("Actual value ".(defined($val)?$val:'undef').", expected $value, tolerance $tol"); |
&addlog("Actual value ".(defined($val)?$val:'undef').", expected $value, tolerance $tol"); |
&addlog("Condition not fulfilled at x=".&actualval($i,$xmin,$xmax)." (".$Apache::functionplotresponse::actualxval[$i]."; index $i)"); |
&addlog("Condition not fulfilled at x=".&actualval($i,$xmin,$xmax)." (".$Apache::functionplotresponse::actualxval[$i]."; index $i)"); |
if (($findupper) && ($i>$li)) { |
if (($findupper) && ($i>$li)) { |
# check for minimum and maximum lengths |
# Check lengths |
my $length=&actualval($i,$xmin,$xmax)-&actualval($li,$xmin,$xmax); |
unless (&checklength($i,$li,$minimumlength,$maximumlength,$xmin,$xmax,$label)) { return 0; } |
if ($minimumlength) { |
# Successfully found a new label, set it |
if ($length<$minimumlength) { |
|
&addlog("Rule $label failed, actual length $length, minimum length $minimumlength"); |
|
return 0; |
|
} |
|
} |
|
if ($maximumlength) { |
|
if ($length>$maximumlength) { |
|
&addlog("Rule $label failed, actual length $length, maximum length $maximumlength"); |
|
return 0; |
|
} |
|
} |
|
$Apache::functionplotresponse::functionplotrulelabels{$xfinallabel}=$i; |
$Apache::functionplotresponse::functionplotrulelabels{$xfinallabel}=$i; |
&addlog("Rule $label passed, setting label $xfinallabel"); |
&addlog("Rule $label passed, setting label $xfinallabel"); |
return 1; |
return 1; |
} else { |
} else { |
&addlog("Rule $label failed."); |
&addlog("Rule $label failed."); |
my $hintlabel=$label; |
&setfailed($label); |
$hintlabel=~s/^R//; |
|
push(@Apache::functionplotresponse::failedrules,$hintlabel); |
|
&addlog("Set hint condition $hintlabel"); |
|
return 0; |
return 0; |
} |
} |
} |
} |
} |
} |
} |
} |
|
# Corner case where this makes sense: using start or stop as defined labels |
|
unless (&checklength($lh,$li,$minimumlength,$maximumlength,$xmin,$xmax,$label)) { return 0; } |
&addlog("Rule $label passed."); |
&addlog("Rule $label passed."); |
return 1; |
return 1; |
} |
} |
|
|
|
# |
|
# check for minimum and maximum lengths |
|
# |
|
|
|
sub checklength { |
|
my ($i,$li,$minimumlength,$maximumlength,$xmin,$xmax,$label)=@_; |
|
unless (($minimumlength) || ($maximumlength)) { return 1; } |
|
my $length=&actualval($i,$xmin,$xmax)-&actualval($li,$xmin,$xmax); |
|
if ($minimumlength) { |
|
if ($length<$minimumlength) { |
|
&addlog("Rule $label failed, actual length $length, minimum length $minimumlength"); |
|
&setfailed($label); |
|
return 0; |
|
} |
|
} |
|
if ($maximumlength) { |
|
if ($length>$maximumlength) { |
|
&addlog("Rule $label failed, actual length $length, maximum length $maximumlength"); |
|
&setfailed($label); |
|
return 0; |
|
} |
|
} |
|
return 1; |
|
} |
|
|
|
sub setfailed { |
|
my ($label)=@_; |
|
my $hintlabel=$label; |
|
$hintlabel=~s/^R//; |
|
push(@Apache::functionplotresponse::failedrules,$hintlabel); |
|
&addlog("Set hint condition $hintlabel"); |
|
} |
|
|
sub start_functionplotruleset { |
sub start_functionplotruleset { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
if ($target eq 'edit') { |
if ($target eq 'edit') { |