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

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

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

Revision 5372 Revision 5373
1loadMacros("MathObjects.pl"); 1loadMacros("MathObjects.pl");
2 2
3sub _contextLimitedPowers_init {}; # don't load it again 3sub _contextLimitedPowers_init {}; # don't load it again
4 4
5=head3 LimitedPowers::NoBaseE(); 5=head3 LimitedPowers::NoBaseE();
6
6=head3 LimitedPowers::OnlyIntegers(); 7=head3 LimitedPowers::OnlyIntegers();
8
7=head3 LimitedPowers::OnlyNonNegativeIntegers(); 9=head3 LimitedPowers::OnlyNonNegativeIntegers();
10
8=head3 LimitedPowers::OnlyPositiveIntegers(); 11=head3 LimitedPowers::OnlyPositiveIntegers();
12
9=head3 LimitedPowers::OnlyNonTrivialPositiveIntegers(); 13=head3 LimitedPowers::OnlyNonTrivialPositiveIntegers();
10 14
11########################################################## 15 ##########################################################
12# 16 #
13# Implements subclasses of the "^" operator that restrict 17 # Implements subclasses of the "^" operator that restrict
14# the base or power that is allowed. There are four 18 # the base or power that is allowed. There are four
15# available restrictions: 19 # available restrictions:
16# 20 #
17# No raising e to a power 21 # No raising e to a power
18# Only allowing integer powers (positive or negative) 22 # Only allowing integer powers (positive or negative)
19# Only allowing positive interger powers 23 # Only allowing positive interger powers
20# Only allowing positive interger powers (and 0) 24 # Only allowing positive interger powers (and 0)
21# 25 #
22# You install these via one of the commands: 26 # You install these via one of the commands:
23# 27 #
24# LimitedPowers::NoBaseE(); 28 # LimitedPowers::NoBaseE();
25# LimitedPowers::OnlyIntegers(); 29 # LimitedPowers::OnlyIntegers();
26# LimitedPowers::OnlyPositiveIntegers(); 30 # LimitedPowers::OnlyPositiveIntegers();
27# LimitedPowers::OnlyNonNegativeIntegers(); 31 # LimitedPowers::OnlyNonNegativeIntegers();
28# 32 #
29# Only one of the three can be in effect at a time; setting 33 # Only one of the three can be in effect at a time; setting
30# a second one overrides the first. 34 # a second one overrides the first.
31# 35 #
32# These function affect the current context, or you can pass 36 # These function affect the current context, or you can pass
33# a context reference, as in 37 # a context reference, as in
34# 38 #
35# $context = Context("Numeric")->copy; 39 # $context = Context("Numeric")->copy;
36# LimitedPowers::OnlyIntegers($context); 40 # LimitedPowers::OnlyIntegers($context);
37# 41 #
38# For the Interger power functions, you can pass additional 42 # For the Interger power functions, you can pass additional
39# parameters that control the range of values that are allowed 43 # parameters that control the range of values that are allowed
40# for the powers. The oprtions include: 44 # for the powers. The oprtions include:
41# 45 #
42# minPower => m only integer powers bigger than or equal 46 # minPower => m only integer powers bigger than or equal
43# to m are allowed. (If m is undef, then 47 # to m are allowed. (If m is undef, then
44# there is no minimum power.) 48 # there is no minimum power.)
45# 49 #
46# maxPower => M only integer powers less than or equal 50 # maxPower => M only integer powers less than or equal
47# to M are allowed. (If M is undef, then 51 # to M are allowed. (If M is undef, then
48# there is no maximum power.) 52 # there is no maximum power.)
49# 53 #
50# message => "text" a description of the type of power 54 # message => "text" a description of the type of power
51# allowed (e.g., "positive integer constants"); 55 # allowed (e.g., "positive integer constants");
52# 56 #
53# checker => code a reference to a subroutine that will be 57 # checker => code a reference to a subroutine that will be
54# used to check if the powers are acceptable. 58 # used to check if the powers are acceptable.
55# It should accept a reference to the BOP::power 59 # It should accept a reference to the BOP::power
56# structure and return 1 or 0 depending on 60 # structure and return 1 or 0 depending on
57# whether the power is OK or not. 61 # whether the power is OK or not.
58# 62 #
59# For example: 63 # For example:
60# 64 #
61# LimitedPowers::OnlyIntegers( 65 # LimitedPowers::OnlyIntegers(
62# minPower => -5, maxPower => 5, 66 # minPower => -5, maxPower => 5,
63# message => "integer constants between -5 and 5", 67 # message => "integer constants between -5 and 5",
64# ); 68 # );
65# 69 #
66# would accept only powers between -5 and 5, while 70 # would accept only powers between -5 and 5, while
67# 71 #
68# LimitedPowers::OnlyIntegers( 72 # LimitedPowers::OnlyIntegers(
69# checker => sub { 73 # checker => sub {
70# return 0 unless LimitedPowers::isInteger(@_); 74 # return 0 unless LimitedPowers::isInteger(@_);
71# my $self = shift; my $p = shift; # the power as a constant 75 # my $self = shift; my $p = shift; # the power as a constant
72# return $p != 0 && $p != 1; 76 # return $p != 0 && $p != 1;
73# }, 77 # },
74# message => "integer constants other than 0 or 1", 78 # message => "integer constants other than 0 or 1",
75# ); 79 # );
76# 80 #
77# would accept any integer power other than 0 and 1. 81 # would accept any integer power other than 0 and 1.
78# 82 #
79########################################################## 83 ##########################################################
80 84
81=cut 85=cut
82 86
83package LimitedPowers; 87package LimitedPowers;
84 88

Legend:
Removed from v.5372  
changed lines
  Added in v.5373

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9