1 | /* const.c |
---|
2 | * |
---|
3 | * Globally declared constants |
---|
4 | * |
---|
5 | * |
---|
6 | * |
---|
7 | * SYNOPSIS: |
---|
8 | * |
---|
9 | * extern double nameofconstant; |
---|
10 | * |
---|
11 | * |
---|
12 | * |
---|
13 | * |
---|
14 | * DESCRIPTION: |
---|
15 | * |
---|
16 | * This file contains a number of mathematical constants and |
---|
17 | * also some needed size parameters of the computer arithmetic. |
---|
18 | * The values are supplied as arrays of hexadecimal integers |
---|
19 | * for IEEE arithmetic; arrays of octal constants for DEC |
---|
20 | * arithmetic; and in a normal decimal scientific notation for |
---|
21 | * other machines. The particular notation used is determined |
---|
22 | * by a symbol (DEC, IBMPC, or UNK) defined in the include file |
---|
23 | * mconf.h. |
---|
24 | * |
---|
25 | * The default size parameters are as follows. |
---|
26 | * |
---|
27 | * For DEC and UNK modes: |
---|
28 | * MACHEP = 1.38777878078144567553E-17 2**-56 |
---|
29 | * MAXLOG = 8.8029691931113054295988E1 log(2**127) |
---|
30 | * MINLOG = -8.872283911167299960540E1 log(2**-128) |
---|
31 | * MAXNUM = 1.701411834604692317316873e38 2**127 |
---|
32 | * |
---|
33 | * For IEEE arithmetic (IBMPC): |
---|
34 | * MACHEP = 1.11022302462515654042E-16 2**-53 |
---|
35 | * MAXLOG = 7.09782712893383996843E2 log(2**1024) |
---|
36 | * MINLOG = -7.08396418532264106224E2 log(2**-1022) |
---|
37 | * MAXNUM = 1.7976931348623158E308 2**1024 |
---|
38 | * |
---|
39 | * The global symbols for mathematical constants are |
---|
40 | * PI = 3.14159265358979323846 pi |
---|
41 | * PIO2 = 1.57079632679489661923 pi/2 |
---|
42 | * PIO4 = 7.85398163397448309616E-1 pi/4 |
---|
43 | * SQRT2 = 1.41421356237309504880 sqrt(2) |
---|
44 | * SQRTH = 7.07106781186547524401E-1 sqrt(2)/2 |
---|
45 | * LOG2E = 1.4426950408889634073599 1/log(2) |
---|
46 | * SQ2OPI = 7.9788456080286535587989E-1 sqrt( 2/pi ) |
---|
47 | * LOGE2 = 6.93147180559945309417E-1 log(2) |
---|
48 | * LOGSQ2 = 3.46573590279972654709E-1 log(2)/2 |
---|
49 | * THPIO4 = 2.35619449019234492885 3*pi/4 |
---|
50 | * TWOOPI = 6.36619772367581343075535E-1 2/pi |
---|
51 | * |
---|
52 | * These lists are subject to change. |
---|
53 | */ |
---|
54 | |
---|
55 | /* const.c */ |
---|
56 | |
---|
57 | /* |
---|
58 | Cephes Math Library Release 2.3: March, 1995 |
---|
59 | Copyright 1984, 1995 by Stephen L. Moshier |
---|
60 | */ |
---|
61 | |
---|
62 | #include "mconf.h" |
---|
63 | |
---|
64 | #ifdef UNK |
---|
65 | #if 1 |
---|
66 | double MACHEP = 1.11022302462515654042E-16; /* 2**-53 */ |
---|
67 | #else |
---|
68 | double MACHEP = 1.38777878078144567553E-17; /* 2**-56 */ |
---|
69 | #endif |
---|
70 | double UFLOWTHRESH = 2.22507385850720138309E-308; /* 2**-1022 */ |
---|
71 | #ifdef DENORMAL |
---|
72 | double MAXLOG = 7.09782712893383996732E2; /* log(MAXNUM) */ |
---|
73 | /* double MINLOG = -7.44440071921381262314E2; */ /* log(2**-1074) */ |
---|
74 | double MINLOG = -7.451332191019412076235E2; /* log(2**-1075) */ |
---|
75 | #else |
---|
76 | double MAXLOG = 7.08396418532264106224E2; /* log 2**1022 */ |
---|
77 | double MINLOG = -7.08396418532264106224E2; /* log 2**-1022 */ |
---|
78 | #endif |
---|
79 | double MAXNUM = 1.79769313486231570815E308; /* 2**1024*(1-MACHEP) */ |
---|
80 | double PI = 3.14159265358979323846; /* pi */ |
---|
81 | double PIO2 = 1.57079632679489661923; /* pi/2 */ |
---|
82 | double PIO4 = 7.85398163397448309616E-1; /* pi/4 */ |
---|
83 | double SQRT2 = 1.41421356237309504880; /* sqrt(2) */ |
---|
84 | double SQRTH = 7.07106781186547524401E-1; /* sqrt(2)/2 */ |
---|
85 | double LOG2E = 1.4426950408889634073599; /* 1/log(2) */ |
---|
86 | double SQ2OPI = 7.9788456080286535587989E-1; /* sqrt( 2/pi ) */ |
---|
87 | double LOGE2 = 6.93147180559945309417E-1; /* log(2) */ |
---|
88 | double LOGSQ2 = 3.46573590279972654709E-1; /* log(2)/2 */ |
---|
89 | double THPIO4 = 2.35619449019234492885; /* 3*pi/4 */ |
---|
90 | double TWOOPI = 6.36619772367581343075535E-1; /* 2/pi */ |
---|
91 | #ifdef INFINITIES |
---|
92 | double INFINITY = 1.0/0.0; /* 99e999; */ |
---|
93 | #else |
---|
94 | double INFINITY = 1.79769313486231570815E308; /* 2**1024*(1-MACHEP) */ |
---|
95 | #endif |
---|
96 | #ifdef NANS |
---|
97 | double NAN = 1.0/0.0 - 1.0/0.0; |
---|
98 | #else |
---|
99 | double NAN = 0.0; |
---|
100 | #endif |
---|
101 | #ifdef MINUSZERO |
---|
102 | double NEGZERO = -0.0; |
---|
103 | #else |
---|
104 | double NEGZERO = 0.0; |
---|
105 | #endif |
---|
106 | #endif |
---|
107 | |
---|
108 | #ifdef IBMPC |
---|
109 | /* 2**-53 = 1.11022302462515654042E-16 */ |
---|
110 | unsigned short MACHEP[4] = {0x0000,0x0000,0x0000,0x3ca0}; |
---|
111 | unsigned short UFLOWTHRESH[4] = {0x0000,0x0000,0x0000,0x0010}; |
---|
112 | #ifdef DENORMAL |
---|
113 | /* log(MAXNUM) = 7.09782712893383996732224E2 */ |
---|
114 | unsigned short MAXLOG[4] = {0x39ef,0xfefa,0x2e42,0x4086}; |
---|
115 | /* log(2**-1074) = - -7.44440071921381262314E2 */ |
---|
116 | /*unsigned short MINLOG[4] = {0x71c3,0x446d,0x4385,0xc087};*/ |
---|
117 | unsigned short MINLOG[4] = {0x3052,0xd52d,0x4910,0xc087}; |
---|
118 | #else |
---|
119 | /* log(2**1022) = 7.08396418532264106224E2 */ |
---|
120 | unsigned short MAXLOG[4] = {0xbcd2,0xdd7a,0x232b,0x4086}; |
---|
121 | /* log(2**-1022) = - 7.08396418532264106224E2 */ |
---|
122 | unsigned short MINLOG[4] = {0xbcd2,0xdd7a,0x232b,0xc086}; |
---|
123 | #endif |
---|
124 | /* 2**1024*(1-MACHEP) = 1.7976931348623158E308 */ |
---|
125 | unsigned short MAXNUM[4] = {0xffff,0xffff,0xffff,0x7fef}; |
---|
126 | unsigned short PI[4] = {0x2d18,0x5444,0x21fb,0x4009}; |
---|
127 | unsigned short PIO2[4] = {0x2d18,0x5444,0x21fb,0x3ff9}; |
---|
128 | unsigned short PIO4[4] = {0x2d18,0x5444,0x21fb,0x3fe9}; |
---|
129 | unsigned short SQRT2[4] = {0x3bcd,0x667f,0xa09e,0x3ff6}; |
---|
130 | unsigned short SQRTH[4] = {0x3bcd,0x667f,0xa09e,0x3fe6}; |
---|
131 | unsigned short LOG2E[4] = {0x82fe,0x652b,0x1547,0x3ff7}; |
---|
132 | unsigned short SQ2OPI[4] = {0x3651,0x33d4,0x8845,0x3fe9}; |
---|
133 | unsigned short LOGE2[4] = {0x39ef,0xfefa,0x2e42,0x3fe6}; |
---|
134 | unsigned short LOGSQ2[4] = {0x39ef,0xfefa,0x2e42,0x3fd6}; |
---|
135 | unsigned short THPIO4[4] = {0x21d2,0x7f33,0xd97c,0x4002}; |
---|
136 | unsigned short TWOOPI[4] = {0xc883,0x6dc9,0x5f30,0x3fe4}; |
---|
137 | #ifdef INFINITIES |
---|
138 | unsigned short INFINITY[4] = {0x0000,0x0000,0x0000,0x7ff0}; |
---|
139 | #else |
---|
140 | unsigned short INFINITY[4] = {0xffff,0xffff,0xffff,0x7fef}; |
---|
141 | #endif |
---|
142 | #ifdef NANS |
---|
143 | unsigned short NAN[4] = {0x0000,0x0000,0x0000,0x7ffc}; |
---|
144 | #else |
---|
145 | unsigned short NAN[4] = {0x0000,0x0000,0x0000,0x0000}; |
---|
146 | #endif |
---|
147 | #ifdef MINUSZERO |
---|
148 | unsigned short NEGZERO[4] = {0x0000,0x0000,0x0000,0x8000}; |
---|
149 | #else |
---|
150 | unsigned short NEGZERO[4] = {0x0000,0x0000,0x0000,0x0000}; |
---|
151 | #endif |
---|
152 | #endif |
---|
153 | |
---|
154 | #ifdef MIEEE |
---|
155 | /* 2**-53 = 1.11022302462515654042E-16 */ |
---|
156 | unsigned short MACHEP[4] = {0x3ca0,0x0000,0x0000,0x0000}; |
---|
157 | unsigned short UFLOWTHRESH[4] = {0x0010,0x0000,0x0000,0x0000}; |
---|
158 | #ifdef DENORMAL |
---|
159 | /* log(2**1024) = 7.09782712893383996843E2 */ |
---|
160 | unsigned short MAXLOG[4] = {0x4086,0x2e42,0xfefa,0x39ef}; |
---|
161 | /* log(2**-1074) = - -7.44440071921381262314E2 */ |
---|
162 | /* unsigned short MINLOG[4] = {0xc087,0x4385,0x446d,0x71c3}; */ |
---|
163 | unsigned short MINLOG[4] = {0xc087,0x4910,0xd52d,0x3052}; |
---|
164 | #else |
---|
165 | /* log(2**1022) = 7.08396418532264106224E2 */ |
---|
166 | unsigned short MAXLOG[4] = {0x4086,0x232b,0xdd7a,0xbcd2}; |
---|
167 | /* log(2**-1022) = - 7.08396418532264106224E2 */ |
---|
168 | unsigned short MINLOG[4] = {0xc086,0x232b,0xdd7a,0xbcd2}; |
---|
169 | #endif |
---|
170 | /* 2**1024*(1-MACHEP) = 1.7976931348623158E308 */ |
---|
171 | unsigned short MAXNUM[4] = {0x7fef,0xffff,0xffff,0xffff}; |
---|
172 | unsigned short PI[4] = {0x4009,0x21fb,0x5444,0x2d18}; |
---|
173 | unsigned short PIO2[4] = {0x3ff9,0x21fb,0x5444,0x2d18}; |
---|
174 | unsigned short PIO4[4] = {0x3fe9,0x21fb,0x5444,0x2d18}; |
---|
175 | unsigned short SQRT2[4] = {0x3ff6,0xa09e,0x667f,0x3bcd}; |
---|
176 | unsigned short SQRTH[4] = {0x3fe6,0xa09e,0x667f,0x3bcd}; |
---|
177 | unsigned short LOG2E[4] = {0x3ff7,0x1547,0x652b,0x82fe}; |
---|
178 | unsigned short SQ2OPI[4] = {0x3fe9,0x8845,0x33d4,0x3651}; |
---|
179 | unsigned short LOGE2[4] = {0x3fe6,0x2e42,0xfefa,0x39ef}; |
---|
180 | unsigned short LOGSQ2[4] = {0x3fd6,0x2e42,0xfefa,0x39ef}; |
---|
181 | unsigned short THPIO4[4] = {0x4002,0xd97c,0x7f33,0x21d2}; |
---|
182 | unsigned short TWOOPI[4] = {0x3fe4,0x5f30,0x6dc9,0xc883}; |
---|
183 | #ifdef INFINITIES |
---|
184 | unsigned short INFINITY[4] = {0x7ff0,0x0000,0x0000,0x0000}; |
---|
185 | #else |
---|
186 | unsigned short INFINITY[4] = {0x7fef,0xffff,0xffff,0xffff}; |
---|
187 | #endif |
---|
188 | #ifdef NANS |
---|
189 | unsigned short NAN[4] = {0x7ff8,0x0000,0x0000,0x0000}; |
---|
190 | #else |
---|
191 | unsigned short NAN[4] = {0x0000,0x0000,0x0000,0x0000}; |
---|
192 | #endif |
---|
193 | #ifdef MINUSZERO |
---|
194 | unsigned short NEGZERO[4] = {0x8000,0x0000,0x0000,0x0000}; |
---|
195 | #else |
---|
196 | unsigned short NEGZERO[4] = {0x0000,0x0000,0x0000,0x0000}; |
---|
197 | #endif |
---|
198 | #endif |
---|
199 | |
---|
200 | #ifdef DEC |
---|
201 | /* 2**-56 = 1.38777878078144567553E-17 */ |
---|
202 | unsigned short MACHEP[4] = {0022200,0000000,0000000,0000000}; |
---|
203 | unsigned short UFLOWTHRESH[4] = {0x0080,0x0000,0x0000,0x0000}; |
---|
204 | /* log 2**127 = 88.029691931113054295988 */ |
---|
205 | unsigned short MAXLOG[4] = {041660,007463,0143742,025733,}; |
---|
206 | /* log 2**-128 = -88.72283911167299960540 */ |
---|
207 | unsigned short MINLOG[4] = {0141661,071027,0173721,0147572,}; |
---|
208 | /* 2**127 = 1.701411834604692317316873e38 */ |
---|
209 | unsigned short MAXNUM[4] = {077777,0177777,0177777,0177777,}; |
---|
210 | unsigned short PI[4] = {040511,007732,0121041,064302,}; |
---|
211 | unsigned short PIO2[4] = {040311,007732,0121041,064302,}; |
---|
212 | unsigned short PIO4[4] = {040111,007732,0121041,064302,}; |
---|
213 | unsigned short SQRT2[4] = {040265,002363,031771,0157145,}; |
---|
214 | unsigned short SQRTH[4] = {040065,002363,031771,0157144,}; |
---|
215 | unsigned short LOG2E[4] = {040270,0125073,024534,013761,}; |
---|
216 | unsigned short SQ2OPI[4] = {040114,041051,0117241,0131204,}; |
---|
217 | unsigned short LOGE2[4] = {040061,071027,0173721,0147572,}; |
---|
218 | unsigned short LOGSQ2[4] = {037661,071027,0173721,0147572,}; |
---|
219 | unsigned short THPIO4[4] = {040426,0145743,0174631,007222,}; |
---|
220 | unsigned short TWOOPI[4] = {040042,0174603,067116,042025,}; |
---|
221 | /* Approximate infinity by MAXNUM. */ |
---|
222 | unsigned short INFINITY[4] = {077777,0177777,0177777,0177777,}; |
---|
223 | unsigned short NAN[4] = {0000000,0000000,0000000,0000000}; |
---|
224 | #ifdef MINUSZERO |
---|
225 | unsigned short NEGZERO[4] = {0000000,0000000,0000000,0100000}; |
---|
226 | #else |
---|
227 | unsigned short NEGZERO[4] = {0000000,0000000,0000000,0000000}; |
---|
228 | #endif |
---|
229 | #endif |
---|
230 | |
---|
231 | #ifndef UNK |
---|
232 | extern unsigned short MACHEP[]; |
---|
233 | extern unsigned short UFLOWTHRESH[]; |
---|
234 | extern unsigned short MAXLOG[]; |
---|
235 | extern unsigned short UNDLOG[]; |
---|
236 | extern unsigned short MINLOG[]; |
---|
237 | extern unsigned short MAXNUM[]; |
---|
238 | extern unsigned short PI[]; |
---|
239 | extern unsigned short PIO2[]; |
---|
240 | extern unsigned short PIO4[]; |
---|
241 | extern unsigned short SQRT2[]; |
---|
242 | extern unsigned short SQRTH[]; |
---|
243 | extern unsigned short LOG2E[]; |
---|
244 | extern unsigned short SQ2OPI[]; |
---|
245 | extern unsigned short LOGE2[]; |
---|
246 | extern unsigned short LOGSQ2[]; |
---|
247 | extern unsigned short THPIO4[]; |
---|
248 | extern unsigned short TWOOPI[]; |
---|
249 | extern unsigned short INFINITY[]; |
---|
250 | extern unsigned short NAN[]; |
---|
251 | extern unsigned short NEGZERO[]; |
---|
252 | #endif |
---|