"Fossies" - the Fresh Open Source Software Archive 
As a special service "Fossies" has tried to format the requested text file into HTML format (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1 InstallDocumentation(
2 rec(
3 kind:= "KEYWORD",
4 name:= "Constants",
5 short :=
6 "For convenience some constants are predefined in KASH. "+
7 "These constants cannot be overwritten. Some constants, namely 'E' and 'PI'. "+
8 "change their value with the global precision 'Precision'. By convention constants are "+
9 "written in capitals.\n\n"+
10 "Enter '?*.|CONSTANT' to see a list of all constants.",
11 see:= [DocHash("InstallConstants()"),
12 DocHash("Precision()"),
13 DocHash("Precision(elt-ord^rat)")]
14 )
15 );
16 ###################################################################
17 C := VOID;
18 E := VOID;
19 I := VOID;
20 INFTY := VOID;
21 PI := VOID;
22 Q := VOID;
23 R := VOID;
24 X := VOID;
25 Z := VOID;
26 ZX := VOID;
27
28 _InstallConstants := function()
29 C := ComplexField();
30 R := RealField();
31 Q := RationalField();
32 PI := Pi(R);
33 E := Exp(1);
34 I := C.1;
35 AssignNames_(C,["I"]);
36 INFTY := Infinity();
37 Z := IntegerRing();
38 ZX := PolynomialAlgebra(Z);
39 X := ZX.1;
40 AssignNames_(ZX,["X"]);
41 end;
42
43 InstallMethod(
44 rec(
45 kind:= "FUNCTION",
46 name:= "InstallConstants",
47 sin := [ ],
48 sou := [ ],
49 short :=
50 "Reinitialize the constants\n"+
51 "C := ComplexField();\n"+
52 "E := Exp(1);\n"+
53 "I := C.1;\n"+
54 "PI:= Pi(R);\n"+
55 "Q := RationalField();\n"+
56 "R := RealField();\n"+
57 "X := ZX.1;\n"+
58 "Z := Integers();\n"+
59 "ZX:= PolynomialRing(Z);",
60 see:= [DocHash("Constants"),
61 DocHash("Precision(elt-ord^rat)")]
62 ),
63 _InstallConstants
64 );
65 InstallConstants();
66 #################### install docu for constants initialized above
67 InstallDocumentation(
68 rec(
69 kind:= "CONSTANT",
70 name:= "Q",
71 sou := [[Type(Q)]],
72 short :=
73 "The field of rational numbers."
74 )
75 );
76 InstallDocumentation(
77 rec(
78 kind:= "CONSTANT",
79 name:= "Z",
80 sou := [[Type(Z)]],
81 short :=
82 "The ring of rational integers."
83 )
84 );
85 InstallDocumentation(
86 rec(
87 kind:= "CONSTANT",
88 name:= "ZX",
89 sou := [[Type(ZX)]],
90 short :=
91 "The ring of polynomials in X over the ring of rational integers Z."
92 )
93 );
94 InstallDocumentation(
95 rec(
96 kind:= "CONSTANT",
97 name:= "X",
98 sou := [[Type(X)]],
99 short :=
100 "The variable of the ring of polynomials ZX over the ring of rational integers Z."
101 )
102 );
103 InstallDocumentation(
104 rec(
105 kind:= "CONSTANT",
106 name:= "R",
107 sou := [[fld^rea]],
108 short :=
109 "The global real field."
110 )
111 );
112 InstallDocumentation(
113 rec(
114 kind:= "CONSTANT",
115 name:= "C",
116 sou := [[Type(C)]],
117 short :=
118 "The global complex field."
119 )
120 );
121 InstallDocumentation(
122 rec(
123 kind:= "CONSTANT",
124 name:= "I",
125 sou := [[Type(I)]],
126 short :=
127 "A complex number I with I^2=-1."
128 )
129 );
130 InstallDocumentation(
131 rec(
132 kind:= "CONSTANT",
133 name:= "E",
134 sou := [[Type(E)]],
135 short :=
136 "Eulers constant to the global precision 'Precision()'."
137 )
138 );
139
140 ##################################################################
141
142 InstallMethod(
143 rec(
144 kind:= "FUNCTION",
145 name:= "Precision",
146 sin := [ ],
147 sou := [[elt-ord^rat,"prec"]],
148 short :=
149 "Returns the global precision for real and complex computations in the shell.",
150 see := [DocHash("Precision(elt-ord^rat)")]
151 ),
152 function()
153 return Precision(RealField());
154 end
155 );
156
157 InstallMethod(
158 rec(
159 kind:= "FUNCTION",
160 name:= "Precision",
161 sin := [[elt-ord^rat,"n"]],
162 sou := [[elt-ord^rat,"prec"]],
163 short :=
164 "Sets the global precision for real and complex computations in the shell to 'n' and\
165 returns the new global precision. The default precision is 20. This function\
166 also reinstalls the constants C, E, PI, Q, R, X, Z, ZX.",
167 see := [DocHash("InstallConstants()"),
168 DocHash("SetDefaultRealFieldPrecision(elt-ord^rat)")]
169 ),
170 function(n)
171 SetDefaultRealFieldPrecision(n);
172 InstallConstants();
173 return Precision(RealField());
174 end
175 );