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

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

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

Revision 3602 Revision 4808
1loadMacros("Parser.pl"); 1loadMacros("Parser.pl");
2 2
3sub _contextLimitedComplex_init {}; # don't load it again 3sub _contextLimitedComplex_init {}; # don't load it again
4 4
5=head3 Context("LimitedComplex")
6
5########################################################## 7 ##########################################################
6# 8 #
7# Implements a context in which complex numbers can be entered, 9 # Implements a context in which complex numbers can be entered,
8# but no complex operations are permitted. So students will 10 # but no complex operations are permitted. So students will
9# be able to perform operations within the real and imaginary 11 # be able to perform operations within the real and imaginary
10# parts of the complex numbers, but not between complex numbers. 12 # parts of the complex numbers, but not between complex numbers.
11# 13 #
12# 14 #
13# Complex Numbers can still be entered in a+bi or a*e^(bt) form. 15 # Complex Numbers can still be entered in a+bi or a*e^(bt) form.
14# The e and i are allowed to be entered only once, so we have 16 # The e and i are allowed to be entered only once, so we have
15# to keep track of that, and allow SOME complex operations, 17 # to keep track of that, and allow SOME complex operations,
16# but only when one term is one of these constants (or an expression 18 # but only when one term is one of these constants (or an expression
17# involving it that we've already OKed). 19 # involving it that we've already OKed).
18# 20 #
19# You control which format to use by setting the complex_format 21 # You control which format to use by setting the complex_format
20# context flag to 'cartesian', 'polar' or 'either'. E.g., 22 # context flag to 'cartesian', 'polar' or 'either'. E.g.,
21# 23 #
22# Context()->flags->set(complex_format => 'polar'); 24 # Context()->flags->set(complex_format => 'polar');
23# 25 #
24# The default is 'either'. There are predefined contexts that 26 # The default is 'either'. There are predefined contexts that
25# already have these values set: 27 # already have these values set:
26# 28 #
27# Context("LimitedComplex-cartesian"); 29 # Context("LimitedComplex-cartesian");
28# Context("LimitedComplex-polar"); 30 # Context("LimitedComplex-polar");
29# 31 #
30# You can require that the a and b used in these forms be strictly 32 # You can require that the a and b used in these forms be strictly
31# numbers (not expressions) by setting the strict_numeric flag and 33 # numbers (not expressions) by setting the strict_numeric flag and
32# disabling all the functions: 34 # disabling all the functions:
33# 35 #
34# Context()->flags->set(strict_numeric=>1); 36 # Context()->flags->set(strict_numeric=>1);
35# Context()->functions->disable('All'); 37 # Context()->functions->disable('All');
36# 38 #
37# There are predefined contexts that already have these values 39 # There are predefined contexts that already have these values
38# set: 40 # set:
39# 41 #
40# Context("LimitedComplex-cartesian-strict"); 42 # Context("LimitedComplex-cartesian-strict");
41# Context("LimitedComplex-polar-strict"); 43 # Context("LimitedComplex-polar-strict");
42# Context("LimitedComplex-strict"); 44 # Context("LimitedComplex-strict");
43# 45 #
44 46
45# 47 #
46# Handle common checking for BOPs 48 # Handle common checking for BOPs
47# 49 #
50
51=cut
52
48package LimitedComplex::BOP; 53package LimitedComplex::BOP;
49 54
50# 55#
51# Do original check and then if the operands are numbers, its OK. 56# Do original check and then if the operands are numbers, its OK.
52# Otherwise, do an operator-specific check for if complex numbers are OK. 57# Otherwise, do an operator-specific check for if complex numbers are OK.

Legend:
Removed from v.3602  
changed lines
  Added in v.4808

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9