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

Annotation of /trunk/pg/macros/Value.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5373 - (view) (download) (as text)

1 : gage 4997
2 :    
3 : dpvc 5373 =head1 DESCRIPTION
4 : gage 4997
5 : dpvc 5373 #
6 :     # Declares constructors for MathObjects
7 :     #
8 : dpvc 2576
9 : gage 4997 =cut
10 :    
11 : gage 5145 =head3 Constructors for the various Mathobject types
12 : gage 4997
13 : gage 5145 =pod
14 : gage 4997
15 : gage 5145 MathObjects are objects which behave much like you would expect
16 : dpvc 5373 their true mathematical counterparts to behave.
17 :    
18 : gage 5145 MathObject types (classes) -- defined in Value.pl
19 :    
20 :     Standard
21 :     Real
22 :     Behave like real numbers
23 :     Infinity
24 :     Extended real numbers (infinities) -- Also complex
25 :     numbers???
26 :     infinity
27 :     - infinity
28 :     infinite (either plus or minus infinity)
29 :     Complex
30 :     Behave like complex numbers. The interpretations of plus
31 :     and times are those standardly used for mathematical
32 :     complex numbers
33 :     List objects -- which means that they involve delimiters
34 :     (parentheses) of some type.
35 :     Point
36 :     Vector
37 :     Matrix
38 :     List
39 :     Subsets of Reals
40 :     Intervals
41 :     Sets (finite collections of points
42 :     Union (of intervals and sets)
43 :     String -- special purpose
44 :     Allows comparison with a string
45 :     Formula -- roughly a function with values as defined above.
46 :     Complex object whose output is one of the MathObject values
47 :     listed above.
48 :     A formula object contains a parse tree inside it which allows
49 :     you to calculate output values from given input values.
50 :     This MathObject is more complicated than the ones above.
51 : dpvc 5373
52 : gage 5145 Constructing MathObjects
53 :     $a = Real(3.5);
54 :     $a = Real("345/45");
55 :     $c = Complex(5,4);
56 :     $c = Complex("5+4i");
57 :    
58 :     See Value.pm for MathObject methods
59 :    
60 :     See Parser.pm for information on turning strings into MathObjects.
61 :    
62 : gage 4997 =cut
63 :    
64 :    
65 : dpvc 4990 sub String {Value->Package("String")->new(@_)}
66 :     sub Real {Value->Package("Real")->new(@_)}
67 :     sub Complex {Value->Package("Complex")->new(@_)}
68 :     sub Point {Value->Package("Point")->new(@_)}
69 :     sub Vector {Value->Package("Vector")->new(@_)}
70 :     sub Matrix {Value->Package("Matrix")->new(@_)}
71 :     sub List {Value->Package("List")->new(@_)}
72 :     sub Interval {Value->Package("Interval")->new(@_)}
73 :     sub Set {Value->Package("Set")->new(@_)}
74 :     sub Union {Value->Package("Union")->new(@_)}
75 : dpvc 2576
76 : dpvc 4990 sub ColumnVector {Value->Package("Vector")->new(@_)->with(ColumnVector=>1,open=>undef,close=>undef)}
77 : dpvc 3267
78 : dpvc 4990 # sub Formula {Value->Package("Formula")->new(@_)} # in Parser.pl
79 : dpvc 2576
80 : dpvc 5071 =head3 Closed($point)
81 : gage 4997
82 : dpvc 5373 #
83 :     # Make a point or list a closed interval.
84 :     # (Obsolete: use $x->with(open=>'[',close=>']') instead.)
85 :     #
86 : gage 4997
87 :     =cut
88 :    
89 : dpvc 2626 sub Closed {
90 :     my $x = shift;
91 :     if (Value::isValue($x)) {$x->{open} = '['; $x->{close} = ']'}
92 :     return $x;
93 :     }
94 :    
95 : gage 4997 =head3 NOTE:
96 :    
97 : gage 5145 ###########################################################################
98 :     #
99 :     # Make it possible to use 1+3*i in perl rather than 1+3*$i or 1+3*i()
100 :     # as well as 3*pi instead of 3*pi()
101 : dpvc 5373
102 : gage 5145 #sub i () {Value->Package("Complex")->i}; # defined in Parser.pl
103 :     #sub pi () {Value->Package("Complex")->pi}; # defined in dangerousMacros.pl
104 :     #sub Infinity () {Value->Package("Infinity")->new()} # defined in dangerousMacros.pl
105 : gage 4997
106 :     =cut
107 :    
108 : dpvc 2644 sub _Value_init {}; # don't let loadMacros load it again
109 :    
110 :     ###########################################################################
111 :    
112 : dpvc 2576 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9