5336
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
4380
|
3 |
"
|
|
4 |
COPYRIGHT (c) 2017 by eXept Software AG
|
5315
|
5 |
All Rights Reserved
|
4380
|
6 |
|
|
7 |
This software is furnished under a license and may be used
|
|
8 |
only in accordance with the terms of that license and with the
|
|
9 |
inclusion of the above copyright notice. This software may not
|
|
10 |
be provided or otherwise made available to, or used by, any
|
|
11 |
other person. No title to or ownership of the software is
|
|
12 |
hereby transferred.
|
|
13 |
"
|
|
14 |
"{ Package: 'stx:libbasic2' }"
|
|
15 |
|
|
16 |
"{ NameSpace: Smalltalk }"
|
|
17 |
|
|
18 |
LimitedPrecisionReal variableByteSubclass:#QDouble
|
5326
|
19 |
instanceVariableNames:''
|
5336
|
20 |
classVariableNames:'DefaultPrintFormat DefaultPrintPrecision E Epsilon FMax FMin
|
|
21 |
InvFact Ln10 Ln2 NaN Pi QDoubleOne QDoubleZero'
|
5326
|
22 |
poolDictionaries:''
|
|
23 |
category:'Magnitude-Numbers'
|
4380
|
24 |
!
|
|
25 |
|
|
26 |
!QDouble primitiveDefinitions!
|
4413
|
27 |
%{
|
|
28 |
#include <stdio.h>
|
|
29 |
#include <errno.h>
|
|
30 |
|
|
31 |
#define __USE_ISOC9X 1
|
|
32 |
#define __USE_ISOC99 1
|
|
33 |
#include <math.h>
|
|
34 |
|
|
35 |
/*
|
|
36 |
* on some systems, errno is a macro ... check for it here
|
|
37 |
*/
|
|
38 |
#ifndef errno
|
|
39 |
extern errno;
|
|
40 |
#endif
|
|
41 |
|
|
42 |
#if !defined (__win32__)
|
|
43 |
# include <locale.h>
|
|
44 |
#endif
|
|
45 |
|
|
46 |
#if defined (__aix__)
|
|
47 |
# include <float.h>
|
|
48 |
#endif
|
|
49 |
|
|
50 |
#if defined(__irix__) || defined(__solaris__) || defined(__sunos__)
|
|
51 |
# include <nan.h>
|
|
52 |
#endif
|
|
53 |
|
|
54 |
#if defined(__linux__)
|
|
55 |
# ifndef NAN
|
|
56 |
# include <bits/nan.h>
|
|
57 |
# endif
|
|
58 |
#endif
|
|
59 |
|
|
60 |
#ifdef __win32__
|
|
61 |
# ifndef isinf
|
|
62 |
# define isinf(x) \
|
5315
|
63 |
((((unsigned int *)(&x))[0] == 0x00000000) && \
|
|
64 |
((((unsigned int *)(&x))[1] & 0x7FF00000) == 0x7FF00000))
|
4413
|
65 |
# endif
|
|
66 |
#endif
|
|
67 |
|
5315
|
68 |
/*
|
|
69 |
* fpu_fix_start:
|
|
70 |
* Set the round-to-double flag, and save the old control word in old_cw.
|
|
71 |
* fpu_fix_end:
|
|
72 |
* Restore the control word.
|
|
73 |
*/
|
4413
|
74 |
#if defined(__x86__) || defined(__x86_64__)
|
|
75 |
|
|
76 |
# ifndef _FPU_EXTENDED
|
|
77 |
# define _FPU_EXTENDED 0x0300
|
|
78 |
# endif
|
|
79 |
|
|
80 |
# ifndef _FPU_DOUBLE
|
|
81 |
# define _FPU_DOUBLE 0x0200
|
|
82 |
# endif
|
|
83 |
|
5315
|
84 |
# if defined( __win32__ )
|
|
85 |
# if defined( __BORLANDC__ )
|
|
86 |
|
|
87 |
# define fpu_fix_start(old_cw_ptr) { \
|
|
88 |
*old_cw_ptr = _control87(0, 0); \
|
|
89 |
_control87(_FPU_DOUBLE, _FPU_EXTENDED);\
|
|
90 |
}
|
|
91 |
|
|
92 |
# define fpu_fix_end(old_cw_ptr) { \
|
|
93 |
_control87(*old_cw_ptr, 0xFFFF);\
|
4413
|
94 |
}
|
|
95 |
|
5315
|
96 |
# else
|
|
97 |
# define fpu_fix_start(old_cw_ptr) { \
|
|
98 |
*old_cw_ptr = _control87(0, 0); \
|
|
99 |
_control87(0x00010000, 0x00030000);\
|
4413
|
100 |
}
|
|
101 |
|
5315
|
102 |
# define fpu_fix_end(old_cw_ptr) { \
|
|
103 |
_control87(*old_cw_ptr, 0xFFFFFFFF);\
|
|
104 |
}
|
|
105 |
|
|
106 |
# endif
|
|
107 |
|
4413
|
108 |
# else // assume MINGW, GCC or CLANG
|
|
109 |
|
|
110 |
# ifndef _FPU_GETCW
|
|
111 |
# define _FPU_GETCW(x) asm volatile ("fnstcw %0":"=m" (x));
|
|
112 |
# endif
|
|
113 |
# ifndef _FPU_SETCW
|
|
114 |
# define _FPU_SETCW(x) asm volatile ("fldcw %0": :"m" (x));
|
|
115 |
# endif
|
|
116 |
|
5315
|
117 |
# define fpu_fix_start(old_cw_ptr) { \
|
|
118 |
volatile unsigned short cw, new_cw;\
|
|
119 |
_FPU_GETCW(cw);\
|
|
120 |
new_cw = (cw & ~_FPU_EXTENDED) | _FPU_DOUBLE;\
|
|
121 |
_FPU_SETCW(new_cw);\
|
|
122 |
*old_cw_ptr = cw;\
|
4413
|
123 |
}
|
|
124 |
|
5315
|
125 |
# define fpu_fix_end(old_cw_ptr) { \
|
|
126 |
volatile unsigned short cw = *old_cw_ptr;\
|
|
127 |
_FPU_SETCW(cw);\
|
4413
|
128 |
}
|
|
129 |
|
|
130 |
# endif
|
|
131 |
|
5315
|
132 |
#endif // defined(__x86__) || defined(__x86_64__)
|
4413
|
133 |
|
|
134 |
#define __qNew_qdReal(newQD, d0,d1,d2,d3) { \
|
5308
|
135 |
double* __d__; \
|
|
136 |
__qNew(newQD, sizeof(struct __qDoubleStruct)); \
|
|
137 |
__stx_setClass(newQD, QDouble); \
|
|
138 |
__d__ = __QDoubleInstPtr(newQD)->d_qDoubleValue; \
|
|
139 |
__d__[0] = d0; \
|
|
140 |
__d__[1] = d1; \
|
|
141 |
__d__[2] = d2; \
|
|
142 |
__d__[3] = d3; \
|
4413
|
143 |
}
|
|
144 |
|
5315
|
145 |
#if 0
|
5308
|
146 |
|
4420
|
147 |
// sigh: not all compilers (borland) support inline functions;
|
|
148 |
// therefore we have to use macros...
|
|
149 |
// sigh2: c-macros are unhygienic - to avoid catching/hiding variable bindings,
|
|
150 |
// use different names in each macros (i.e. a_xxx)
|
|
151 |
|
4413
|
152 |
#define _QD_SPLITTER 134217729.0 // = 2^27 + 1
|
|
153 |
#define _QD_SPLIT_THRESH 6.69692879491417e+299 // = 2^996
|
|
154 |
|
4420
|
155 |
#define m_quick_two_sum(rslt_1, a_1, b_1, err_1)\
|
|
156 |
{\
|
|
157 |
double s_1 = (a_1) + (b_1);\
|
|
158 |
(err_1) = (b_1) - (s_1 - (a_1));\
|
|
159 |
(rslt_1) = s_1; \
|
4413
|
160 |
}
|
|
161 |
|
4420
|
162 |
#define m_quick_two_diff(rslt_2, a_2, b_2, err_2)\
|
|
163 |
{\
|
|
164 |
double s_2 = (a_2) - (b_2);\
|
|
165 |
(err_2) = ((a_2) - s_2) - (b_2);\
|
|
166 |
(rslt_2) = s_2;\
|
4413
|
167 |
}
|
|
168 |
|
4420
|
169 |
#define m_two_sum(rslt_3, a_3, b_3, err_3)\
|
|
170 |
{\
|
4981
|
171 |
double s_3 = (a_3) + (b_3);\
|
|
172 |
double v_3 = s_3 - (a_3);\
|
|
173 |
(err_3) = ((a_3) - (s_3 - v_3)) + ((b_3) - v_3);\
|
|
174 |
(rslt_3) = s_3;\
|
4413
|
175 |
}
|
|
176 |
|
|
177 |
/* Computes fl(a-b) and err(a-b). */
|
4420
|
178 |
#define m_two_diff(rslt_4, a_4, b_4, err_4)\
|
|
179 |
{\
|
4981
|
180 |
double s_4 = (a_4) - (b_4);\
|
|
181 |
double bb_4 = s_4 - (a_4);\
|
|
182 |
(err_4) = ((a_4) - (s_4 - bb_4)) - ((b_4) + bb_4);\
|
|
183 |
(rslt_4) = s_4;\
|
4413
|
184 |
}
|
|
185 |
|
4420
|
186 |
#define m_three_sum(a_5, b_5, c_5)\
|
|
187 |
{ \
|
|
188 |
double t1_5, t2_5, t3_5; \
|
4981
|
189 |
m_two_sum(t1_5, (a_5), (b_5), t2_5); \
|
|
190 |
m_two_sum((a_5), (c_5), t1_5, t3_5); \
|
|
191 |
m_two_sum((b_5), t2_5, t3_5, (c_5)); \
|
4413
|
192 |
}
|
|
193 |
|
4420
|
194 |
#define m_three_sum2(a_6, b_6, c_6)\
|
|
195 |
{\
|
|
196 |
double t1_6, t2_6, t3_6;\
|
4981
|
197 |
m_two_sum(t1_6, (a_6), (b_6), t2_6);\
|
|
198 |
m_two_sum((a_6), (c_6), t1_6, t3_6);\
|
|
199 |
(b_6) = t2_6 + t3_6;\
|
4413
|
200 |
}
|
|
201 |
|
|
202 |
#ifndef QD_FMS
|
|
203 |
|
|
204 |
/* Computes high word and lo word of a */
|
4420
|
205 |
#define m_split(a_7, hi_7, lo_7)\
|
|
206 |
{\
|
|
207 |
double temp_7;\
|
4981
|
208 |
double thi_7, tlo_7;\
|
|
209 |
if ((a_7) > _QD_SPLIT_THRESH || (a_7) < -_QD_SPLIT_THRESH) {\
|
5315
|
210 |
(a_7) *= 3.7252902984619140625e-09;\
|
|
211 |
temp_7 = _QD_SPLITTER * (a_7);\
|
|
212 |
thi_7 = temp_7 - (temp_7 - (a_7));\
|
|
213 |
tlo_7 = (a_7) - thi_7;\
|
|
214 |
thi_7 *= 268435456.0;\
|
|
215 |
tlo_7 *= 268435456.0;\
|
4420
|
216 |
} else {\
|
5315
|
217 |
temp_7 = _QD_SPLITTER * (a_7);\
|
|
218 |
thi_7 = temp_7 - (temp_7 - (a_7));\
|
|
219 |
tlo_7 = (a_7) - thi_7;\
|
4420
|
220 |
}\
|
4981
|
221 |
(hi_7) = thi_7; \
|
|
222 |
(lo_7) = tlo_7; \
|
4413
|
223 |
}
|
|
224 |
|
|
225 |
#endif
|
|
226 |
|
|
227 |
|
|
228 |
#ifdef QD_FMS
|
|
229 |
|
|
230 |
/* Computes fl(a*b) and err(a*b). */
|
|
231 |
|
4420
|
232 |
#define m_two_prod(rslt_8, a_8, b_8, err_8)\
|
|
233 |
{\
|
4981
|
234 |
double p_8 = (a_8) * (b_8);\
|
|
235 |
err_8 = QD_FMS((a_8), (b_8), p_8);\
|
4420
|
236 |
rslt_8 = p_8; \
|
4413
|
237 |
}
|
|
238 |
|
|
239 |
#else
|
|
240 |
|
4420
|
241 |
#define m_two_prod(rslt_8, a_8, b_8, err_8)\
|
|
242 |
{\
|
|
243 |
double a_hi_8, a_lo_8, b_hi_8, b_lo_8;\
|
4981
|
244 |
double p_8 = (a_8) * (b_8);\
|
4420
|
245 |
m_split(a_8, a_hi_8, a_lo_8);\
|
|
246 |
m_split(b_8, b_hi_8, b_lo_8);\
|
|
247 |
err_8 = ((a_hi_8 * b_hi_8 - p_8) + a_hi_8 * b_lo_8 + a_lo_8 * b_hi_8) + a_lo_8 * b_lo_8;\
|
|
248 |
rslt_8 = p_8; \
|
4413
|
249 |
}
|
|
250 |
|
|
251 |
#endif
|
|
252 |
|
|
253 |
#ifdef QD_FMS
|
|
254 |
|
4420
|
255 |
#define m_two_sqr(rslt_9, a_9, err_9)\
|
|
256 |
{\
|
4981
|
257 |
double p_9 = (a_9) * (a_9);\
|
|
258 |
err_9 = QD_FMS((a_9), (a_9), p_9);\
|
4420
|
259 |
rslt_9 = p_9;\
|
4413
|
260 |
}
|
|
261 |
|
|
262 |
#else
|
|
263 |
|
4420
|
264 |
#define m_two_sqr(rslt_9, a_9, err_9)\
|
|
265 |
{\
|
|
266 |
double hi_9, lo_9;\
|
4981
|
267 |
double q_9 = (a_9) * (a_9);\
|
4420
|
268 |
m_split(a_9, hi_9, lo_9);\
|
|
269 |
err_9 = ((hi_9 * hi_9 - q_9) + 2.0 * hi_9 * lo_9) + lo_9 * lo_9;\
|
|
270 |
rslt_9 = q_9;\
|
4413
|
271 |
}
|
|
272 |
|
|
273 |
#endif
|
|
274 |
|
4420
|
275 |
#define m_renorm4(c0_10, c1_10, c2_10, c3_10)\
|
|
276 |
{\
|
|
277 |
double s0_10, s1_10, s2_10 = 0.0, s3_10 = 0.0;\
|
4413
|
278 |
\
|
4420
|
279 |
if (! isinf(c0_10)) { \
|
4413
|
280 |
\
|
5315
|
281 |
m_quick_two_sum(s0_10, c2_10, c3_10, c3_10);\
|
|
282 |
m_quick_two_sum(s0_10, c1_10, s0_10, c2_10);\
|
|
283 |
m_quick_two_sum(c0_10, c0_10, s0_10, c1_10);\
|
4420
|
284 |
\
|
5315
|
285 |
s0_10 = c0_10;\
|
|
286 |
s1_10 = c1_10;\
|
|
287 |
if (s1_10 != 0.0) {\
|
|
288 |
m_quick_two_sum(s1_10, s1_10, c2_10, s2_10);\
|
|
289 |
if (s2_10 != 0.0) {\
|
|
290 |
m_quick_two_sum(s2_10, s2_10, c3_10, s3_10);\
|
|
291 |
} else {\
|
|
292 |
m_quick_two_sum(s1_10, s1_10, c3_10, s2_10);\
|
|
293 |
}\
|
|
294 |
} else {\
|
|
295 |
m_quick_two_sum(s0_10, s0_10, c2_10, s1_10);\
|
|
296 |
if (s1_10 != 0.0) {\
|
|
297 |
m_quick_two_sum(s1_10, s1_10, c3_10, s2_10);\
|
|
298 |
} else {\
|
|
299 |
m_quick_two_sum(s0_10, s0_10, c3_10, s1_10);\
|
|
300 |
}\
|
|
301 |
}\
|
4413
|
302 |
\
|
5315
|
303 |
c0_10 = s0_10;\
|
|
304 |
c1_10 = s1_10;\
|
|
305 |
c2_10 = s2_10;\
|
|
306 |
c3_10 = s3_10;\
|
4413
|
307 |
}\
|
|
308 |
}
|
|
309 |
|
4420
|
310 |
#define m_renorm5(c0_11, c1_11, c2_11, c3_11, c4_11)\
|
|
311 |
{\
|
|
312 |
double s0_11, s1_11, s2_11 = 0.0, s3_11 = 0.0; \
|
4413
|
313 |
\
|
4420
|
314 |
if (! isinf(c0_11)) { \
|
5315
|
315 |
m_quick_two_sum(s0_11, c3_11, c4_11, c4_11); \
|
|
316 |
m_quick_two_sum(s0_11, c2_11, s0_11, c3_11); \
|
|
317 |
m_quick_two_sum(s0_11, c1_11, s0_11, c2_11); \
|
|
318 |
m_quick_two_sum(c0_11, c0_11, s0_11, c1_11); \
|
4413
|
319 |
\
|
5315
|
320 |
s0_11 = c0_11; \
|
|
321 |
s1_11 = c1_11; \
|
4413
|
322 |
\
|
5315
|
323 |
m_quick_two_sum(s0_11, c0_11, c1_11, s1_11); \
|
|
324 |
if (s1_11 != 0.0) { \
|
|
325 |
m_quick_two_sum(s1_11, s1_11, c2_11, s2_11); \
|
|
326 |
if (s2_11 != 0.0) { \
|
|
327 |
m_quick_two_sum(s2_11 ,s2_11, c3_11, s3_11); \
|
|
328 |
if (s3_11 != 0.0) {\
|
|
329 |
s3_11 += c4_11; \
|
|
330 |
} else {\
|
|
331 |
s2_11 += c4_11;\
|
|
332 |
}\
|
|
333 |
} else { \
|
|
334 |
m_quick_two_sum(s1_11, s1_11, c3_11, s2_11); \
|
|
335 |
if (s2_11 != 0.0) {\
|
|
336 |
m_quick_two_sum(s2_11, s2_11, c4_11, s3_11); \
|
|
337 |
} else { \
|
|
338 |
m_quick_two_sum(s1_11, s1_11, c4_11, s2_11); \
|
|
339 |
} \
|
|
340 |
} \
|
|
341 |
} else { \
|
|
342 |
m_quick_two_sum(s0_11,s0_11, c2_11, s1_11); \
|
|
343 |
if (s1_11 != 0.0) { \
|
|
344 |
m_quick_two_sum(s1_11,s1_11, c3_11, s2_11); \
|
|
345 |
if (s2_11 != 0.0) {\
|
|
346 |
m_quick_two_sum(s2_11,s2_11, c4_11, s3_11); \
|
|
347 |
} else { \
|
|
348 |
m_quick_two_sum(s1_11 ,s1_11, c4_11, s2_11); \
|
|
349 |
} \
|
|
350 |
} else { \
|
|
351 |
m_quick_two_sum(s0_11,s0_11, c3_11, s1_11); \
|
|
352 |
if (s1_11 != 0.0) { \
|
|
353 |
m_quick_two_sum(s1_11,s1_11, c4_11, s2_11); \
|
|
354 |
} else { \
|
|
355 |
m_quick_two_sum(s0_11,s0_11, c4_11, s1_11); \
|
|
356 |
} \
|
|
357 |
} \
|
|
358 |
} \
|
4413
|
359 |
\
|
5315
|
360 |
c0_11 = s0_11; \
|
|
361 |
c1_11 = s1_11; \
|
|
362 |
c2_11 = s2_11; \
|
|
363 |
c3_11 = s3_11; \
|
4413
|
364 |
} \
|
|
365 |
}
|
|
366 |
|
5315
|
367 |
#endif // 0
|
4413
|
368 |
%}
|
4380
|
369 |
! !
|
|
370 |
|
|
371 |
!QDouble primitiveFunctions!
|
4413
|
372 |
%{
|
|
373 |
|
5314
|
374 |
#ifdef __BORLANDC__
|
5308
|
375 |
# define INLINE /* */
|
|
376 |
#else
|
|
377 |
# define INLINE inline
|
|
378 |
#endif
|
|
379 |
|
5315
|
380 |
#define QD_IEEE_ADD
|
|
381 |
|
5308
|
382 |
// routines
|
|
383 |
// fast_two_sum : s + e = a + b, s = fl(a + b), e = err(a + b), assumption |a|>|b|, Dekker('71)
|
|
384 |
// two_sum : s + e = a + b, s = fl(a + b), e = err(a + b), Knuth('69)
|
|
385 |
// three_sum : d + e + f = a + b + c, def are nonoverlapping, Bailey
|
|
386 |
// three_sum2 : d + e = a + b + c, de are nonoverlapping, Bailey
|
|
387 |
// two_prod : s + e = a * b, s = fl(a * b), e = err(a * b), Verkamp and Dekker
|
|
388 |
// sqr : s + e = a^2, s = fl(a * a), e = err(a * a)
|
5312
|
389 |
// renorm : renormalization algorithm
|
5308
|
390 |
// qd_add_s : qd + double
|
|
391 |
// qd_add_qd : qd + qd (sloppy add)
|
|
392 |
// s_sub_qd : double - qd
|
|
393 |
// qd_sub_qd : qd - qd
|
|
394 |
// s_mul_qd : double * qd
|
|
395 |
// qd_mul_qd : qd * qd
|
|
396 |
// qd_div_qd : qd / qd
|
5312
|
397 |
// qd_sqr : qd ^ 2
|
|
398 |
// qd_sqrt : square root (scalar)
|
|
399 |
// qd_pow : qd ^ n (n integer)
|
5308
|
400 |
|
|
401 |
static INLINE void
|
|
402 |
fast_two_sum(double *s, double *e, double a, double b)
|
|
403 |
{
|
5315
|
404 |
double t;
|
|
405 |
|
|
406 |
s[0] = t = a + b;
|
|
407 |
e[0] = b - (t - a);
|
5308
|
408 |
}
|
|
409 |
|
|
410 |
static INLINE void
|
|
411 |
two_sum(double *s, double *e, double a, double b)
|
|
412 |
{
|
5315
|
413 |
double t, bb;
|
|
414 |
|
|
415 |
s[0] = t = a + b;
|
|
416 |
bb = t - a;
|
|
417 |
e[0] = (a - (t - bb)) + (b - bb);
|
5308
|
418 |
}
|
|
419 |
|
|
420 |
static INLINE void
|
|
421 |
three_sum(double *d, double *e, double *f, double a, double b, double c)
|
|
422 |
{
|
|
423 |
double t1,t2,t3,v;
|
|
424 |
|
|
425 |
d[0] = 0.0; e[0] = 0.0; f[0] = 0.0;
|
|
426 |
|
|
427 |
t1= a + b;
|
|
428 |
v = t1 - a;
|
|
429 |
t2= (a - (t1 - v))+(b - v);
|
|
430 |
|
|
431 |
d[0] = t1 + c;
|
|
432 |
v = d[0] - t1;
|
|
433 |
t3= (t1 - (d[0] - v))+(c - v);
|
|
434 |
|
|
435 |
e[0] = t2 + t3;
|
|
436 |
v = e[0] - t2;
|
|
437 |
f[0] = (t2 - (e[0] - v))+(t3 - v);
|
|
438 |
}
|
|
439 |
|
|
440 |
static INLINE void
|
5315
|
441 |
three_sum2(double *d, double *e, double a, double b, double c) {
|
5308
|
442 |
double t1,t2,t3,v;
|
|
443 |
d[0] = 0.0; e[0] = 0.0;
|
|
444 |
|
|
445 |
t1= a + b;
|
|
446 |
v = t1 - a;
|
|
447 |
t2= (a - (t1 - v))+(b - v);
|
|
448 |
|
|
449 |
d[0] = t1 + c;
|
|
450 |
v = d[0] - t1;
|
|
451 |
t3= (t1 - (d[0] - v))+(c - v);
|
|
452 |
|
|
453 |
e[0] = t2 + t3;
|
|
454 |
}
|
|
455 |
|
5315
|
456 |
/* Computes high word and lo word of a */
|
|
457 |
#define _QD_SPLITTER 134217729.0 // = 2^27 + 1
|
|
458 |
#define _QD_SPLIT_THRESH 6.69692879491417e+299 // = 2^996
|
|
459 |
|
|
460 |
static INLINE void
|
|
461 |
split(double a, double *hi, double *lo) {
|
|
462 |
double temp;
|
|
463 |
if (a > _QD_SPLIT_THRESH || a < -_QD_SPLIT_THRESH) {
|
|
464 |
a *= 3.7252902984619140625e-09; // 2^-28
|
|
465 |
temp = _QD_SPLITTER * a;
|
|
466 |
*hi = temp - (temp - a);
|
|
467 |
*lo = a - *hi;
|
|
468 |
*hi *= 268435456.0; // 2^28
|
|
469 |
*lo *= 268435456.0; // 2^28
|
|
470 |
} else {
|
|
471 |
temp = _QD_SPLITTER * a;
|
|
472 |
*hi = temp - (temp - a);
|
|
473 |
*lo = a - *hi;
|
|
474 |
}
|
|
475 |
}
|
|
476 |
|
|
477 |
#if 0
|
5326
|
478 |
|
5308
|
479 |
static INLINE void
|
|
480 |
two_prod(double *p, double *e, double a, double b)
|
|
481 |
{
|
|
482 |
double t,ah,al,bh,bl;
|
|
483 |
|
|
484 |
p[0] = a * b;
|
|
485 |
|
|
486 |
t = 134217729 * a; // splitter: 2^27 + 1
|
|
487 |
ah = t -(t - a);
|
|
488 |
al = a - ah;
|
|
489 |
t = 134217729 * b; // splitter: 2^27 + 1
|
|
490 |
bh = t -(t - b);
|
|
491 |
bl = b - bh;
|
|
492 |
|
|
493 |
e[0] = ((ah*bh - p[0]) + ah*bl + al*bh) + al*bl;
|
|
494 |
}
|
5326
|
495 |
|
5315
|
496 |
#else
|
5326
|
497 |
|
|
498 |
static INLINE void
|
5315
|
499 |
two_prod(double *o, double *e, double a, double b) {
|
|
500 |
double a_hi, a_lo, b_hi, b_lo;
|
|
501 |
double p = a * b;
|
|
502 |
split(a, &a_hi, &a_lo);
|
|
503 |
split(b, &b_hi, &b_lo);
|
|
504 |
e[0] = ((a_hi * b_hi - p) + a_hi * b_lo + a_lo * b_hi) + a_lo * b_lo;
|
|
505 |
o[0] = p;
|
|
506 |
}
|
5326
|
507 |
|
5315
|
508 |
#endif
|
|
509 |
|
|
510 |
#if 0
|
|
511 |
// multiply by something known to be a power of 2
|
|
512 |
static INLINE
|
|
513 |
mul_pwr2(double *o0, double *o1, double *o2, double *o3, double a0, double a1, double a2, double a3, double b) {
|
|
514 |
o0[0] = a0 * b;
|
|
515 |
o0[1] = a1 * b;
|
|
516 |
o0[2] = a2 * b;
|
|
517 |
o0[3] = a3 * b;
|
|
518 |
}
|
|
519 |
#endif
|
5308
|
520 |
|
|
521 |
static INLINE void
|
|
522 |
sqr(double *p, double *e, double a)
|
|
523 |
{
|
5315
|
524 |
#if 0
|
5308
|
525 |
double t,ah,al;
|
|
526 |
|
|
527 |
p[0] = a * a;
|
|
528 |
t = 134217729 * a; // splitter: 2^27 + 1
|
|
529 |
ah = t -(t - a);
|
|
530 |
al = a - ah;
|
|
531 |
e[0] = ((ah*ah - p[0]) + (ah*al)*2.0) + al*al;
|
5315
|
532 |
#else
|
|
533 |
double hi, lo;
|
|
534 |
double q = a * a;
|
|
535 |
split(a, &hi, &lo);
|
|
536 |
*e = ((hi * hi - q) + 2.0 * hi * lo) + lo * lo;
|
|
537 |
p[0] = q;
|
|
538 |
#endif
|
5308
|
539 |
}
|
|
540 |
|
|
541 |
static INLINE void
|
|
542 |
renorm(double *b0, double *b1, double *b2, double *b3, double a0, double a1, double a2, double a3, double a4)
|
|
543 |
{
|
|
544 |
double t0,t1,t2,t3,t4,s,ss;
|
|
545 |
s = 0.0; ss = 0.0;
|
|
546 |
t0 = 0.0;t1 = 0.0;t2 = 0.0;t3 = 0.0;t4 = 0.0;
|
|
547 |
|
|
548 |
// fast_two_sum(&x, &y, a3, a4);
|
|
549 |
// s = x;
|
|
550 |
// t4 = y;
|
|
551 |
// fast_two_sum(&x, &y, a2, s);
|
|
552 |
// s = x;
|
|
553 |
// t3 = y;
|
|
554 |
// fast_two_sum(&x, &y, a1, s);
|
|
555 |
// s = x;
|
|
556 |
// t2 = y;
|
|
557 |
// fast_two_sum(&x, &y, a0, s);
|
|
558 |
// t0 = x;
|
|
559 |
// t1 = y;
|
|
560 |
// if(t1 != 0.0) {
|
|
561 |
// fast_two_sum(&x, &y, t1, t2);
|
|
562 |
// t1 = x;
|
|
563 |
// t2 = y;
|
|
564 |
// if(t2 != 0.0) {
|
|
565 |
// fast_two_sum(&x, &y,t2, t3);
|
|
566 |
// t2 = x;
|
|
567 |
// t3 = y;
|
|
568 |
// if(t3 != 0.0) {
|
|
569 |
// t3 += t4;
|
|
570 |
// } else {
|
|
571 |
// t2 += t4;
|
|
572 |
// }
|
|
573 |
// } else {
|
|
574 |
// fast_two_sum(&x, &y, t1, t3);
|
|
575 |
// t1 = x;
|
|
576 |
// t2 = y;
|
|
577 |
// if(t2 != 0.0) {
|
|
578 |
// fast_two_sum(&x, &y, t2, t4);
|
|
579 |
// t2 = x;
|
|
580 |
// t3 = y;
|
|
581 |
// } else {
|
|
582 |
// fast_two_sum(&x, &y, t1, t4);
|
|
583 |
// t1 = x;
|
|
584 |
// t2 = y;
|
|
585 |
// }
|
|
586 |
// }
|
|
587 |
// } else {
|
|
588 |
// fast_two_sum(&x, &y, t0, t2);
|
|
589 |
// t0 = x;
|
|
590 |
// t1 = y;
|
|
591 |
// if(t1 != 0.0) {
|
|
592 |
// fast_two_sum(&x, &y, t1, t3);
|
|
593 |
// t1 = x;
|
|
594 |
// t2 = y;
|
|
595 |
// if(t2 != 0.0) {
|
|
596 |
// fast_two_sum(&x, &y, t2, t4);
|
|
597 |
// t2 = x;
|
|
598 |
// t3 = y;
|
|
599 |
// } else {
|
|
600 |
// fast_two_sum(&x, &y, t1, t4);
|
|
601 |
// t1 = x;
|
|
602 |
// t2 = y;
|
|
603 |
// }
|
|
604 |
// } else {
|
|
605 |
// fast_two_sum(&x, &y, t0, t3);
|
|
606 |
// t0 = x;
|
|
607 |
// t1 = y;
|
|
608 |
// if(t1 != 0.0) {
|
|
609 |
// fast_two_sum(&x, &y, t1, t4);
|
|
610 |
// t1 = x;
|
|
611 |
// t2 = y;
|
|
612 |
// } else {
|
|
613 |
// fast_two_sum(&x, &y, t0, t4);
|
|
614 |
// t0 = x;
|
|
615 |
// t1 = y;
|
|
616 |
// }
|
|
617 |
// }
|
|
618 |
// }
|
|
619 |
|
|
620 |
|
|
621 |
//[s,t4] = fast_two_sum(a4,a5);
|
|
622 |
s = a3 + a4;
|
|
623 |
t3 = a4 - (s - a3);
|
|
624 |
//[ss,t3] = fast_two_sum(a3,s);
|
|
625 |
ss = a2 + s;
|
|
626 |
t2 = s - (ss - a2);
|
|
627 |
//[s,t2] = fast_two_sum(a2,ss);
|
|
628 |
s = a1 + ss;
|
|
629 |
t1 = ss - (s - a1);
|
|
630 |
//[b1,t1] = fast_two_sum(a1,s);
|
|
631 |
b0[0] = a0 + s;
|
|
632 |
t0 = s - (b0[0] - a0);
|
|
633 |
//[s,t3] = fast_two_sum(t3,t4);
|
|
634 |
s = t2 + t3;
|
|
635 |
t2 = t3 - (s - t2);
|
|
636 |
//[ss,t2] = fast_two_sum(t2,s);
|
|
637 |
ss = t1 + s;
|
|
638 |
t1 = s - (ss - t1);
|
|
639 |
//[b2,t1] = fast_two_sum(t1,ss);
|
|
640 |
b1[0] = t0 + ss;
|
|
641 |
t0 = ss - (b1[0] - t0);
|
|
642 |
//[s,t2] = fast_two_sum(t2,t3);
|
|
643 |
s = t1 + t2;
|
|
644 |
t1 = t2 - (s -t1);
|
|
645 |
//[b3,t1] = fast_two_sum(t1,s);
|
|
646 |
b2[0] = t0 + s;
|
|
647 |
t0 = s - (b2[0] - t0);
|
|
648 |
b3[0] = t0 + t1;
|
|
649 |
}
|
|
650 |
|
|
651 |
static INLINE void
|
|
652 |
renorm4(double *c0Ptr, double *c1Ptr, double *c2Ptr, double *c3Ptr) {
|
|
653 |
double s0, s1, s2 = 0.0, s3 = 0.0;
|
|
654 |
double c0 = *c0Ptr;
|
|
655 |
|
|
656 |
if (isinf(c0)) return;
|
|
657 |
fast_two_sum(&s0, c3Ptr, *c2Ptr, *c3Ptr); // s0 = fast_two_sum(*c2Ptr, *c3Ptr, c3Ptr);
|
|
658 |
fast_two_sum(&s0, c2Ptr, *c1Ptr, s0); // s0 = quick_two_sum(*c1Ptr, s0, c2Ptr);
|
|
659 |
fast_two_sum(&c0, c1Ptr, c0, s0); // c0 = quick_two_sum(c0, s0, c1Ptr);
|
|
660 |
|
|
661 |
s0 = c0;
|
|
662 |
s1 = *c1Ptr;
|
|
663 |
if (s1 != 0.0) {
|
5315
|
664 |
fast_two_sum(&s1, &s2, s1, *c2Ptr); // s1 = quick_two_sum(s1, *c2Ptr, &s2);
|
|
665 |
if (s2 != 0.0)
|
|
666 |
fast_two_sum(&s2, &s3, s2, *c3Ptr); // s2 = quick_two_sum(s2, *c3Ptr, &s3);
|
|
667 |
else
|
|
668 |
fast_two_sum(&s1, &s2, s1, *c3Ptr); // s1 = quick_two_sum(s1, *c3Ptr, &s2);
|
5308
|
669 |
} else {
|
5315
|
670 |
fast_two_sum(&s0, &s1, s0, *c2Ptr); // s0 = quick_two_sum(s0, *c2Ptr, &s1);
|
|
671 |
if (s1 != 0.0)
|
|
672 |
fast_two_sum(&s1, &s2, s1, *c3Ptr); // s1 = quick_two_sum(s1, *c3Ptr, &s2);
|
|
673 |
else
|
|
674 |
fast_two_sum(&s0, &s1, s0, *c3Ptr); // s0 = quick_two_sum(s0, *c3Ptr, &s1);
|
5308
|
675 |
}
|
|
676 |
|
|
677 |
*c0Ptr = s0;
|
|
678 |
*c1Ptr = s1;
|
|
679 |
*c2Ptr = s2;
|
|
680 |
*c3Ptr = s3;
|
|
681 |
}
|
|
682 |
|
|
683 |
//--------------------------------------------------------------------------------------------
|
|
684 |
//
|
|
685 |
// quad-double square
|
|
686 |
//
|
|
687 |
//--------------------------------------------------------------------------------------------
|
|
688 |
static INLINE void
|
|
689 |
qd_sqr(double *c0, double *c1, double *c2, double *c3, double a0, double a1, double a2, double a3)
|
|
690 |
{
|
|
691 |
double p01,p11,p02,p03,p12,e00,e01,e11,e02,x,y,w,z,s0,s1,t0,t1;
|
|
692 |
c0[0] = 0.0; c1[0] = 0.0; c2[0] = 0.0; c3[0] = 0.0;
|
|
693 |
|
|
694 |
//O(1) term
|
|
695 |
sqr(&x, &y, a0); c0[0] = x; e00 = y; //O(1) term ok
|
|
696 |
|
|
697 |
//O(eps) term
|
|
698 |
two_prod(&x, &y, a0, a1); p01 = 2.0*x; e01 = 2.0*y;
|
|
699 |
|
|
700 |
//O(eps^2) terms
|
|
701 |
two_prod(&x, &y, a0, a2); p02 = 2.0*x; e02 = 2.0*y;
|
|
702 |
sqr(&x, &y, a1); p11 = x; e11 = y;
|
|
703 |
|
|
704 |
two_sum(&x, &y, p01, e00); c1[0] = x; e00 = y; //O(eps) term ok
|
|
705 |
two_sum(&x, &y, e00, e01); e00 = x; e01 = y;
|
|
706 |
two_sum(&x, &y, p02, p11); p02 = x; p11 = y;
|
|
707 |
two_sum(&x, &y, e00, p02); s0 = x; t0 = y;
|
|
708 |
two_sum(&x, &y, e01, p11); s1 = x; t1 = y;
|
|
709 |
two_sum(&x, &y, s1, t0); s1 = x; t0 = y;
|
|
710 |
|
|
711 |
t0 = t0 + t1;
|
|
712 |
|
|
713 |
fast_two_sum(&x, &y, s1, t0); s1 = x; t0 = y;
|
|
714 |
fast_two_sum(&x, &y, s0, s1); c2[0] = x; t1 = y; //O(eps^2) term ok
|
|
715 |
fast_two_sum(&x, &y, t1, t0); p11 = x; e00 = y;
|
|
716 |
|
|
717 |
//O(eps^3) terms
|
|
718 |
p03 = 2.0 * a0 * a3;
|
|
719 |
p12 = 2.0 * a1 * a2;
|
|
720 |
|
|
721 |
two_sum(&x, &y, p03, p12); p03 = x; p12 = y;
|
|
722 |
two_sum(&x, &y, e02, e11); e02 = x; e11 = y;
|
|
723 |
two_sum(&x, &y, p03, e02); t0 = x; t1 = y;
|
|
724 |
|
|
725 |
t1 = t1 + p12 + e11;
|
|
726 |
|
|
727 |
two_sum(&x, &y, p11, t0); c3[0] = x; p03 = y; //O(eps^3) term ok
|
|
728 |
p03 = p03 + e00 + t1; //O(eps^4) term ok
|
|
729 |
|
|
730 |
renorm(&x, &y, &w, &z, c0[0], c1[0], c2[0], c3[0], p03);
|
|
731 |
c0[0] = x; c1[0] = y; c2[0] = w; c3[0] = z;
|
|
732 |
}
|
|
733 |
|
|
734 |
//--------------------------------------------------------------------------------------------
|
|
735 |
//
|
|
736 |
// addition quad-double + double
|
|
737 |
//
|
|
738 |
//--------------------------------------------------------------------------------------------
|
|
739 |
static INLINE void
|
5312
|
740 |
qd_add_s(double *o0, double *o1, double *o2, double *o3, double a0, double a1, double a2, double a3, double b)
|
5308
|
741 |
{
|
|
742 |
double e,x,y,w,z;
|
5312
|
743 |
double c0, c1, c2, c3;
|
|
744 |
c0 = 0.0; c1 = 0.0; c2 = 0.0; c3 = 0.0;
|
|
745 |
|
|
746 |
two_sum(&x, &y, a0, b); c0 = x; e = y;
|
|
747 |
two_sum(&x, &y, a1, e); c1 = x; e = y;
|
|
748 |
two_sum(&x, &y, a2, e); c2 = x; e = y;
|
|
749 |
two_sum(&x, &y, a3, e); c3 = x; e = y;
|
|
750 |
renorm(&x, &y, &w, &z, c0, c1, c2, c3, e);
|
|
751 |
o0[0] = x; o1[0] = y; o2[0] = w; o3[0] = z;
|
5308
|
752 |
}
|
|
753 |
|
|
754 |
//--------------------------------------------------------------------------------------------
|
|
755 |
//
|
|
756 |
// addition quad-double + double-double
|
|
757 |
//
|
|
758 |
//--------------------------------------------------------------------------------------------
|
|
759 |
static INLINE void
|
5312
|
760 |
qd_add_dd(double *o0, double *o1, double *o2, double *o3, double a0, double a1, double a2, double a3, double b0, double b1)
|
5308
|
761 |
{
|
|
762 |
double e1,e2,x,y,w,z;
|
5312
|
763 |
double c0, c1, c2, c3;
|
|
764 |
c0 = 0.0; c1 = 0.0; c2 = 0.0; c3 = 0.0;
|
|
765 |
|
|
766 |
two_sum(&x, &y, a0, b0); c0 = x; e1 = y;
|
|
767 |
two_sum(&x, &y, a1, b1); c1 = x; e2 = y;
|
|
768 |
two_sum(&x, &y, c1, e1); c1 = x; e1 = y;
|
|
769 |
two_sum(&x, &y, a2, e2); c2 = x; e2 = y;
|
|
770 |
two_sum(&x, &y, c2, e1); c2 = x; e1 = y;
|
|
771 |
two_sum(&x, &y, e1, e2); e1 = x; e2 = y;
|
|
772 |
two_sum(&x, &y, a3, e1); c3 = x; e1 = y;
|
5308
|
773 |
e1 = e1 + e2;
|
5312
|
774 |
renorm(&x, &y, &w, &z, c0, c1, c2, c3, e1);
|
|
775 |
o0[0] = x; o1[0] = y; o2[0] = w; o3[0] = z;
|
5308
|
776 |
return;
|
|
777 |
}
|
|
778 |
|
|
779 |
//--------------------------------------------------------------------------------------------
|
|
780 |
//
|
|
781 |
// addition quad-double + quad-double
|
|
782 |
//
|
|
783 |
//--------------------------------------------------------------------------------------------
|
|
784 |
static INLINE void
|
|
785 |
qd_add_qd(double *c0, double *c1, double *c2, double *c3, double a0, double a1, double a2, double a3, double b0, double b1, double b2, double b3)
|
|
786 |
{
|
|
787 |
double e1,e2,e3,e4,x,y,w,z;
|
|
788 |
c0[0] = 0.0; c1[0] = 0.0; c2[0] = 0.0; c3[0] = 0.0;
|
|
789 |
|
|
790 |
two_sum(&x, &y, a0, b0); c0[0] = x; e1 = y;
|
|
791 |
two_sum(&x, &y, a1, b1); c1[0] = x; e2 = y;
|
|
792 |
two_sum(&x, &y, c1[0], e1); c1[0] = x; e1 = y;
|
5312
|
793 |
|
5308
|
794 |
two_sum(&x, &y, a2, b2); c2[0] = x; e3 = y;
|
|
795 |
three_sum(&x, &y, &z, c2[0], e2, e1); c2[0] = x; e1 = y; e2 = z;
|
|
796 |
two_sum(&x, &y, a3, b3); c3[0] = x; e4 = y;
|
|
797 |
three_sum2(&x, &y, c3[0], e3, e1); c3[0] = x; e1 = y;
|
|
798 |
e1 = e1 + e2 + e4;
|
|
799 |
renorm(&x, &y, &w, &z, c0[0], c1[0], c2[0], c3[0], e1);
|
|
800 |
c0[0] = x; c1[0] = y; c2[0] = w; c3[0] = z;
|
|
801 |
}
|
|
802 |
|
|
803 |
//--------------------------------------------------------------------------------------------
|
|
804 |
//
|
|
805 |
// subtraction double - quad-double
|
|
806 |
//
|
|
807 |
//--------------------------------------------------------------------------------------------
|
|
808 |
static INLINE void
|
5312
|
809 |
s_sub_qd(double *o0, double *o1, double *o2, double *o3, double a, double b0, double b1, double b2, double b3)
|
5308
|
810 |
{
|
5312
|
811 |
double e,x,y,w,z;
|
|
812 |
double c0, c1, c2, c3;
|
|
813 |
|
|
814 |
e=0.0;
|
|
815 |
c0 = 0.0; c1 = 0.0; c2 = 0.0; c3 = 0.0;
|
|
816 |
b0=-b0; b1=-b1; b2=-b2; b3=-b3;
|
|
817 |
two_sum(&x, &y, a, b0);
|
|
818 |
c0 = x;
|
|
819 |
e = y;
|
|
820 |
two_sum(&x, &y, b1, e);
|
|
821 |
c1 = x;
|
|
822 |
e = y;
|
|
823 |
two_sum(&x, &y, b2, e);
|
|
824 |
c2 = x;
|
|
825 |
e = y;
|
|
826 |
two_sum(&x, &y, b3, e);
|
|
827 |
c3 = x;
|
|
828 |
e = y;
|
|
829 |
renorm(&x, &y, &w, &z, c0, c1, c2, c3, e);
|
|
830 |
o0[0] = x;
|
|
831 |
o1[0] = y;
|
|
832 |
o2[0] = w;
|
|
833 |
o3[0] = z;
|
5308
|
834 |
}
|
|
835 |
|
|
836 |
//--------------------------------------------------------------------------------------------
|
|
837 |
//
|
|
838 |
// subtraction quad-double - quad-double
|
|
839 |
//
|
|
840 |
//--------------------------------------------------------------------------------------------
|
|
841 |
static INLINE void
|
|
842 |
qd_sub_qd(double *c0, double *c1, double *c2, double *c3, double a0, double a1, double a2, double a3, double b0, double b1, double b2, double b3)
|
|
843 |
{
|
|
844 |
double e1,e2,e3,e4,x,y,w,z;
|
|
845 |
b0 = -b0; b1 = -b1; b2 = -b2; b3 = -b3;
|
|
846 |
c0[0] = 0.0; c1[0] = 0.0; c2[0] = 0.0; c3[0] = 0.0;
|
|
847 |
|
|
848 |
two_sum(&x, &y, a0, b0); c0[0] = x; e1 = y;
|
|
849 |
two_sum(&x, &y, a1, b1); c1[0] = x; e2 = y;
|
|
850 |
two_sum(&x, &y, c1[0], e1); c1[0] = x; e1 = y;
|
|
851 |
two_sum(&x, &y, a2, b2); c2[0] = x; e3 = y;
|
|
852 |
three_sum(&x, &y, &z, c2[0], e2, e1); c2[0] = x; e1 = y; e2 = z;
|
|
853 |
two_sum(&x, &y, a3, b3); c3[0] = x; e4 = y;
|
|
854 |
three_sum2(&x, &y, c3[0], e3, e1); c3[0] = x; e1 = y;
|
|
855 |
e1 = e1 + e2 + e4;
|
|
856 |
renorm(&x, &y, &w, &z, c0[0], c1[0], c2[0], c3[0], e1);
|
|
857 |
c0[0] = x; c1[0] = y; c2[0] = w; c3[0] = z;
|
|
858 |
}
|
|
859 |
|
|
860 |
//--------------------------------------------------------------------------------------------
|
|
861 |
//
|
|
862 |
// multiplication double * quad-double
|
|
863 |
//
|
|
864 |
//--------------------------------------------------------------------------------------------
|
|
865 |
static INLINE void
|
5312
|
866 |
s_mul_qd(double *o0, double *o1, double *o2, double *o3, double b, double a0, double a1, double a2, double a3)
|
5308
|
867 |
{
|
|
868 |
double e0,e1,e2,x,y,w,z;
|
5312
|
869 |
double c0, c1, c2, c3;
|
|
870 |
|
|
871 |
c0 = 0.0; c1 = 0.0; c2 = 0.0; c3 = 0.0;
|
|
872 |
|
|
873 |
two_prod(&x, &y, a0, b); c0 = x; e0 = y;
|
|
874 |
two_prod(&x, &y, a1, b); c1 = x; e1 = y;
|
|
875 |
two_sum(&x, &y, c1, e0); c1 = x; e0 = y;
|
|
876 |
two_prod(&x, &y, a2, b); c2 = x; e2 = y;
|
|
877 |
three_sum(&x, &y, &z, c2, e1, e0); c2 = x; e0 = y; e1 = z;
|
|
878 |
c3 = a3*b;
|
|
879 |
three_sum2(&x, &y, c3, e2, e0); c3 = x; e0 = y;
|
5308
|
880 |
e0 = e0 + e1;
|
|
881 |
|
5312
|
882 |
renorm(&x, &y, &w, &z, c0, c1, c2, c3, e0);
|
|
883 |
o0[0] = x; o1[0] = y; o2[0] = w; o3[0] = z;
|
5308
|
884 |
}
|
|
885 |
|
|
886 |
//--------------------------------------------------------------------------------------------
|
|
887 |
//
|
|
888 |
// multiplication quad-double * quad-double
|
|
889 |
//
|
|
890 |
//--------------------------------------------------------------------------------------------
|
|
891 |
static INLINE void
|
|
892 |
qd_mul_qd(double *c0, double *c1, double *c2, double *c3, double a0, double a1, double a2, double a3, double b0, double b1, double b2, double b3)
|
|
893 |
{
|
|
894 |
double p10,p01,p11,p20,p02,e00,e10,e01,e11,e20,e02,x,y,w,z;
|
|
895 |
c0[0] = 0.0; c1[0] = 0.0; c2[0] = 0.0; c3[0] = 0.0;
|
|
896 |
|
|
897 |
//O(1) terms
|
|
898 |
two_prod(&x, &y, a0, b0); c0[0] = x; e00 = y;
|
|
899 |
|
|
900 |
//O(eps) terms
|
|
901 |
two_prod(&x, &y, a0, b1); p01 = x; e01 = y;
|
|
902 |
two_prod(&x, &y, a1, b0); p10 = x; e10 = y;
|
|
903 |
three_sum(&x, &y, &z, p01, p10, e00);
|
|
904 |
c1[0] = x; //O(eps)
|
|
905 |
p10 = y; //O(eps^2)
|
|
906 |
p01 = z; //O(eps^3)
|
|
907 |
|
|
908 |
//O(eps^2) terms
|
|
909 |
two_prod(&x, &y, a0, b2); p02 = x; e02 = y;
|
|
910 |
two_prod(&x, &y, a1, b1); p11 = x; e11 = y;
|
|
911 |
two_prod(&x, &y, a2, b0); p20 = x; e20 = y;
|
|
912 |
|
|
913 |
//six three sum for p10, e01, e10, p02, p11, p20
|
|
914 |
three_sum(&x, &y, &z, p10, e01, e10); p10 = x; e01 = y; e10 = z;
|
|
915 |
three_sum(&x, &y, &z, p02, p11, p20); p02 = x; p11 = y; p20 = z;
|
|
916 |
two_sum(&x, &y, p02, p10); c2[0] = x; p10 = y;
|
|
917 |
two_sum(&x, &y, p11, e01); p11 = x; e01 = y;
|
|
918 |
two_sum(&x, &y, p10, p11); p10 = x; p11 = y;
|
|
919 |
|
|
920 |
e10 = e10 + p20 + e01 + p11; //O(eps^4) terms
|
|
921 |
|
|
922 |
//O(eps^3) terms
|
|
923 |
c3[0] = p10 + a0*b3 + a1*b2 + a2*b1 + a3*b0 + e02 + e11 + e20;
|
|
924 |
|
|
925 |
renorm(&x, &y, &w, &z, c0[0], c1[0], c2[0], c3[0], e10);
|
|
926 |
c0[0] = x;
|
|
927 |
c1[0] = y;
|
|
928 |
c2[0] = w;
|
|
929 |
c3[0] = z;
|
|
930 |
}
|
|
931 |
|
|
932 |
//--------------------------------------------------------------------------------------------
|
|
933 |
//
|
|
934 |
// division quad-double / double
|
|
935 |
//
|
|
936 |
//--------------------------------------------------------------------------------------------
|
|
937 |
static INLINE void
|
|
938 |
|
|
939 |
qd_div_s(double *c0, double *c1, double *c2, double *c3, double a0, double a1, double a2, double a3, double b)
|
|
940 |
{
|
|
941 |
double x,y,w,z,t0,t1,r0,r1,r2,r3,e;
|
|
942 |
c0[0] = 0.0; c1[0] = 0.0; c2[0] = 0.0; c3[0] = 0.0;
|
|
943 |
|
|
944 |
c0[0] = a0/b;
|
|
945 |
// reminder a - c_0*b
|
|
946 |
two_prod(&x, &y, c0[0], b);
|
|
947 |
t0 = -x;
|
|
948 |
t1 = -y;
|
|
949 |
//qd subtruction (a - t)
|
|
950 |
qd_add_dd(&x, &y, &w, &z, a0, a1, a2, a3, t0, t1);
|
|
951 |
r0 = x; r1 = y; r2 = w; r3 = z;
|
|
952 |
|
|
953 |
c1[0] = r0/b;
|
|
954 |
// reminder r - c_1*b
|
|
955 |
two_prod(&x, &y, c1[0], b);
|
|
956 |
t0 = -x;
|
|
957 |
t1 = -y;
|
|
958 |
//qd subtruction (r - t)
|
|
959 |
qd_add_dd(&x, &y, &w, &z, r0, r1, r2, r3, t0, t1);
|
|
960 |
r0 = x; r1 = y; r2 = w; r3 = z;
|
|
961 |
|
|
962 |
c2[0] = r0/b;
|
|
963 |
// reminder r - c_2*b
|
|
964 |
two_prod(&x, &y, c2[0], b);
|
|
965 |
t0 = -x;
|
|
966 |
t1 = -y;
|
|
967 |
//qd subtruction (r - t)
|
|
968 |
qd_add_dd(&x, &y, &w, &z, r0, r1, r2, r3, t0, t1);
|
|
969 |
r0 = x; r1 = y; r2 = w; r3 = z;
|
|
970 |
|
|
971 |
c3[0] = r0/b;
|
|
972 |
// reminder r - c_3*b
|
|
973 |
two_prod(&x, &y, c3[0], b);
|
|
974 |
t0 = -x;
|
|
975 |
t1 = -y;
|
|
976 |
//qd subtruction (r - t)
|
|
977 |
qd_add_dd(&x, &y, &w, &z, r0, r1, r2, r3, t0, t1);
|
|
978 |
r0 = x; r1 = y; r2 = w; r3 = z;
|
|
979 |
|
|
980 |
e = r0/b;
|
|
981 |
renorm(&x, &y, &w, &z, c0[0], c1[0], c2[0], c3[0], e);
|
|
982 |
c0[0] = x;
|
|
983 |
c1[0] = y;
|
|
984 |
c2[0] = w;
|
|
985 |
c3[0] = z;
|
|
986 |
return;
|
|
987 |
}
|
|
988 |
|
|
989 |
//--------------------------------------------------------------------------------------------
|
|
990 |
//
|
|
991 |
// division quad-double / quad-double
|
|
992 |
//
|
|
993 |
//--------------------------------------------------------------------------------------------
|
|
994 |
static INLINE void
|
|
995 |
qd_div_qd(double *c0, double *c1, double *c2, double *c3, double a0, double a1, double a2, double a3, double b0, double b1, double b2, double b3)
|
|
996 |
{
|
|
997 |
double x,y,w,z,t0,t1,t2,t3,r0,r1,r2,r3,e;
|
|
998 |
|
|
999 |
c0[0] = 0.0; c1[0] = 0.0; c2[0] = 0.0; c3[0] = 0.0;
|
|
1000 |
|
|
1001 |
c0[0] = a0/b0;
|
|
1002 |
// reminder a - c_0*b
|
|
1003 |
//multiplication
|
|
1004 |
s_mul_qd(&x, &y, &w, &z, c0[0], b0, b1, b2, b3);
|
|
1005 |
t0 = -x; t1 = -y; t2 = -w; t3 = -z;
|
|
1006 |
//qd subtruction (a - t)
|
|
1007 |
qd_add_qd(&x, &y, &w, &z, a0, a1, a2, a3, t0, t1, t2, t3);
|
|
1008 |
r0 = x; r1 = y; r2 = w; r3 = z;
|
|
1009 |
|
|
1010 |
c1[0] = r0/b0;
|
|
1011 |
// reminder r - c_1*b
|
|
1012 |
//multiplication
|
|
1013 |
s_mul_qd(&x, &y, &w, &z, c1[0], b0, b1, b2, b3);
|
|
1014 |
t0 = -x; t1 = -y; t2 = -w; t3 = -z;
|
|
1015 |
//qd subtruction (r - t)
|
|
1016 |
qd_add_qd(&x, &y, &w, &z, r0, r1, r2, r3, t0, t1, t2, t3);
|
|
1017 |
r0 = x; r1 = y; r2 = w; r3 = z;
|
|
1018 |
|
|
1019 |
c2[0] = r0/b0;
|
|
1020 |
// reminder r - c_2*b
|
|
1021 |
//multiplication
|
|
1022 |
s_mul_qd(&x, &y, &w, &z, c2[0], b0, b1, b2, b3);
|
|
1023 |
t0 = -x; t1 = -y; t2 = -w; t3 = -z;
|
|
1024 |
//qd subtruction (r - t)
|
|
1025 |
qd_add_qd(&x, &y, &w, &z, r0, r1, r2, r3, t0, t1, t2, t3);
|
|
1026 |
r0 = x; r1 = y; r2 = w; r3 = z;
|
|
1027 |
|
|
1028 |
c3[0] = r0/b0;
|
|
1029 |
// reminder r - c_3*b
|
|
1030 |
//multiplication
|
|
1031 |
s_mul_qd(&x, &y, &w, &z, c3[0], b0, b1, b2, b3);
|
|
1032 |
t0 = -x; t1 = -y; t2 = -w; t3 = -z;
|
|
1033 |
//qd subtruction (r - t)
|
|
1034 |
qd_add_qd(&x, &y, &w, &z, r0, r1, r2, r3, t0, t1, t2, t3);
|
|
1035 |
r0 = x; r1 = y; r2 = w; r3 = z;
|
|
1036 |
|
|
1037 |
e = r0/b0;
|
|
1038 |
renorm(&x, &y, &w, &z, c0[0], c1[0], c2[0], c3[0], e);
|
|
1039 |
c0[0] = x;
|
|
1040 |
c1[0] = y;
|
|
1041 |
c2[0] = w;
|
|
1042 |
c3[0] = z;
|
|
1043 |
}
|
|
1044 |
|
|
1045 |
//--------------------------------------------------------------------------------------------
|
|
1046 |
//
|
|
1047 |
// division double / quad-double sloppy
|
|
1048 |
//
|
|
1049 |
//--------------------------------------------------------------------------------------------
|
|
1050 |
static INLINE void
|
|
1051 |
s_div_qd(double *c0, double *c1, double *c2, double *c3, double a, double b0, double b1, double b2, double b3)
|
|
1052 |
{
|
|
1053 |
double x,y,w,z,t0,t1,t2,t3,r0,r1,r2,r3;
|
|
1054 |
|
|
1055 |
c0[0] = 0.0; c1[0] = 0.0; c2[0] = 0.0; c3[0] = 0.0;
|
|
1056 |
|
|
1057 |
c0[0] = a/b0;
|
|
1058 |
// reminder a - c_0*b
|
|
1059 |
//multiplication
|
|
1060 |
s_mul_qd(&x, &y, &w, &z, c0[0], b0, b1, b2, b3);
|
|
1061 |
t0 = -x; t1 = -y; t2 = -w; t3 = -z;
|
|
1062 |
//qd subtruction (a - t)
|
|
1063 |
qd_add_s(&x, &y, &w, &z, t0, t1, t2, t3, a);
|
|
1064 |
|
|
1065 |
r0 = x; r1 = y; r2 = w; r3 = z;
|
|
1066 |
|
|
1067 |
|
|
1068 |
c1[0] = r0/b0;
|
|
1069 |
// reminder r - c_1*b
|
|
1070 |
s_mul_qd(&x, &y, &w, &z, c1[0], b0, b1, b2, b3);
|
|
1071 |
t0 = -x; t1 = -y; t2 = -w; t3 = -z;
|
|
1072 |
//qd subtruction (r - t)
|
|
1073 |
qd_add_qd(&x, &y, &w, &z, r0, r1, r2, r3, t0, t1, t2, t3);
|
|
1074 |
r0 = x; r1 = y; r2 = w; r3 = z;
|
|
1075 |
|
|
1076 |
c2[0] = r0/b0;
|
|
1077 |
// reminder r - c_2*b
|
|
1078 |
s_mul_qd(&x, &y, &w, &z, c2[0], b0, b1, b2, b3);
|
|
1079 |
t0 = -x; t1 = -y; t2 = -w; t3 = -z;
|
|
1080 |
//qd subtruction (r - t)
|
|
1081 |
qd_add_qd(&x, &y, &w, &z, r0, r1, r2, r3, t0, t1, t2, t3);
|
|
1082 |
r0 = x; r1 = y; r2 = w; r3 = z;
|
|
1083 |
|
|
1084 |
c3[0] = r0/b0;
|
|
1085 |
|
|
1086 |
renorm(&x, &y, &w, &z, c0[0], c1[0], c2[0], c3[0], 0.0);
|
|
1087 |
c0[0] = x;
|
|
1088 |
c1[0] = y;
|
|
1089 |
c2[0] = w;
|
|
1090 |
c3[0] = z;
|
|
1091 |
}
|
|
1092 |
|
|
1093 |
static INLINE void
|
5312
|
1094 |
qd_sqrt(double *c0, double *c1, double *c2, double *c3, double a0, double a1, double a2, double a3)
|
5308
|
1095 |
{
|
|
1096 |
double h0,h1,h2,h3,x0,x1,x2,x3,p,q,r,s;
|
|
1097 |
|
|
1098 |
c0[0] = 0.0; c1[0] = 0.0; c2[0] = 0.0; c3[0] = 0.0;
|
|
1099 |
|
|
1100 |
c0[0] = 1.0/sqrt(a0);
|
|
1101 |
h0 = 0.5*a0; h1 = 0.5*a1; h2 = 0.5*a2; h3 = 0.5*a3;
|
|
1102 |
|
|
1103 |
qd_sqr(&x0, &x1, &x2, &x3, c0[0], c1[0], c2[0], c3[0]); //x_k^2
|
|
1104 |
qd_mul_qd(&p, &q, &r, &s, h0, h1, h2, h3, x0, x1, x2, x3); //0.5 * a * x_k^2
|
|
1105 |
x0 = -p; x1 = -q; x2 = -r; x3 = -s;
|
|
1106 |
qd_add_s(&p, &q, &r, &s, x0, x1, x2, x3, 0.5); //0.5 - 0.5 * a * x_k^2
|
|
1107 |
qd_mul_qd(&x0, &x1, &x2, &x3, p, q, r, s, c0[0], c1[0], c2[0], c3[0]); //(0.5 - 0.5 * a * x_k^2)*x_k
|
|
1108 |
qd_add_qd(&p, &q, &r, &s, c0[0], c1[0], c2[0], c3[0], x0, x1, x2, x3); //x_k+1 = x_k + (0.5 - 0.5 * a * x_k^2)*x_k
|
|
1109 |
c0[0] = p; c1[0] = q; c2[0] = r; c3[0] = s;
|
|
1110 |
|
|
1111 |
qd_sqr(&x0, &x1, &x2, &x3, c0[0], c1[0], c2[0], c3[0]); //x_k^2
|
|
1112 |
qd_mul_qd(&p, &q, &r, &s, h0, h1, h2, h3, x0, x1, x2, x3); //0.5 * a * x_k^2
|
|
1113 |
x0 = -p; x1 = -q; x2 = -r; x3 = -s;
|
|
1114 |
qd_add_s(&p, &q, &r, &s, x0, x1, x2, x3, 0.5); //0.5 - 0.5 * a * x_k^2
|
|
1115 |
qd_mul_qd(&x0, &x1, &x2, &x3, p, q, r, s, c0[0], c1[0], c2[0], c3[0]); //(0.5 - 0.5 * a * x_k^2)*x_k
|
|
1116 |
qd_add_qd(&p, &q, &r, &s, c0[0], c1[0], c2[0], c3[0], x0, x1, x2, x3); //x_k+1 = x_k + (0.5 - 0.5 * a * x_k^2)*x_k
|
|
1117 |
c0[0] = p; c1[0] = q; c2[0] = r; c3[0] = s;
|
|
1118 |
|
|
1119 |
qd_sqr(&x0, &x1, &x2, &x3, c0[0], c1[0], c2[0], c3[0]); //x_k^2
|
|
1120 |
qd_mul_qd(&p, &q, &r, &s, h0, h1, h2, h3, x0, x1, x2, x3); //0.5 * a * x_k^2
|
|
1121 |
x0 = -p; x1 = -q; x2 = -r; x3 = -s;
|
|
1122 |
qd_add_s(&p, &q, &r, &s, x0, x1, x2, x3, 0.5); //0.5 - 0.5 * a * x_k^2
|
|
1123 |
qd_mul_qd(&x0, &x1, &x2, &x3, p, q, r, s, c0[0], c1[0], c2[0], c3[0]); //(0.5 - 0.5 * a * x_k^2)*x_k
|
|
1124 |
qd_add_qd(&p, &q, &r, &s, c0[0], c1[0], c2[0], c3[0], x0, x1, x2, x3); //x_k+1 = x_k + (0.5 - 0.5 * a * x_k^2)*x_k
|
|
1125 |
|
|
1126 |
qd_mul_qd(&x0, &x1, &x2, &x3, a0, a1, a2, a3, p, q, r, s); //(0.5 - 0.5 * a * x_k^2)*x_k*a
|
|
1127 |
c0[0] = x0; c1[0] = x1; c2[0] = x2; c3[0] = x3;
|
|
1128 |
}
|
|
1129 |
|
|
1130 |
static void
|
5312
|
1131 |
qd_pow(double *c0, double *c1, double *c2, double *c3, double a0, double a1, double a2, double a3, int p)
|
5308
|
1132 |
{
|
|
1133 |
double r0,r1,r2,r3,x,y,w,z;
|
|
1134 |
int abs_p;
|
|
1135 |
|
|
1136 |
c0[0] = 0.0; c1[0] = 0.0; c2[0] = 0.0; c3[0] = 0.0;
|
|
1137 |
|
|
1138 |
if (p == 0) {
|
5315
|
1139 |
c0[0] = 1.0;
|
5308
|
1140 |
} else {
|
5315
|
1141 |
r0 = a0; r1 = a1; r2 = a2; r3 = a3;
|
|
1142 |
c0[0] = 1.0;
|
|
1143 |
abs_p = abs(p);
|
|
1144 |
|
|
1145 |
if (abs_p > 1) {
|
|
1146 |
while (abs_p > 0) {
|
|
1147 |
if ((abs_p % 2)==1) {
|
|
1148 |
qd_mul_qd(&x, &y, &w, &z, c0[0], c1[0], c2[0], c3[0], r0, r1, r2, r3);
|
|
1149 |
c0[0] = x; c1[0] = y; c2[0] = w; c3[0] = z;
|
|
1150 |
}
|
|
1151 |
abs_p = abs_p / 2;
|
|
1152 |
if (abs_p > 0) {
|
|
1153 |
qd_sqr(&x, &y, &w, &z, r0, r1, r2, r3);
|
|
1154 |
r0 = x; r1 = y; r2 = w; r3 = z;
|
|
1155 |
}
|
|
1156 |
}
|
|
1157 |
} else {
|
|
1158 |
c0[0] = r0; c1[0] = r1; c2[0] = r2; c3[0] = r3;
|
|
1159 |
}
|
|
1160 |
if (p < 0) {
|
|
1161 |
s_div_qd(&x, &y, &w, &z, 1.0, c0[0], c1[0], c2[0], c3[0]);
|
|
1162 |
c0[0] = x; c1[0] = y; c2[0] = w; c3[0] = z;
|
|
1163 |
}
|
5308
|
1164 |
}
|
|
1165 |
}
|
|
1166 |
|
|
1167 |
// round to nearest integer
|
|
1168 |
#define round(x) (floor((x)+0.5))
|
|
1169 |
|
|
1170 |
static INLINE void
|
|
1171 |
nint_qd(double *x0, double *x1, double *x2, double *x3, double a0, double a1, double a2, double a3)
|
|
1172 |
{
|
|
1173 |
x0[0]=round(a0);
|
|
1174 |
x1[0]=0.0; x2[0]=0.0; x3[0]=0.0;
|
|
1175 |
|
|
1176 |
if(x0[0]==a0) {
|
5315
|
1177 |
x1[0]=round(a1);
|
|
1178 |
if(x1[0]==a1) {
|
|
1179 |
x2[0]=round(a2);
|
|
1180 |
if(x2[0]==a2) {
|
|
1181 |
x3[0]=round(a3);
|
|
1182 |
}
|
|
1183 |
else {
|
|
1184 |
if(((int)fabs(x2[0]-a2)==0.5) && (a3<0.0)) {
|
|
1185 |
x2[0]=x2[0]-1.0;
|
|
1186 |
}
|
|
1187 |
}
|
|
1188 |
}
|
|
1189 |
else {
|
|
1190 |
if(((int)fabs(x1[0]-a1)==0.5) && (a2<0.0)) {
|
|
1191 |
x1[0]=x1[0]-1.0;
|
|
1192 |
}
|
|
1193 |
}
|
5308
|
1194 |
}
|
|
1195 |
else {
|
5315
|
1196 |
if(((int)fabs(x0[0]-a0)==0.5) && (a1<0.0)) {
|
|
1197 |
x0[0]=x0[0]-1.0;
|
|
1198 |
}
|
5308
|
1199 |
}
|
|
1200 |
renorm(&x0[0],&x1[0],&x2[0],&x3[0],x0[0],x1[0],x2[0],x3[0],0.0);
|
|
1201 |
return;
|
|
1202 |
}
|
|
1203 |
|
|
1204 |
static double s_table[256][4]= {
|
|
1205 |
{3.0679567629659761e-03, 1.2690279085455925e-19, 5.2879464245328389e-36, -1.7820334081955298e-52},
|
|
1206 |
{6.1358846491544753e-03, 9.0545257482474933e-20, 1.6260113133745320e-37, -9.7492001208767410e-55},
|
|
1207 |
{9.2037547820598194e-03, -1.2136591693535934e-19, 5.5696903949425567e-36, 1.2505635791936951e-52},
|
|
1208 |
{1.2271538285719925e-02, 6.9197907640283170e-19, -4.0203726713435555e-36, -2.0688703606952816e-52},
|
|
1209 |
{1.5339206284988102e-02, -8.4462578865401696e-19, 4.6535897505058629e-35, -1.3923682978570467e-51},
|
|
1210 |
{1.8406729905804820e-02, 7.4195533812833160e-19, 3.9068476486787607e-35, 3.6393321292898614e-52},
|
|
1211 |
{2.1474080275469508e-02, -4.5407960207688566e-19, -2.2031770119723005e-35, 1.2709814654833741e-52},
|
|
1212 |
{2.4541228522912288e-02, -9.1868490125778782e-20, 4.8706148704467061e-36, -2.8153947855469224e-52},
|
|
1213 |
{2.7608145778965743e-02, -1.5932358831389269e-18, -7.0475416242776030e-35, -2.7518494176602744e-51},
|
|
1214 |
{3.0674803176636626e-02, -1.6936054844107918e-20, -2.0039543064442544e-36, -1.6267505108658196e-52},
|
|
1215 |
{3.3741171851377587e-02, -2.0096074292368340e-18, -1.3548237016537134e-34, 6.5554881875899973e-51},
|
|
1216 |
{3.6807222941358832e-02, 6.1060088803529842e-19, -4.0448721259852727e-35, -2.1111056765671495e-51},
|
|
1217 |
{3.9872927587739811e-02, 4.6657453481183289e-19, 3.4119333562288684e-35, 2.4007534726187511e-51},
|
|
1218 |
{4.2938256934940820e-02, 2.8351940588660907e-18, 1.6991309601186475e-34, 6.8026536098672629e-51},
|
|
1219 |
{4.6003182130914630e-02, -1.1182813940157788e-18, 7.5235020270378946e-35, 4.1187304955493722e-52},
|
|
1220 |
{4.9067674327418015e-02, -6.7961037205182801e-19, -4.4318868124718325e-35, -9.9376628132525316e-52},
|
|
1221 |
{5.2131704680283324e-02, -2.4243695291953779e-18, -1.3675405320092298e-34, -8.3938137621145070e-51},
|
|
1222 |
{5.5195244349689941e-02, -1.3340299860891103e-18, -3.4359574125665608e-35, 1.1911462755409369e-51},
|
|
1223 |
{5.8258264500435759e-02, 2.3299905496077492e-19, 1.9376108990628660e-36, -5.1273775710095301e-53},
|
|
1224 |
{6.1320736302208578e-02, -5.1181134064638108e-19, -4.2726335866706313e-35, 2.6368495557440691e-51},
|
|
1225 |
{6.4382630929857465e-02, -4.2325997000052705e-18, 3.3260117711855937e-35, 1.4736267706718352e-51},
|
|
1226 |
{6.7443919563664065e-02, -6.9221796556983636e-18, 1.5909286358911040e-34, -7.8828946891835218e-51},
|
|
1227 |
{7.0504573389613870e-02, -6.8552791107342883e-18, -1.9961177630841580e-34, 2.0127129580485300e-50},
|
|
1228 |
{7.3564563599667426e-02, -2.7784941506273593e-18, -9.1240375489852821e-35, -1.9589752023546795e-51},
|
|
1229 |
{7.6623861392031492e-02, 2.3253700287958801e-19, -1.3186083921213440e-36, -4.9927872608099673e-53},
|
|
1230 |
{7.9682437971430126e-02, -4.4867664311373041e-18, 2.8540789143650264e-34, 2.8491348583262741e-51},
|
|
1231 |
{8.2740264549375692e-02, 1.4735983530877760e-18, 3.7284093452233713e-35, 2.9024430036724088e-52},
|
|
1232 |
{8.5797312344439894e-02, -3.3881893830684029e-18, -1.6135529531508258e-34, 7.7294651620588049e-51},
|
|
1233 |
{8.8853552582524600e-02, -3.7501775830290691e-18, 3.7543606373911573e-34, 2.2233701854451859e-50},
|
|
1234 |
{9.1908956497132724e-02, 4.7631594854274564e-18, 1.5722874642939344e-34, -4.8464145447831456e-51},
|
|
1235 |
{9.4963495329639006e-02, -6.5885886400417564e-18, -2.1371116991641965e-34, 1.3819370559249300e-50},
|
|
1236 |
{9.8017140329560604e-02, -1.6345823622442560e-18, -1.3209238810006454e-35, -3.5691060049117942e-52},
|
|
1237 |
{1.0106986275482782e-01, 3.3164325719308656e-18, -1.2004224885132282e-34, 7.2028828495418631e-51},
|
|
1238 |
{1.0412163387205457e-01, 6.5760254085385100e-18, 1.7066246171219214e-34, -4.9499340996893514e-51},
|
|
1239 |
{1.0717242495680884e-01, 6.4424044279026198e-18, -8.3956976499698139e-35, -4.0667730213318321e-51},
|
|
1240 |
{1.1022220729388306e-01, -5.6789503537823233e-19, 1.0380274792383233e-35, 1.5213997918456695e-52},
|
|
1241 |
{1.1327095217756435e-01, 2.7100481012132900e-18, 1.5323292999491619e-35, 4.9564432810360879e-52},
|
|
1242 |
{1.1631863091190477e-01, 1.0294914877509705e-18, -9.3975734948993038e-35, 1.3534827323719708e-52},
|
|
1243 |
{1.1936521481099137e-01, -3.9500089391898506e-18, 3.5317349978227311e-34, 1.8856046807012275e-51},
|
|
1244 |
{1.2241067519921620e-01, 2.8354501489965335e-18, 1.8151655751493305e-34, -2.8716592177915192e-51},
|
|
1245 |
{1.2545498341154623e-01, 4.8686751763148235e-18, 5.9878105258097936e-35, -3.3534629098722107e-51},
|
|
1246 |
{1.2849811079379317e-01, 3.8198603954988802e-18, -1.8627501455947798e-34, -2.4308161133527791e-51},
|
|
1247 |
{1.3154002870288312e-01, -5.0039708262213813e-18, -1.2983004159245552e-34, -4.6872034915794122e-51},
|
|
1248 |
{1.3458070850712620e-01, -9.1670359171480699e-18, 1.5916493007073973e-34, 4.0237002484366833e-51},
|
|
1249 |
{1.3762012158648604e-01, 6.6253255866774482e-18, -2.3746583031401459e-34, -9.3703876173093250e-52},
|
|
1250 |
{1.4065823933284924e-01, -7.9193932965524741e-18, 6.0972464202108397e-34, 2.4566623241035797e-50},
|
|
1251 |
{1.4369503315029444e-01, 1.1472723016618666e-17, -5.1884954557576435e-35, -4.2220684832186607e-51},
|
|
1252 |
{1.4673047445536175e-01, 3.7269471470465677e-18, 3.7352398151250827e-34, -4.0881822289508634e-51},
|
|
1253 |
{1.4976453467732151e-01, 8.0812114131285151e-18, 1.2979142554917325e-34, 9.9380667487736254e-51},
|
|
1254 |
{1.5279718525844344e-01, -7.6313573938416838e-18, 5.7714690450284125e-34, -3.7731132582986687e-50},
|
|
1255 |
{1.5582839765426523e-01, 3.0351307187678221e-18, -1.0976942315176184e-34, 7.8734647685257867e-51},
|
|
1256 |
{1.5885814333386145e-01, -4.0163200573859079e-18, -9.2840580257628812e-35, -2.8567420029274875e-51},
|
|
1257 |
{1.6188639378011183e-01, 1.1850519643573528e-17, -5.0440990519162957e-34, 3.0510028707928009e-50},
|
|
1258 |
{1.6491312048996992e-01, -7.0405288319166738e-19, 3.3211107491245527e-35, 8.6663299254686031e-52},
|
|
1259 |
{1.6793829497473117e-01, 5.4284533721558139e-18, -3.3263339336181369e-34, -1.8536367335123848e-50},
|
|
1260 |
{1.7096188876030122e-01, 9.1919980181759094e-18, -6.7688743940982606e-34, -1.0377711384318389e-50},
|
|
1261 |
{1.7398387338746382e-01, 5.8151994618107928e-18, -1.6751014298301606e-34, -6.6982259797164963e-51},
|
|
1262 |
{1.7700422041214875e-01, 6.7329300635408167e-18, 2.8042736644246623e-34, 3.6786888232793599e-51},
|
|
1263 |
{1.8002290140569951e-01, 7.9701826047392143e-18, -7.0765920110524977e-34, 1.9622512608461784e-50},
|
|
1264 |
{1.8303988795514095e-01, 7.7349918688637383e-18, -4.4803769968145083e-34, 1.1201148793328890e-50},
|
|
1265 |
{1.8605515166344666e-01, -1.2564893007679552e-17, 7.5953844248530810e-34, -3.8471695132415039e-51},
|
|
1266 |
{1.8906866414980622e-01, -7.6208955803527778e-18, -4.4792298656662981e-34, -4.4136824096645007e-50},
|
|
1267 |
{1.9208039704989244e-01, 4.3348343941174903e-18, -2.3404121848139937e-34, 1.5789970962611856e-50},
|
|
1268 |
{1.9509032201612828e-01, -7.9910790684617313e-18, 6.1846270024220713e-34, -3.5840270918032937e-50},
|
|
1269 |
{1.9809841071795359e-01, -1.8434411800689445e-18, 1.4139031318237285e-34, 1.0542811125343809e-50},
|
|
1270 |
{2.0110463484209190e-01, 1.1010032669300739e-17, -3.9123576757413791e-34, 2.4084852500063531e-51},
|
|
1271 |
{2.0410896609281687e-01, 6.0941297773957752e-18, -2.8275409970449641e-34, 4.6101008563532989e-51},
|
|
1272 |
{2.0711137619221856e-01, -1.0613362528971356e-17, 2.2456805112690884e-34, 1.3483736125280904e-50},
|
|
1273 |
{2.1011183688046961e-01, 1.1561548476512844e-17, 6.0355905610401254e-34, 3.3329909618405675e-50},
|
|
1274 |
{2.1311031991609136e-01, 1.2031873821063860e-17, -3.4142699719695635e-34, -1.2436262780241778e-50},
|
|
1275 |
{2.1610679707621952e-01, -1.0111196082609117e-17, 7.2789545335189643e-34, -2.9347540365258610e-50},
|
|
1276 |
{2.1910124015686980e-01, -3.6513812299150776e-19, -2.3359499418606442e-35, 3.1785298198458653e-52},
|
|
1277 |
{2.2209362097320354e-01, -3.0337210995812162e-18, 6.6654668033632998e-35, 2.0110862322656942e-51},
|
|
1278 |
{2.2508391135979283e-01, 3.9507040822556510e-18, 2.4287993958305375e-35, 5.6662797513020322e-52},
|
|
1279 |
{2.2807208317088573e-01, 8.2361837339258012e-18, 6.9786781316397937e-34, -6.4122962482639504e-51},
|
|
1280 |
{2.3105810828067111e-01, 1.0129787149761869e-17, -6.9359234615816044e-34, -2.8877355604883782e-50},
|
|
1281 |
{2.3404195858354343e-01, -6.9922402696101173e-18, -5.7323031922750280e-34, 5.3092579966872727e-51},
|
|
1282 |
{2.3702360599436720e-01, 8.8544852285039918e-18, 1.3588480826354134e-34, 1.0381022520213867e-50},
|
|
1283 |
{2.4000302244874150e-01, -1.2137758975632164e-17, -2.6448807731703891e-34, -1.9929733800670473e-51},
|
|
1284 |
{2.4298017990326390e-01, -8.7514315297196632e-18, -6.5723260373079431e-34, -1.0333158083172177e-50},
|
|
1285 |
{2.4595505033579462e-01, -1.1129044052741832e-17, 4.3805998202883397e-34, 1.2219399554686291e-50},
|
|
1286 |
{2.4892760574572018e-01, -8.1783436100020990e-18, 5.5666875261111840e-34, 3.8080473058748167e-50},
|
|
1287 |
{2.5189781815421697e-01, -1.7591436032517039e-17, -1.0959681232525285e-33, 5.6209426020232456e-50},
|
|
1288 |
{2.5486565960451457e-01, -1.3602299806901461e-19, -6.0073844642762535e-36, -3.0072751311893878e-52},
|
|
1289 |
{2.5783110216215899e-01, 1.8480038630879957e-17, 3.3201664714047599e-34, -5.5547819290576764e-51},
|
|
1290 |
{2.6079411791527551e-01, 4.2721420983550075e-18, 5.6782126934777920e-35, 3.1428338084365397e-51},
|
|
1291 |
{2.6375467897483140e-01, -1.8837947680038700e-17, 1.3720129045754794e-33, -8.2763406665966033e-50},
|
|
1292 |
{2.6671275747489837e-01, 2.0941222578826688e-17, -1.1303466524727989e-33, 1.9954224050508963e-50},
|
|
1293 |
{2.6966832557291509e-01, 1.5765657618133259e-17, -6.9696142173370086e-34, -4.0455346879146776e-50},
|
|
1294 |
{2.7262135544994898e-01, 7.8697166076387850e-18, 6.6179388602933372e-35, -2.7642903696386267e-51},
|
|
1295 |
{2.7557181931095814e-01, 1.9320328962556582e-17, 1.3932094180100280e-33, 1.3617253920018116e-50},
|
|
1296 |
{2.7851968938505312e-01, -1.0030273719543544e-17, 7.2592115325689254e-34, -1.0068516296655851e-50},
|
|
1297 |
{2.8146493792575800e-01, -1.2322299641274009e-17, -1.0564788706386435e-34, 7.5137424251265885e-51},
|
|
1298 |
{2.8440753721127182e-01, 2.2209268510661475e-17, -9.1823095629523708e-34, -5.2192875308892218e-50},
|
|
1299 |
{2.8734745954472951e-01, 1.5461117367645717e-17, -6.3263973663444076e-34, -2.2982538416476214e-50},
|
|
1300 |
{2.9028467725446239e-01, -1.8927978707774251e-17, 1.1522953157142315e-33, 7.4738655654716596e-50},
|
|
1301 |
{2.9321916269425863e-01, 2.2385430811901833e-17, 1.3662484646539680e-33, -4.2451325253996938e-50},
|
|
1302 |
{2.9615088824362384e-01, -2.0220736360876938e-17, -7.9252212533920413e-35, -2.8990577729572470e-51},
|
|
1303 |
{2.9907982630804048e-01, 1.6701181609219447e-18, 8.6091151117316292e-35, 3.9931286230012102e-52},
|
|
1304 |
{3.0200594931922808e-01, -1.7167666235262474e-17, 2.3336182149008069e-34, 8.3025334555220004e-51},
|
|
1305 |
{3.0492922973540243e-01, -2.2989033898191262e-17, -1.4598901099661133e-34, 3.7760487693121827e-51},
|
|
1306 |
{3.0784964004153487e-01, 2.7074088527245185e-17, 1.2568858206899284e-33, 7.2931815105901645e-50},
|
|
1307 |
{3.1076715274961147e-01, 2.0887076364048513e-17, -3.0130590791065942e-34, 1.3876739009935179e-51},
|
|
1308 |
{3.1368174039889146e-01, 1.4560447299968912e-17, 3.6564186898011595e-34, 1.1654264734999375e-50},
|
|
1309 |
{3.1659337555616585e-01, 2.1435292512726283e-17, 1.2338169231377316e-33, 3.3963542100989293e-50},
|
|
1310 |
{3.1950203081601569e-01, -1.3981562491096626e-17, 8.1730000697411350e-34, -7.7671096270210952e-50},
|
|
1311 |
{3.2240767880106985e-01, -4.0519039937959398e-18, 3.7438302780296796e-34, 8.7936731046639195e-51},
|
|
1312 |
{3.2531029216226293e-01, 7.9171249463765892e-18, -6.7576622068146391e-35, 2.3021655066929538e-51},
|
|
1313 |
{3.2820984357909255e-01, -2.6693140719641896e-17, 7.8928851447534788e-34, 2.5525163821987809e-51},
|
|
1314 |
{3.3110630575987643e-01, -2.7469465474778694e-17, -1.3401245916610206e-33, 6.5531762489976163e-50},
|
|
1315 |
{3.3399965144200938e-01, 2.2598986806288142e-17, 7.8063057192586115e-34, 2.0427600895486683e-50},
|
|
1316 |
{3.3688985339222005e-01, -4.2000940033475092e-19, -2.9178652969985438e-36, -1.1597376437036749e-52},
|
|
1317 |
{3.3977688440682685e-01, 6.6028679499418282e-18, 1.2575009988669683e-34, 2.5569067699008304e-51},
|
|
1318 |
{3.4266071731199438e-01, 1.9261518449306319e-17, -9.2754189135990867e-34, 8.5439996687390166e-50},
|
|
1319 |
{3.4554132496398904e-01, 2.7251143672916123e-17, 7.0138163601941737e-34, -1.4176292197454015e-50},
|
|
1320 |
{3.4841868024943456e-01, 3.6974420514204918e-18, 3.5532146878499996e-34, 1.9565462544501322e-50},
|
|
1321 |
{3.5129275608556715e-01, -2.2670712098795844e-17, -1.6994216673139631e-34, -1.2271556077284517e-50},
|
|
1322 |
{3.5416352542049040e-01, -1.6951763305764860e-17, 1.2772331777814617e-33, -3.3703785435843310e-50},
|
|
1323 |
{3.5703096123343003e-01, -4.8218191137919166e-19, -4.1672436994492361e-35, -7.1531167149364352e-52},
|
|
1324 |
{3.5989503653498817e-01, -1.7601687123839282e-17, 1.3375125473046791e-33, 7.9467815593584340e-50},
|
|
1325 |
{3.6275572436739723e-01, -9.1668352663749849e-18, -7.4317843956936735e-34, -2.0199582511804564e-50},
|
|
1326 |
{3.6561299780477385e-01, 1.6217898770457546e-17, 1.1286970151961055e-33, -7.1825287318139010e-50},
|
|
1327 |
{3.6846682995337232e-01, 1.0463640796159268e-17, 2.0554984738517304e-35, 1.0441861305618769e-51},
|
|
1328 |
{3.7131719395183754e-01, 3.4749239648238266e-19, -7.5151053042866671e-37, -2.8153468438650851e-53},
|
|
1329 |
{3.7416406297145799e-01, 8.0114103761962118e-18, 5.3429599813406052e-34, 1.0351378796539210e-50},
|
|
1330 |
{3.7700741021641826e-01, -2.7255302041956930e-18, 6.3646586445018137e-35, 8.3048657176503559e-52},
|
|
1331 |
{3.7984720892405116e-01, 9.9151305855172370e-18, 4.8761409697224886e-34, 1.4025084000776705e-50},
|
|
1332 |
{3.8268343236508978e-01, -1.0050772696461588e-17, -2.0605316302806695e-34, -1.2717724698085205e-50},
|
|
1333 |
{3.8551605384391885e-01, 1.5177665396472313e-17, 1.4198230518016535e-33, 5.8955167159904235e-50},
|
|
1334 |
{3.8834504669882630e-01, -1.0053770598398717e-17, 7.5942999255057131e-34, -3.1967974046654219e-50},
|
|
1335 |
{3.9117038430225387e-01, 1.7997787858243995e-17, -1.0613482402609856e-33, -5.4582148817791032e-50},
|
|
1336 |
{3.9399204006104810e-01, 9.7649241641239336e-18, -2.1233599441284617e-34, -5.5529836795340819e-51},
|
|
1337 |
{3.9680998741671031e-01, 2.0545063670840126e-17, 6.1347058801922842e-34, 1.0733788150636430e-50},
|
|
1338 |
{3.9962419984564684e-01, -1.5065497476189372e-17, -9.9653258881867298e-34, -5.7524323712725355e-50},
|
|
1339 |
{4.0243465085941843e-01, 1.0902619339328270e-17, 7.3998528125989765e-34, 2.2745784806823499e-50},
|
|
1340 |
{4.0524131400498986e-01, 9.9111401942899884e-18, -2.5169070895434648e-34, 9.2772984818436573e-53},
|
|
1341 |
{4.0804416286497869e-01, -7.0006015137351311e-18, -1.4108207334268228e-34, 1.5175546997577136e-52},
|
|
1342 |
{4.1084317105790397e-01, -2.4219835190355499e-17, -1.1418902925313314e-33, -2.0996843165093468e-50},
|
|
1343 |
{4.1363831223843456e-01, -1.0393984940597871e-17, -1.1481681174503880e-34, -2.0281052851028680e-51},
|
|
1344 |
{4.1642956009763721e-01, -2.5475580413131732e-17, -3.4482678506112824e-34, 7.1788619351865480e-51},
|
|
1345 |
{4.1921688836322396e-01, -4.2232463750110590e-18, -3.6053023045255790e-34, -2.2209673210025631e-50},
|
|
1346 |
{4.2200027079979968e-01, 4.3543266994128527e-18, 3.1734310272251190e-34, -1.3573247980738668e-50},
|
|
1347 |
{4.2477968120910881e-01, 2.7462312204277281e-17, -4.6552847802111948e-34, 6.5961781099193122e-51},
|
|
1348 |
{4.2755509343028208e-01, 9.4111898162954726e-18, -1.7446682426598801e-34, -2.2054492626480169e-51},
|
|
1349 |
{4.3032648134008261e-01, 2.2259686974092690e-17, 8.5972591314085075e-34, -2.9420897889003020e-50},
|
|
1350 |
{4.3309381885315196e-01, 1.1224283329847517e-17, 5.3223748041075651e-35, 5.3926192627014212e-51},
|
|
1351 |
{4.3585707992225547e-01, 1.6230515450644527e-17, -6.4371449063579431e-35, -6.9102436481386757e-51},
|
|
1352 |
{4.3861623853852766e-01, -2.0883315831075090e-17, -1.4259583540891877e-34, 6.3864763590657077e-52},
|
|
1353 |
{4.4137126873171667e-01, 2.2360783886964969e-17, 1.1864769603515770e-34, -3.8087003266189232e-51},
|
|
1354 |
{4.4412214457042926e-01, -2.4218874422178315e-17, 2.2205230838703907e-34, 9.2133035911356258e-51},
|
|
1355 |
{4.4686884016237421e-01, -1.9222136142309382e-17, -4.4425678589732049e-35, -1.3673609292149535e-51},
|
|
1356 |
{4.4961132965460660e-01, 4.8831924232035243e-18, 2.7151084498191381e-34, -1.5653993171613154e-50},
|
|
1357 |
{4.5234958723377089e-01, -1.4827977472196122e-17, -7.6947501088972324e-34, 1.7656856882031319e-50},
|
|
1358 |
{4.5508358712634384e-01, -1.2379906758116472e-17, 5.5289688955542643e-34, -8.5382312840209386e-51},
|
|
1359 |
{4.5781330359887723e-01, -8.4554254922295949e-18, -6.3770394246764263e-34, 3.1778253575564249e-50},
|
|
1360 |
{4.6053871095824001e-01, 1.8488777492177872e-17, -1.0527732154209725e-33, 3.3235593490947102e-50},
|
|
1361 |
{4.6325978355186020e-01, -7.3514924533231707e-18, 6.7175396881707035e-34, 3.9594127612123379e-50},
|
|
1362 |
{4.6597649576796618e-01, -3.3023547778235135e-18, 3.4904677050476886e-35, 3.4483855263874246e-51},
|
|
1363 |
{4.6868882203582796e-01, -2.2949251681845054e-17, -1.1364757641823658e-33, 6.8840522501918612e-50},
|
|
1364 |
{4.7139673682599764e-01, 6.5166781360690130e-18, 2.9457546966235984e-34, -6.2159717738836630e-51},
|
|
1365 |
{4.7410021465055002e-01, -8.1451601548978075e-18, -3.4789448555614422e-34, -1.1681943974658508e-50},
|
|
1366 |
{4.7679923006332214e-01, -1.0293515338305794e-17, -3.6582045008369952e-34, 1.7424131479176475e-50},
|
|
1367 |
{4.7949375766015301e-01, 1.8419999662684771e-17, -1.3040838621273312e-33, 1.0977131822246471e-50},
|
|
1368 |
{4.8218377207912277e-01, -2.5861500925520442e-17, -6.2913197606500007e-36, 4.0802359808684726e-52},
|
|
1369 |
{4.8486924800079112e-01, -1.8034004203262245e-17, -3.5244276906958044e-34, -1.7138318654749246e-50},
|
|
1370 |
{4.8755016014843594e-01, 1.4231090931273653e-17, -1.8277733073262697e-34, -1.5208291790429557e-51},
|
|
1371 |
{4.9022648328829116e-01, -5.1496145643440404e-18, -3.6903027405284104e-34, 1.5172940095151304e-50},
|
|
1372 |
{4.9289819222978404e-01, -1.0257831676562186e-18, 6.9520817760885069e-35, -2.4260961214090389e-51},
|
|
1373 |
{4.9556526182577254e-01, -9.4323241942365362e-18, 3.1212918657699143e-35, 4.2009072375242736e-52},
|
|
1374 |
{4.9822766697278187e-01, -1.6126383830540798e-17, -1.5092897319298871e-33, 1.1049298890895917e-50},
|
|
1375 |
{5.0088538261124083e-01, -3.9604015147074639e-17, -2.2208395201898007e-33, 1.3648202735839417e-49},
|
|
1376 |
{5.0353838372571758e-01, -1.6731308204967497e-17, -1.0140233644074786e-33, 4.0953071937671477e-50},
|
|
1377 |
{5.0618664534515534e-01, -4.8321592986493711e-17, 9.2858107226642252e-34, 4.2699802401037005e-50},
|
|
1378 |
{5.0883014254310699e-01, 4.7836968268014130e-17, -1.0727022928806035e-33, 2.7309374513672757e-50},
|
|
1379 |
{5.1146885043797041e-01, -1.3088001221007579e-17, 4.0929033363366899e-34, -3.7952190153477926e-50},
|
|
1380 |
{5.1410274419322177e-01, -4.5712707523615624e-17, 1.5488279442238283e-33, -2.5853959305521130e-50},
|
|
1381 |
{5.1673179901764987e-01, 8.3018617233836515e-18, 5.8251027467695202e-34, -2.2812397190535076e-50},
|
|
1382 |
{5.1935599016558964e-01, -5.5331248144171145e-17, -3.1628375609769026e-35, -2.4091972051188571e-51},
|
|
1383 |
{5.2197529293715439e-01, -4.6555795692088883e-17, 4.6378980936850430e-34, -3.3470542934689532e-51},
|
|
1384 |
{5.2458968267846895e-01, -4.3068869040082345e-17, -4.2013155291932055e-34, -1.5096069926700274e-50},
|
|
1385 |
{5.2719913478190139e-01, -4.2202983480560619e-17, 8.5585916184867295e-34, 7.9974339336732307e-50},
|
|
1386 |
{5.2980362468629472e-01, -4.8067841706482342e-17, 5.8309721046630296e-34, -8.9740761521756660e-51},
|
|
1387 |
{5.3240312787719801e-01, -4.1020306135800895e-17, -1.9239996374230821e-33, -1.5326987913812184e-49},
|
|
1388 |
{5.3499761988709726e-01, -5.3683132708358134e-17, -1.3900569918838112e-33, 2.7154084726474092e-50},
|
|
1389 |
{5.3758707629564551e-01, -2.2617365388403054e-17, -5.9787279033447075e-34, 3.1204419729043625e-51},
|
|
1390 |
{5.4017147272989285e-01, 2.7072447965935839e-17, 1.1698799709213829e-33, -5.9094668515881500e-50},
|
|
1391 |
{5.4275078486451589e-01, 1.7148261004757101e-17, -1.3525905925200870e-33, 4.9724411290727323e-50},
|
|
1392 |
{5.4532498842204646e-01, -4.1517817538384258e-17, -1.5318930219385941e-33, 6.3629921101413974e-50},
|
|
1393 |
{5.4789405917310019e-01, -2.4065878297113363e-17, -3.5639213669362606e-36, -2.6013270854271645e-52},
|
|
1394 |
{5.5045797293660481e-01, -8.3319903015807663e-18, -2.3058454035767633e-34, -2.1611290432369010e-50},
|
|
1395 |
{5.5301670558002758e-01, -4.7061536623798204e-17, -1.0617111545918056e-33, -1.6196316144407379e-50},
|
|
1396 |
{5.5557023301960218e-01, 4.7094109405616768e-17, -2.0640520383682921e-33, 1.2290163188567138e-49},
|
|
1397 |
{5.5811853122055610e-01, 1.3481176324765226e-17, -5.5016743873011438e-34, -2.3484822739335416e-50},
|
|
1398 |
{5.6066157619733603e-01, -7.3956418153476152e-18, 3.9680620611731193e-34, 3.1995952200836223e-50},
|
|
1399 |
{5.6319934401383409e-01, 2.3835775146854829e-17, 1.3511793173769814e-34, 9.3201311581248143e-51},
|
|
1400 |
{5.6573181078361323e-01, -3.4096079596590466e-17, -1.7073289744303546e-33, 8.9147089975404507e-50},
|
|
1401 |
{5.6825895267013160e-01, -5.0935673642769248e-17, -1.6274356351028249e-33, 9.8183151561702966e-51},
|
|
1402 |
{5.7078074588696726e-01, 2.4568151455566208e-17, -1.2844481247560350e-33, -1.8037634376936261e-50},
|
|
1403 |
{5.7329716669804220e-01, 8.5176611669306400e-18, -6.4443208788026766e-34, 2.2546105543273003e-50},
|
|
1404 |
{5.7580819141784534e-01, -3.7909495458942734e-17, -2.7433738046854309e-33, 1.1130841524216795e-49},
|
|
1405 |
{5.7831379641165559e-01, -2.6237691512372831e-17, 1.3679051680738167e-33, -3.1409808935335900e-50},
|
|
1406 |
{5.8081395809576453e-01, 1.8585338586613408e-17, 2.7673843114549181e-34, 1.9605349619836937e-50},
|
|
1407 |
{5.8330865293769829e-01, 3.4516601079044858e-18, 1.8065977478946306e-34, -6.3953958038544646e-51},
|
|
1408 |
{5.8579785745643886e-01, -3.7485501964311294e-18, 2.7965403775536614e-34, -7.1816936024157202e-51},
|
|
1409 |
{5.8828154822264533e-01, -2.9292166725006846e-17, -2.3744954603693934e-33, -1.1571631191512480e-50},
|
|
1410 |
{5.9075970185887428e-01, -4.7013584170659542e-17, 2.4808417611768356e-33, 1.2598907673643198e-50},
|
|
1411 |
{5.9323229503979980e-01, 1.2892320944189053e-17, 5.3058364776359583e-34, 4.1141674699390052e-50},
|
|
1412 |
{5.9569930449243336e-01, -1.3438641936579467e-17, -6.7877687907721049e-35, -5.6046937531684890e-51},
|
|
1413 |
{5.9816070699634227e-01, 3.8801885783000657e-17, -1.2084165858094663e-33, -4.0456610843430061e-50},
|
|
1414 |
{6.0061647938386897e-01, -4.6398198229461932e-17, -1.6673493003710801e-33, 5.1982824378491445e-50},
|
|
1415 |
{6.0306659854034816e-01, 3.7323357680559650e-17, 2.7771920866974305e-33, -1.6194229649742458e-49},
|
|
1416 |
{6.0551104140432555e-01, -3.1202672493305677e-17, 1.2761267338680916e-33, -4.0859368598379647e-50},
|
|
1417 |
{6.0794978496777363e-01, 3.5160832362096660e-17, -2.5546242776778394e-34, -1.4085313551220694e-50},
|
|
1418 |
{6.1038280627630948e-01, -2.2563265648229169e-17, 1.3185575011226730e-33, 8.2316691420063460e-50},
|
|
1419 |
{6.1281008242940971e-01, -4.2693476568409685e-18, 2.5839965886650320e-34, 1.6884412005622537e-50},
|
|
1420 |
{6.1523159058062682e-01, 2.6231417767266950e-17, -1.4095366621106716e-33, 7.2058690491304558e-50},
|
|
1421 |
{6.1764730793780398e-01, -4.7478594510902452e-17, -7.2986558263123996e-34, -3.0152327517439154e-50},
|
|
1422 |
{6.2005721176328921e-01, -2.7983410837681118e-17, 1.1649951056138923e-33, -5.4539089117135207e-50},
|
|
1423 |
{6.2246127937414997e-01, 5.2940728606573002e-18, -4.8486411215945827e-35, 1.2696527641980109e-52},
|
|
1424 |
{6.2485948814238634e-01, 3.3671846037243900e-17, -2.7846053391012096e-33, 5.6102718120012104e-50},
|
|
1425 |
{6.2725181549514408e-01, 3.0763585181253225e-17, 2.7068930273498138e-34, -1.1172240309286484e-50},
|
|
1426 |
{6.2963823891492698e-01, 4.1115334049626806e-17, -1.9167473580230747e-33, 1.1118424028161730e-49},
|
|
1427 |
{6.3201873593980906e-01, -4.0164942296463612e-17, -7.2208643641736723e-34, 3.7828920470544344e-50},
|
|
1428 |
{6.3439328416364549e-01, 1.0420901929280035e-17, 4.1174558929280492e-34, -1.4464152986630705e-51},
|
|
1429 |
{6.3676186123628420e-01, 3.1419048711901611e-17, -2.2693738415126449e-33, -1.6023584204297388e-49},
|
|
1430 |
{6.3912444486377573e-01, 1.2416796312271043e-17, -6.2095419626356605e-34, 2.7762065999506603e-50},
|
|
1431 |
{6.4148101280858316e-01, -9.9883430115943310e-18, 4.1969230376730128e-34, 5.6980543799257597e-51},
|
|
1432 |
{6.4383154288979150e-01, -3.2084798795046886e-17, -1.2595311907053305e-33, -4.0205885230841536e-50},
|
|
1433 |
{6.4617601298331639e-01, -2.9756137382280815e-17, -1.0275370077518259e-33, 8.0852478665893014e-51},
|
|
1434 |
{6.4851440102211244e-01, 3.9870270313386831e-18, 1.9408388509540788e-34, -5.1798420636193190e-51},
|
|
1435 |
{6.5084668499638088e-01, 3.9714670710500257e-17, 2.9178546787002963e-34, 3.8140635508293278e-51},
|
|
1436 |
{6.5317284295377676e-01, 8.5695642060026238e-18, -6.9165322305070633e-34, 2.3873751224185395e-50},
|
|
1437 |
{6.5549285299961535e-01, 3.5638734426385005e-17, 1.2695365790889811e-33, 4.3984952865412050e-50},
|
|
1438 |
{6.5780669329707864e-01, 1.9580943058468545e-17, -1.1944272256627192e-33, 2.8556402616436858e-50},
|
|
1439 |
{6.6011434206742048e-01, -1.3960054386823638e-19, 6.1515777931494047e-36, 5.3510498875622660e-52},
|
|
1440 |
{6.6241577759017178e-01, -2.2615508885764591e-17, 5.0177050318126862e-34, 2.9162532399530762e-50},
|
|
1441 |
{6.6471097820334490e-01, -3.6227793598034367e-17, -9.0607934765540427e-34, 3.0917036342380213e-50},
|
|
1442 |
{6.6699992230363747e-01, 3.5284364997428166e-17, -1.0382057232458238e-33, 7.3812756550167626e-50},
|
|
1443 |
{6.6928258834663612e-01, -5.4592652417447913e-17, -2.5181014709695152e-33, -1.6867875999437174e-49},
|
|
1444 |
{6.7155895484701844e-01, -4.0489037749296692e-17, 3.1995835625355681e-34, -1.4044414655670960e-50},
|
|
1445 |
{6.7382900037875604e-01, 2.3091901236161086e-17, 5.7428037192881319e-34, 1.1240668354625977e-50},
|
|
1446 |
{6.7609270357531592e-01, 3.7256902248049466e-17, 1.7059417895764375e-33, 9.7326347795300652e-50},
|
|
1447 |
{6.7835004312986147e-01, 1.8302093041863122e-17, 9.5241675746813072e-34, 5.0328101116133503e-50},
|
|
1448 |
{6.8060099779545302e-01, 2.8473293354522047e-17, 4.1331805977270903e-34, 4.2579030510748576e-50},
|
|
1449 |
{6.8284554638524808e-01, -1.2958058061524531e-17, 1.8292386959330698e-34, 3.4536209116044487e-51},
|
|
1450 |
{6.8508366777270036e-01, 2.5948135194645137e-17, -8.5030743129500702e-34, -6.9572086141009930e-50},
|
|
1451 |
{6.8731534089175916e-01, -5.5156158714917168e-17, 1.1896489854266829e-33, -7.8505896218220662e-51},
|
|
1452 |
{6.8954054473706694e-01, -1.5889323294806790e-17, 9.1242356240205712e-34, 3.8315454152267638e-50},
|
|
1453 |
{6.9175925836415775e-01, 2.7406078472410668e-17, 1.3286508943202092e-33, 1.0651869129580079e-51},
|
|
1454 |
{6.9397146088965400e-01, 7.4345076956280137e-18, 7.5061528388197460e-34, -1.5928000240686583e-50},
|
|
1455 |
{6.9617713149146299e-01, -4.1224081213582889e-17, -3.1838716762083291e-35, -3.9625587412119131e-51},
|
|
1456 |
{6.9837624940897280e-01, 4.8988282435667768e-17, 1.9134010413244152e-33, 2.6161153243793989e-50},
|
|
1457 |
{7.0056879394324834e-01, 3.1027960192992922e-17, 9.5638250509179997e-34, 4.5896916138107048e-51},
|
|
1458 |
{7.0275474445722530e-01, 2.5278294383629822e-18, -8.6985561210674942e-35, -5.6899862307812990e-51},
|
|
1459 |
{7.0493408037590488e-01, 2.7608725585748502e-17, 2.9816599471629137e-34, 1.1533044185111206e-50},
|
|
1460 |
{7.0710678118654757e-01, -4.8336466567264567e-17, 2.0693376543497068e-33, 2.4677734957341755e-50}
|
|
1461 |
};
|
|
1462 |
|
|
1463 |
static INLINE void
|
|
1464 |
sin_table_qd(double *s0, double *s1, double *s2, double *s3, double j)
|
|
1465 |
{
|
|
1466 |
int int_j=(int)j;
|
|
1467 |
s0[0]=s_table[int_j-1][0];
|
|
1468 |
s1[0]=s_table[int_j-1][1];
|
|
1469 |
s2[0]=s_table[int_j-1][2];
|
|
1470 |
s3[0]=s_table[int_j-1][3];
|
|
1471 |
}
|
|
1472 |
|
|
1473 |
static double c_table[265][4] = {
|
|
1474 |
{9.9999529380957619e-01, -1.9668064285322189e-17, -6.3053955095883481e-34, 5.3266110855726731e-52},
|
|
1475 |
{9.9998117528260111e-01, 3.3568103522895585e-17, -1.4740132559368063e-35, 9.8603097594755596e-52},
|
|
1476 |
{9.9995764455196390e-01, -3.1527836866647287e-17, 2.6363251186638437e-33, 1.0007504815488399e-49},
|
|
1477 |
{9.9992470183914450e-01, 3.7931082512668012e-17, -8.5099918660501484e-35, -4.9956973223295153e-51},
|
|
1478 |
{9.9988234745421256e-01, -3.5477814872408538e-17, 1.7102001035303974e-33, -1.0725388519026542e-49},
|
|
1479 |
{9.9983058179582340e-01, 1.8825140517551119e-17, -5.1383513457616937e-34, -3.8378827995403787e-50},
|
|
1480 |
{9.9976940535121528e-01, 4.2681177032289012e-17, 1.9062302359737099e-33, -6.0221153262881160e-50},
|
|
1481 |
{9.9969881869620425e-01, -2.9851486403799753e-17, -1.9084787370733737e-33, 5.5980260344029202e-51},
|
|
1482 |
{9.9961882249517864e-01, -4.1181965521424734e-17, 2.0915365593699916e-33, 8.1403390920903734e-50},
|
|
1483 |
{9.9952941750109314e-01, 2.0517917823755591e-17, -4.7673802585706520e-34, -2.9443604198656772e-50},
|
|
1484 |
{9.9943060455546173e-01, 3.9644497752257798e-17, -2.3757223716722428e-34, -1.2856759011361726e-51},
|
|
1485 |
{9.9932238458834954e-01, -4.2858538440845682e-17, 3.3235101605146565e-34, -8.3554272377057543e-51},
|
|
1486 |
{9.9920475861836389e-01, 9.1796317110385693e-18, 5.5416208185868570e-34, 8.0267046717615311e-52},
|
|
1487 |
{9.9907772775264536e-01, 2.1419007653587032e-17, -7.9048203318529618e-34, -5.3166296181112712e-50},
|
|
1488 |
{9.9894129318685687e-01, -2.0610641910058638e-17, -1.2546525485913485e-33, -7.5175888806157064e-50},
|
|
1489 |
{9.9879545620517241e-01, -1.2291693337075465e-17, 2.4468446786491271e-34, 1.0723891085210268e-50},
|
|
1490 |
{9.9864021818026527e-01, -4.8690254312923302e-17, -2.9470881967909147e-34, -1.3000650761346907e-50},
|
|
1491 |
{9.9847558057329477e-01, -2.2002931182778795e-17, -1.2371509454944992e-33, -2.4911225131232065e-50},
|
|
1492 |
{9.9830154493389289e-01, -5.1869402702792278e-17, 1.0480195493633452e-33, -2.8995649143155511e-50},
|
|
1493 |
{9.9811811290014918e-01, 2.7935487558113833e-17, 2.4423341255830345e-33, -6.7646699175334417e-50},
|
|
1494 |
{9.9792528619859600e-01, 1.7143659778886362e-17, 5.7885840902887460e-34, -9.2601432603894597e-51},
|
|
1495 |
{9.9772306664419164e-01, -2.6394475274898721e-17, -1.6176223087661783e-34, -9.9924942889362281e-51},
|
|
1496 |
{9.9751145614030345e-01, 5.6007205919806937e-18, -5.9477673514685690e-35, -1.4166807162743627e-54},
|
|
1497 |
{9.9729045667869021e-01, 9.1647695371101735e-18, 6.7824134309739296e-34, -8.6191392795543357e-52},
|
|
1498 |
{9.9706007033948296e-01, 1.6734093546241963e-17, -1.3169951440780028e-33, 1.0311048767952477e-50},
|
|
1499 |
{9.9682029929116567e-01, 4.7062820708615655e-17, 2.8412041076474937e-33, -8.0006155670263622e-50},
|
|
1500 |
{9.9657114579055484e-01, 1.1707179088390986e-17, -7.5934413263024663e-34, 2.8474848436926008e-50},
|
|
1501 |
{9.9631261218277800e-01, 1.1336497891624735e-17, 3.4002458674414360e-34, 7.7419075921544901e-52},
|
|
1502 |
{9.9604470090125197e-01, 2.2870031707670695e-17, -3.9184839405013148e-34, -3.7081260416246375e-50},
|
|
1503 |
{9.9576741446765982e-01, -2.3151908323094359e-17, -1.6306512931944591e-34, -1.5925420783863192e-51},
|
|
1504 |
{9.9548075549192694e-01, 3.2084621412226554e-18, -4.9501292146013023e-36, -2.7811428850878516e-52},
|
|
1505 |
{9.9518472667219693e-01, -4.2486913678304410e-17, 1.3315510772504614e-33, 6.7927987417051888e-50},
|
|
1506 |
{9.9487933079480562e-01, 4.2130813284943662e-18, -4.2062597488288452e-35, 2.5157064556087620e-51},
|
|
1507 |
{9.9456457073425542e-01, 3.6745069641528058e-17, -3.0603304105471010e-33, 1.0397872280487526e-49},
|
|
1508 |
{9.9424044945318790e-01, 4.4129423472462673e-17, -3.0107231708238066e-33, 7.4201582906861892e-50},
|
|
1509 |
{9.9390697000235606e-01, -1.8964849471123746e-17, -1.5980853777937752e-35, -8.5374807150597082e-52},
|
|
1510 |
{9.9356413552059530e-01, 2.9752309927797428e-17, -4.5066707331134233e-34, -3.3548191633805036e-50},
|
|
1511 |
{9.9321194923479450e-01, 3.3096906261272262e-17, 1.5592811973249567e-33, 1.4373977733253592e-50},
|
|
1512 |
{9.9285041445986510e-01, -1.4094517733693302e-17, -1.1954558131616916e-33, 1.8761873742867983e-50},
|
|
1513 |
{9.9247953459870997e-01, 3.1093055095428906e-17, -1.8379594757818019e-33, -3.9885758559381314e-51},
|
|
1514 |
{9.9209931314219180e-01, -3.9431926149588778e-17, -6.2758062911047230e-34, -1.2960929559212390e-50},
|
|
1515 |
{9.9170975366909953e-01, -2.3372891311883661e-18, 2.7073298824968591e-35, -1.2569459441802872e-51},
|
|
1516 |
{9.9131085984611544e-01, -2.5192111583372105e-17, -1.2852471567380887e-33, 5.2385212584310483e-50},
|
|
1517 |
{9.9090263542778001e-01, 1.5394565094566704e-17, -1.0799984133184567e-33, 2.7451115960133595e-51},
|
|
1518 |
{9.9048508425645709e-01, -5.5411437553780867e-17, -1.4614017210753585e-33, -3.8339374397387620e-50},
|
|
1519 |
{9.9005821026229712e-01, -1.7055485906233963e-17, 1.3454939685758777e-33, 7.3117589137300036e-50},
|
|
1520 |
{9.8962201746320089e-01, -5.2398217968132530e-17, 1.3463189211456219e-33, 5.8021640554894872e-50},
|
|
1521 |
{9.8917650996478101e-01, -4.0987309937047111e-17, -4.4857560552048437e-34, -3.9414504502871125e-50},
|
|
1522 |
{9.8872169196032378e-01, -1.0976227206656125e-17, 3.2311342577653764e-34, 9.6367946583575041e-51},
|
|
1523 |
{9.8825756773074946e-01, 2.7030607784372632e-17, 7.7514866488601377e-35, 2.1019644956864938e-51},
|
|
1524 |
{9.8778414164457218e-01, -2.3600693397159021e-17, -1.2323283769707861e-33, 3.0130900716803339e-50},
|
|
1525 |
{9.8730141815785843e-01, -5.2332261255715652e-17, -2.7937644333152473e-33, 1.2074160567958408e-49},
|
|
1526 |
{9.8680940181418553e-01, -5.0287214351061075e-17, -2.2681526238144461e-33, 4.4003694320169133e-50},
|
|
1527 |
{9.8630809724459867e-01, -2.1520877103013341e-17, 1.1866528054187716e-33, -7.8532199199813836e-50},
|
|
1528 |
{9.8579750916756748e-01, -5.1439452979953012e-17, 2.6276439309996725e-33, 7.5423552783286347e-50},
|
|
1529 |
{9.8527764238894122e-01, 2.3155637027900207e-17, -7.5275971545764833e-34, 1.0582231660456094e-50},
|
|
1530 |
{9.8474850180190421e-01, 1.0548144061829957e-17, 2.8786145266267306e-34, -3.6782210081466112e-51},
|
|
1531 |
{9.8421009238692903e-01, 4.7983922627050691e-17, 2.2597419645070588e-34, 1.7573875814863400e-50},
|
|
1532 |
{9.8366241921173025e-01, 1.9864948201635255e-17, -1.0743046281211033e-35, 1.7975662796558100e-52},
|
|
1533 |
{9.8310548743121629e-01, 4.2170007522888628e-17, 8.2396265656440904e-34, -8.0803700139096561e-50},
|
|
1534 |
{9.8253930228744124e-01, 1.5149580813777224e-17, -4.1802771422186237e-34, -2.2150174326226160e-50},
|
|
1535 |
{9.8196386910955524e-01, 2.1108443711513084e-17, -1.5253013442896054e-33, -6.8388082079337969e-50},
|
|
1536 |
{9.8137919331375456e-01, 1.3428163260355633e-17, -6.5294290469962986e-34, 2.7965412287456268e-51},
|
|
1537 |
{9.8078528040323043e-01, 1.8546939997825006e-17, -1.0696564445530757e-33, 6.6668174475264961e-50},
|
|
1538 |
{9.8018213596811743e-01, -3.6801786963856159e-17, 6.3245171387992842e-34, 1.8600176137175971e-50},
|
|
1539 |
{9.7956976568544052e-01, 1.5573991584990420e-17, -1.3401066029782990e-33, -1.7263702199862149e-50},
|
|
1540 |
{9.7894817531906220e-01, -2.3817727961148053e-18, -1.0694750370381661e-34, -8.2293047196087462e-51},
|
|
1541 |
{9.7831737071962765e-01, -2.1623082233344895e-17, 1.0970403012028032e-33, 7.7091923099369339e-50},
|
|
1542 |
{9.7767735782450993e-01, 5.0514136167059628e-17, -1.3254751701428788e-33, 7.0161254312124538e-50},
|
|
1543 |
{9.7702814265775439e-01, -4.3353875751555997e-17, 5.4948839831535478e-34, -9.2755263105377306e-51},
|
|
1544 |
{9.7636973133002114e-01, 9.3093931526213780e-18, -4.1184949155685665e-34, -3.1913926031393690e-50},
|
|
1545 |
{9.7570213003852857e-01, -2.5572556081259686e-17, -9.3174244508942223e-34, -8.3675863211646863e-51},
|
|
1546 |
{9.7502534506699412e-01, 2.6642660651899135e-17, 1.7819392739353853e-34, -3.3159625385648947e-51},
|
|
1547 |
{9.7433938278557586e-01, 2.3041221476151512e-18, 1.0758686005031430e-34, 5.1074116432809478e-51},
|
|
1548 |
{9.7364424965081198e-01, -5.1729808691005871e-17, -1.5508473005989887e-33, -1.6505125917675401e-49},
|
|
1549 |
{9.7293995220556018e-01, -3.1311211122281800e-17, -2.6874087789006141e-33, -2.1652434818822145e-51},
|
|
1550 |
{9.7222649707893627e-01, 3.6461169785938221e-17, 3.0309636883883133e-33, -1.2702716907967306e-51},
|
|
1551 |
{9.7150389098625178e-01, -7.9865421122289046e-18, -4.3628417211263380e-34, 3.4307517798759352e-51},
|
|
1552 |
{9.7077214072895035e-01, -4.7992163325114922e-17, 3.0347528910975783e-33, 8.5989199506479701e-50},
|
|
1553 |
{9.7003125319454397e-01, 1.8365300348428844e-17, -1.4311097571944918e-33, 8.5846781998740697e-51},
|
|
1554 |
{9.6928123535654853e-01, -4.5663660261927896e-17, 9.6147526917239387e-34, 8.1267605207871330e-51},
|
|
1555 |
{9.6852209427441727e-01, 4.9475074918244771e-17, 2.8558738351911241e-33, 6.2948422316507461e-50},
|
|
1556 |
{9.6775383709347551e-01, -4.5512132825515820e-17, -1.4127617988719093e-33, -8.4620609089704578e-50},
|
|
1557 |
{9.6697647104485207e-01, 3.8496228837337864e-17, -5.3881631542745647e-34, -3.5221863171458959e-50},
|
|
1558 |
{9.6619000344541250e-01, 5.1298840401665493e-17, 1.4564075904769808e-34, 1.0095973971377432e-50},
|
|
1559 |
{9.6539444169768940e-01, -2.3745389918392156e-17, 5.9221515590053862e-34, -3.8811192556231094e-50},
|
|
1560 |
{9.6458979328981276e-01, -3.4189470735959786e-17, 2.2982074155463522e-33, -4.5128791045607634e-50},
|
|
1561 |
{9.6377606579543984e-01, 2.6463950561220029e-17, -2.9073234590199323e-36, -1.2938328629395601e-52},
|
|
1562 |
{9.6295326687368388e-01, 8.9341960404313634e-18, -3.9071244661020126e-34, 1.6212091116847394e-50},
|
|
1563 |
{9.6212140426904158e-01, 1.5236770453846305e-17, -1.3050173525597142e-33, 7.9016122394092666e-50},
|
|
1564 |
{9.6128048581132064e-01, 2.0933955216674039e-18, 1.0768607469015692e-34, -5.9453639304361774e-51},
|
|
1565 |
{9.6043051941556579e-01, 2.4653904815317185e-17, -1.3792169410906322e-33, -4.7726598378506903e-51},
|
|
1566 |
{9.5957151308198452e-01, 1.1000640085000957e-17, -4.2036030828223975e-34, 4.0023704842606573e-51},
|
|
1567 |
{9.5870347489587160e-01, -4.3685014392372053e-17, 2.2001800662729131e-33, -1.0553721324358075e-49},
|
|
1568 |
{9.5782641302753291e-01, -1.7696710075371263e-17, 1.9164034110382190e-34, 8.1489235071754813e-51},
|
|
1569 |
{9.5694033573220882e-01, 4.0553869861875701e-17, -1.7147013364302149e-33, 2.5736745295329455e-50},
|
|
1570 |
{9.5604525134999641e-01, 3.7705045279589067e-17, 1.9678699997347571e-33, 8.5093177731230180e-50},
|
|
1571 |
{9.5514116830577067e-01, 5.0088652955014668e-17, -2.6983181838059211e-33, 1.0102323575596493e-49},
|
|
1572 |
{9.5422809510910567e-01, -3.7545901690626874e-17, 1.4951619241257764e-33, -8.2717333151394973e-50},
|
|
1573 |
{9.5330604035419386e-01, -2.5190738779919934e-17, -1.4272239821134379e-33, -4.6717286809283155e-50},
|
|
1574 |
{9.5237501271976588e-01, -2.0269300462299272e-17, -1.0635956887246246e-33, -3.5514537666487619e-50},
|
|
1575 |
{9.5143502096900834e-01, 3.1350584123266695e-17, -2.4824833452737813e-33, 9.5450335525380613e-51},
|
|
1576 |
{9.5048607394948170e-01, 1.9410097562630436e-17, -8.1559393949816789e-34, -1.0501209720164562e-50},
|
|
1577 |
{9.4952818059303667e-01, -7.5544151928043298e-18, -5.1260245024046686e-34, 1.8093643389040406e-50},
|
|
1578 |
{9.4856134991573027e-01, 2.0668262262333232e-17, -5.9440730243667306e-34, 1.4268853111554300e-50},
|
|
1579 |
{9.4758559101774109e-01, 4.3417993852125991e-17, -2.7728667889840373e-34, 5.5709160196519968e-51},
|
|
1580 |
{9.4660091308328353e-01, 3.5056800210680730e-17, 9.8578536940318117e-34, 6.6035911064585197e-50},
|
|
1581 |
{9.4560732538052128e-01, 4.6019102478523738e-17, -6.2534384769452059e-34, 1.5758941215779961e-50},
|
|
1582 |
{9.4460483726148026e-01, 8.8100545476641165e-18, 5.2291695602757842e-34, -3.3487256018407123e-50},
|
|
1583 |
{9.4359345816196039e-01, -2.4093127844404214e-17, 1.0283279856803939e-34, -2.3398232614531355e-51},
|
|
1584 |
{9.4257319760144687e-01, 1.3235564806436886e-17, -5.7048262885386911e-35, 3.9947050442753744e-51},
|
|
1585 |
{9.4154406518302081e-01, -2.7896379547698341e-17, 1.6273236356733898e-33, -5.3075944708471203e-51},
|
|
1586 |
{9.4050607059326830e-01, 2.8610421567116268e-17, 2.9261501147538827e-33, -2.6849867690896925e-50},
|
|
1587 |
{9.3945922360218992e-01, -7.0152867943098655e-18, -5.6395693818011210e-34, 3.5568142678987651e-50},
|
|
1588 |
{9.3840353406310806e-01, 5.4242545044795490e-17, -1.9039966607859759e-33, -1.5627792988341215e-49},
|
|
1589 |
{9.3733901191257496e-01, -3.6570926284362776e-17, -1.1902940071273247e-33, -1.1215082331583223e-50},
|
|
1590 |
{9.3626566717027826e-01, -1.3013766145497654e-17, 5.2229870061990595e-34, -3.3972777075634108e-51},
|
|
1591 |
{9.3518350993894761e-01, -3.2609395302485065e-17, -8.1813015218875245e-34, 5.5642140024928139e-50},
|
|
1592 |
{9.3409255040425887e-01, 4.4662824360767511e-17, -2.5903243047396916e-33, 8.1505209004343043e-50},
|
|
1593 |
{9.3299279883473885e-01, 4.2041415555384355e-17, 9.0285896495521276e-34, 5.3019984977661259e-50},
|
|
1594 |
{9.3188426558166815e-01, -4.0785944377318095e-17, 1.7631450298754169e-33, 2.5776403305507453e-50},
|
|
1595 |
{9.3076696107898371e-01, 1.9703775102838329e-17, 6.5657908718278205e-34, -1.9480347966259524e-51},
|
|
1596 |
{9.2964089584318121e-01, 5.1282530016864107e-17, 2.3719739891916261e-34, -1.7230065426917127e-50},
|
|
1597 |
{9.2850608047321559e-01, -2.3306639848485943e-17, -7.7799084333208503e-34, -5.8597558009300305e-50},
|
|
1598 |
{9.2736252565040111e-01, -2.7677111692155437e-17, 2.2110293450199576e-34, 2.0349190819680613e-50},
|
|
1599 |
{9.2621024213831138e-01, -3.7303754586099054e-17, 2.0464457809993405e-33, 1.3831799631231817e-49},
|
|
1600 |
{9.2504924078267758e-01, 6.0529447412576159e-18, -8.8256517760278541e-35, 1.8285462122388328e-51},
|
|
1601 |
{9.2387953251128674e-01, 1.7645047084336677e-17, -5.0442537321586818e-34, -4.0478677716823890e-50},
|
|
1602 |
{9.2270112833387852e-01, 5.2963798918539814e-17, -5.7135699628876685e-34, 3.0163671797219087e-50},
|
|
1603 |
{9.2151403934204190e-01, 4.1639843390684644e-17, 1.1891485604702356e-33, 2.0862437594380324e-50},
|
|
1604 |
{9.2031827670911059e-01, -2.7806888779036837e-17, 2.7011013677071274e-33, 1.1998578792455499e-49},
|
|
1605 |
{9.1911385169005777e-01, -2.6496484622344718e-17, 6.5403604763461920e-34, -2.8997180201186078e-50},
|
|
1606 |
{9.1790077562139050e-01, -3.9074579680849515e-17, 2.3004636541490264e-33, 3.9851762744443107e-50},
|
|
1607 |
{9.1667905992104270e-01, -4.1733978698287568e-17, 1.2094444804381172e-33, 4.9356916826097816e-50},
|
|
1608 |
{9.1544871608826783e-01, -1.3591056692900894e-17, 5.9923027475594735e-34, 2.1403295925962879e-50},
|
|
1609 |
{9.1420975570353069e-01, -3.6316182527814423e-17, -1.9438819777122554e-33, 2.8340679287728316e-50},
|
|
1610 |
{9.1296219042839821e-01, -4.7932505228039469e-17, -1.7753551889428638e-33, 4.0607782903868160e-51},
|
|
1611 |
{9.1170603200542988e-01, -2.6913273175034130e-17, -5.1928101916162528e-35, 1.1338175936090630e-51},
|
|
1612 |
{9.1044129225806725e-01, -5.0433041673313820e-17, 1.0938746257404305e-33, 9.5378272084170731e-51},
|
|
1613 |
{9.0916798309052238e-01, -3.6878564091359894e-18, 2.9951330310507693e-34, -1.2225666136919926e-50},
|
|
1614 |
{9.0788611648766626e-01, -4.9459964301225840e-17, -1.6599682707075313e-33, -5.1925202712634716e-50},
|
|
1615 |
{9.0659570451491533e-01, 3.0506718955442023e-17, -1.4478836557141204e-33, 1.8906373784448725e-50},
|
|
1616 |
{9.0529675931811882e-01, -4.1153099826889901e-17, 2.9859368705184223e-33, 5.1145293917439211e-50},
|
|
1617 |
{9.0398929312344334e-01, -6.6097544687484308e-18, 1.2728013034680357e-34, -4.3026097234014823e-51},
|
|
1618 |
{9.0267331823725883e-01, -1.9250787033961483e-17, 1.3242128993244527e-33, -5.2971030688703665e-50},
|
|
1619 |
{9.0134884704602203e-01, -1.3524789367698682e-17, 6.3605353115880091e-34, 3.6227400654573828e-50},
|
|
1620 |
{9.0001589201616028e-01, -5.0639618050802273e-17, 1.0783525384031576e-33, 2.8130016326515111e-50},
|
|
1621 |
{8.9867446569395382e-01, 2.6316906461033013e-17, 3.7003137047796840e-35, -2.3447719900465938e-51},
|
|
1622 |
{8.9732458070541832e-01, -3.6396283314867290e-17, -2.3611649895474815e-33, 1.1837247047900082e-49},
|
|
1623 |
{8.9596624975618511e-01, 4.9025099114811813e-17, -1.9440489814795326e-33, -1.7070486667767033e-49},
|
|
1624 |
{8.9459948563138270e-01, -1.7516226396814919e-17, -1.3200670047246923e-33, -1.5953009884324695e-50},
|
|
1625 |
{8.9322430119551532e-01, -4.1161239151908913e-18, 2.5380253805715999e-34, 4.2849455510516192e-51},
|
|
1626 |
{8.9184070939234272e-01, 4.6690228137124547e-18, 1.6150254286841982e-34, -3.9617448820725012e-51},
|
|
1627 |
{8.9044872324475788e-01, 1.1781931459051803e-17, -1.3346142209571930e-34, -9.4982373530733431e-51},
|
|
1628 |
{8.8904835585466457e-01, -1.1164514966766675e-17, -3.4797636107798736e-34, -1.5605079997040631e-50},
|
|
1629 |
{8.8763962040285393e-01, 1.2805091918587960e-17, 3.9948742059584459e-35, 3.8940716325338136e-51},
|
|
1630 |
{8.8622253014888064e-01, -6.7307369600274315e-18, 1.2385593432917413e-34, 2.0364014759133320e-51},
|
|
1631 |
{8.8479709843093779e-01, -9.4331469628972690e-18, -5.7106541478701439e-34, 1.8260134111907397e-50},
|
|
1632 |
{8.8336333866573158e-01, 1.5822643380255127e-17, -7.8921320007588250e-34, -1.4782321016179836e-50},
|
|
1633 |
{8.8192126434835505e-01, -1.9843248405890562e-17, -7.0412114007673834e-34, -1.0636770169389104e-50},
|
|
1634 |
{8.8047088905216075e-01, 1.6311096602996350e-17, -5.7541360594724172e-34, -4.0128611862170021e-50},
|
|
1635 |
{8.7901222642863353e-01, -4.7356837291118011e-17, 1.4388771297975192e-33, -2.9085554304479134e-50},
|
|
1636 |
{8.7754529020726124e-01, 5.0113311846499550e-17, 2.8382769008739543e-34, 1.5550640393164140e-50},
|
|
1637 |
{8.7607009419540660e-01, 5.8729024235147677e-18, 2.7941144391738458e-34, -1.8536073846509828e-50},
|
|
1638 |
{8.7458665227817611e-01, -5.7216617730397065e-19, -2.9705811503689596e-35, 8.7389593969796752e-52},
|
|
1639 |
{8.7309497841829009e-01, 7.8424672990129903e-18, -4.8685015839797165e-34, -2.2815570587477527e-50},
|
|
1640 |
{8.7159508665595109e-01, -5.5272998038551050e-17, -2.2104090204984907e-33, -9.7749763187643172e-50},
|
|
1641 |
{8.7008699110871146e-01, -4.1888510868549968e-17, 7.0900185861878415e-34, 3.7600251115157260e-50},
|
|
1642 |
{8.6857070597134090e-01, 2.7192781689782903e-19, -1.6710140396932428e-35, -1.2625514734637969e-51},
|
|
1643 |
{8.6704624551569265e-01, 3.0267859550930567e-18, -1.1559438782171572e-34, -5.3580556397808012e-52},
|
|
1644 |
{8.6551362409056909e-01, -6.3723113549628899e-18, 2.3725520321746832e-34, 1.5911880348395175e-50},
|
|
1645 |
{8.6397285612158670e-01, 4.1486355957361607e-17, 2.2709976932210266e-33, -8.1228385659479984e-50},
|
|
1646 |
{8.6242395611104050e-01, 3.7008992527383130e-17, 5.2128411542701573e-34, 2.6945600081026861e-50},
|
|
1647 |
{8.6086693863776731e-01, -3.0050048898573656e-17, -8.8706183090892111e-34, 1.5005320558097301e-50},
|
|
1648 |
{8.5930181835700836e-01, 4.2435655816850687e-17, 7.6181814059912025e-34, -3.9592127850658708e-50},
|
|
1649 |
{8.5772861000027212e-01, -4.8183447936336620e-17, -1.1044130517687532e-33, -8.7400233444645562e-50},
|
|
1650 |
{8.5614732837519447e-01, 9.1806925616606261e-18, 5.6328649785951470e-34, 2.3326646113217378e-51},
|
|
1651 |
{8.5455798836540053e-01, -1.2991124236396092e-17, 1.2893407722948080e-34, -3.6506925747583053e-52},
|
|
1652 |
{8.5296060493036363e-01, 2.7152984251981370e-17, 7.4336483283120719e-34, 4.2162417622350668e-50},
|
|
1653 |
{8.5135519310526520e-01, -5.3279874446016209e-17, 2.2281156380919942e-33, -4.0281886404138477e-50},
|
|
1654 |
{8.4974176800085244e-01, 5.1812347659974015e-17, 3.0810626087331275e-33, -2.5931308201994965e-50},
|
|
1655 |
{8.4812034480329723e-01, 1.8762563415239981e-17, 1.4048773307919617e-33, -2.4915221509958691e-50},
|
|
1656 |
{8.4649093877405213e-01, -4.7969419958569345e-17, -2.7518267097886703e-33, -7.3518959727313350e-50},
|
|
1657 |
{8.4485356524970712e-01, -4.3631360296879637e-17, -2.0307726853367547e-33, 4.3097229819851761e-50},
|
|
1658 |
{8.4320823964184544e-01, 9.6536707005959077e-19, 2.8995142431556364e-36, 9.6715076811480284e-53},
|
|
1659 |
{8.4155497743689844e-01, -3.4095465391321557e-17, -8.4130208607579595e-34, -4.9447283960568686e-50},
|
|
1660 |
{8.3989379419599952e-01, -1.6673694881511411e-17, -1.4759184141750289e-33, -7.5795098161914058e-50},
|
|
1661 |
{8.3822470555483808e-01, -3.5560085052855026e-17, 1.1689791577022643e-33, -5.8627347359723411e-50},
|
|
1662 |
{8.3654772722351201e-01, -2.0899059027066533e-17, -9.8104097821002585e-35, -3.1609177868229853e-51},
|
|
1663 |
{8.3486287498638001e-01, 4.6048430609159657e-17, -5.1827423265239912e-34, -7.0505343435504109e-51},
|
|
1664 |
{8.3317016470191319e-01, 1.3275129507229764e-18, 4.8589164115370863e-35, 4.5422281300506859e-51},
|
|
1665 |
{8.3146961230254524e-01, 1.4073856984728024e-18, 4.6951315383980830e-35, 5.1431906049905658e-51},
|
|
1666 |
{8.2976123379452305e-01, -2.9349109376485597e-18, 1.1496917934149818e-34, 3.5186665544980233e-51},
|
|
1667 |
{8.2804504525775580e-01, -4.4196593225871532e-17, 2.7967864855211251e-33, 1.0030777287393502e-49},
|
|
1668 |
{8.2632106284566353e-01, -5.3957485453612902e-17, 6.8976896130138550e-34, 3.8106164274199196e-50},
|
|
1669 |
{8.2458930278502529e-01, -2.6512360488868275e-17, 1.6916964350914386e-34, 6.7693974813562649e-51},
|
|
1670 |
{8.2284978137582632e-01, 1.5193019034505495e-17, 9.6890547246521685e-34, 5.6994562923653264e-50},
|
|
1671 |
{8.2110251499110465e-01, 3.0715131609697682e-17, -1.7037168325855879e-33, -1.1149862443283853e-49},
|
|
1672 |
{8.1934752007679701e-01, -4.8200736995191133e-17, -1.5574489646672781e-35, -9.5647853614522216e-53},
|
|
1673 |
{8.1758481315158371e-01, -1.4883149812426772e-17, -7.8273262771298917e-34, 4.1332149161031594e-50},
|
|
1674 |
{8.1581441080673378e-01, 8.2652693782130871e-18, -2.3028778135179471e-34, 1.5102071387249843e-50},
|
|
1675 |
{8.1403632970594841e-01, -5.2127351877042624e-17, -1.9047670611316360e-33, -1.6937269585941507e-49},
|
|
1676 |
{8.1225058658520388e-01, 3.1054545609214803e-17, 2.2649541922707251e-34, -7.4221684154649405e-51},
|
|
1677 |
{8.1045719825259477e-01, 2.3520367349840499e-17, -7.7530070904846341e-34, -7.2792616357197140e-50},
|
|
1678 |
{8.0865618158817498e-01, 9.3251597879721674e-18, -7.1823301933068394e-34, 2.3925440846132106e-50},
|
|
1679 |
{8.0684755354379922e-01, 4.9220603766095546e-17, 2.9796016899903487e-33, 1.5220754223615788e-49},
|
|
1680 |
{8.0503133114296355e-01, 5.1368289568212149e-17, 6.3082807402256524e-34, 7.3277646085129827e-51},
|
|
1681 |
{8.0320753148064494e-01, -3.3060609804814910e-17, -1.2242726252420433e-33, 2.8413673268630117e-50},
|
|
1682 |
{8.0137617172314024e-01, -2.0958013413495834e-17, -4.3798162198006931e-34, 2.0235690497752515e-50},
|
|
1683 |
{7.9953726910790501e-01, 2.0356723822005431e-17, -9.7448513696896360e-34, 5.3608109599696008e-52},
|
|
1684 |
{7.9769084094339116e-01, -4.6730759884788944e-17, 2.3075897077191757e-33, 3.1605567774640253e-51},
|
|
1685 |
{7.9583690460888357e-01, -3.0062724851910721e-17, -2.2496210832042235e-33, -6.5881774117183040e-50},
|
|
1686 |
{7.9397547755433717e-01, -7.4194631759921416e-18, 2.4124341304631069e-34, -4.9956808616244972e-51},
|
|
1687 |
{7.9210657730021239e-01, -3.7087850202326467e-17, -1.4874457267228264e-33, 2.9323097289153505e-50},
|
|
1688 |
{7.9023022143731003e-01, 2.3056905954954492e-17, 1.4481080533260193e-33, -7.6725237057203488e-50},
|
|
1689 |
{7.8834642762660623e-01, 3.4396993154059708e-17, 1.7710623746737170e-33, 1.7084159098417402e-49},
|
|
1690 |
{7.8645521359908577e-01, -9.7841429939305265e-18, 3.3906063272445472e-34, 5.7269505320382577e-51},
|
|
1691 |
{7.8455659715557524e-01, -8.5627965423173476e-18, -2.1106834459001849e-34, -1.6890322182469603e-50},
|
|
1692 |
{7.8265059616657573e-01, 9.0745866975808825e-18, 6.7623847404278666e-34, -1.7173237731987271e-50},
|
|
1693 |
{7.8073722857209449e-01, -9.9198782066678806e-18, -2.1265794012162715e-36, 3.0772165598957647e-54},
|
|
1694 |
{7.7881651238147598e-01, -2.4891385579973807e-17, 6.7665497024807980e-35, -6.5218594281701332e-52},
|
|
1695 |
{7.7688846567323244e-01, 7.7418602570672864e-18, -5.9986517872157897e-34, 3.0566548232958972e-50},
|
|
1696 |
{7.7495310659487393e-01, -5.2209083189826433e-17, -9.6653593393686612e-34, 3.7027750076562569e-50},
|
|
1697 |
{7.7301045336273699e-01, -3.2565907033649772e-17, 1.3860807251523929e-33, -3.9971329917586022e-50},
|
|
1698 |
{7.7106052426181382e-01, -4.4558442347769265e-17, -2.9863565614083783e-33, -6.8795262083596236e-50},
|
|
1699 |
{7.6910333764557959e-01, 5.1546455184564817e-17, 2.6142829553524292e-33, -1.6199023632773298e-49},
|
|
1700 |
{7.6713891193582040e-01, -1.8885903683750782e-17, -1.3659359331495433e-33, -2.2538834962921934e-50},
|
|
1701 |
{7.6516726562245896e-01, -3.2707225612534598e-17, 1.1177117747079528e-33, -3.7005182280175715e-50},
|
|
1702 |
{7.6318841726338127e-01, 2.6314748416750748e-18, 1.4048039063095910e-34, 8.9601886626630321e-52},
|
|
1703 |
{7.6120238548426178e-01, 3.5315510881690551e-17, 1.2833566381864357e-33, 8.6221435180890613e-50},
|
|
1704 |
{7.5920918897838807e-01, -3.8558842175523123e-17, 2.9720241208332759e-34, -1.2521388928220163e-50},
|
|
1705 |
{7.5720884650648457e-01, -1.9909098777335502e-17, 3.9409283266158482e-34, 2.0744254207802976e-50},
|
|
1706 |
{7.5520137689653655e-01, -1.9402238001823017e-17, -3.7756206444727573e-34, -2.1212242308178287e-50},
|
|
1707 |
{7.5318679904361252e-01, -3.7937789838736540e-17, -6.7009539920231559e-34, -6.7128562115050214e-51},
|
|
1708 |
{7.5116513190968637e-01, 4.3499761158645868e-17, 2.5227718971102212e-33, -6.5969709212757102e-50},
|
|
1709 |
{7.4913639452345937e-01, -4.4729078447011889e-17, -2.4206025249983768e-33, 1.1336681351116422e-49},
|
|
1710 |
{7.4710060598018013e-01, 1.1874824875965430e-17, 2.1992523849833518e-34, 1.1025018564644483e-50},
|
|
1711 |
{7.4505778544146595e-01, 1.5078686911877863e-17, 8.0898987212942471e-34, 8.2677958765323532e-50},
|
|
1712 |
{7.4300795213512172e-01, -2.5144629669719265e-17, 7.1128989512526157e-34, 3.0181629077821220e-50},
|
|
1713 |
{7.4095112535495911e-01, -1.4708616952297345e-17, -4.9550433827142032e-34, 3.1434132533735671e-50},
|
|
1714 |
{7.3888732446061511e-01, 3.4324874808225091e-17, -1.3706639444717610e-33, -3.3520827530718938e-51},
|
|
1715 |
{7.3681656887736990e-01, -2.8932468101656295e-17, -3.4649887126202378e-34, -1.8484474476291476e-50},
|
|
1716 |
{7.3473887809596350e-01, -3.4507595976263941e-17, -2.3718000676666409e-33, -3.9696090387165402e-50},
|
|
1717 |
{7.3265427167241282e-01, 1.8918673481573520e-17, -1.5123719544119886e-33, -9.7922152011625728e-51},
|
|
1718 |
{7.3056276922782759e-01, -2.9689959904476928e-17, -1.1276871244239744e-33, -3.0531520961539007e-50},
|
|
1719 |
{7.2846439044822520e-01, 1.1924642323370718e-19, 5.9001892316611011e-36, 1.2178089069502704e-52},
|
|
1720 |
{7.2635915508434601e-01, -3.1917502443460542e-17, 7.7047912412039396e-34, 4.1455880160182123e-50},
|
|
1721 |
{7.2424708295146689e-01, 2.9198471334403004e-17, 2.3027324968739464e-33, -1.2928820533892183e-51},
|
|
1722 |
{7.2212819392921535e-01, -2.3871262053452047e-17, 1.0636125432862273e-33, -4.4598638837802517e-50},
|
|
1723 |
{7.2000250796138165e-01, -2.5689658854462333e-17, -9.1492566948567925e-34, 4.4403780801267786e-50},
|
|
1724 |
{7.1787004505573171e-01, 2.7006476062511453e-17, -2.2854956580215348e-34, 9.1726903890287867e-51},
|
|
1725 |
{7.1573082528381871e-01, -5.1581018476410262e-17, -1.3736271349300259e-34, -1.2734611344111297e-50},
|
|
1726 |
{7.1358486878079364e-01, -4.2342504403133584e-17, -4.2690366101617268e-34, -2.6352370883066522e-50},
|
|
1727 |
{7.1143219574521643e-01, 7.9643298613856813e-18, 2.9488239510721469e-34, 1.6985236437666356e-50},
|
|
1728 |
{7.0927282643886569e-01, -3.7597359110245730e-17, 1.0613125954645119e-34, 8.9465480185486032e-51},
|
|
1729 |
{7.0710678118654757e-01, -4.8336466567264567e-17, 2.0693376543497068e-33, 2.4677734957341755e-50}
|
|
1730 |
};
|
|
1731 |
|
|
1732 |
static INLINE void
|
|
1733 |
cos_table_qd(double *c0, double *c1, double *c2, double *c3, double j)
|
|
1734 |
{
|
|
1735 |
int int_j=(int)j;
|
|
1736 |
c0[0]=c_table[int_j-1][0];
|
|
1737 |
c1[0]=c_table[int_j-1][1];
|
|
1738 |
c2[0]=c_table[int_j-1][2];
|
|
1739 |
c3[0]=c_table[int_j-1][3];
|
|
1740 |
return;
|
|
1741 |
}
|
|
1742 |
|
|
1743 |
static double inv_fact[15][4] = {
|
|
1744 |
{1.66666666666666657e-01, 9.25185853854297066e-18, 5.13581318503262866e-34, 2.85094902409834186e-50},
|
|
1745 |
{4.16666666666666644e-02, 2.31296463463574266e-18, 1.28395329625815716e-34, 7.12737256024585466e-51},
|
|
1746 |
{8.33333333333333322e-03, 1.15648231731787138e-19, 1.60494162032269652e-36, 2.22730392507682967e-53},
|
|
1747 |
{1.38888888888888894e-03, -5.30054395437357706e-20, -1.73868675534958776e-36, -1.63335621172300840e-52},
|
|
1748 |
{1.98412698412698413e-04, 1.72095582934207053e-22, 1.49269123913941271e-40, 1.29470326746002471e-58},
|
|
1749 |
{2.48015873015873016e-05, 2.15119478667758816e-23, 1.86586404892426588e-41, 1.61837908432503088e-59},
|
|
1750 |
{2.75573192239858925e-06, -1.85839327404647208e-22, 8.49175460488199287e-39, -5.72661640789429621e-55},
|
|
1751 |
{2.75573192239858883e-07, 2.37677146222502973e-23, -3.26318890334088294e-40, 1.61435111860404415e-56},
|
|
1752 |
{2.50521083854417202e-08, -1.44881407093591197e-24, 2.04267351467144546e-41, -8.49632672007163175e-58},
|
|
1753 |
{2.08767569878681002e-09, -1.20734505911325997e-25, 1.70222792889287100e-42, 1.41609532150396700e-58},
|
|
1754 |
{1.60590438368216133e-10, 1.25852945887520981e-26, -5.31334602762985031e-43, 3.54021472597605528e-59},
|
|
1755 |
{1.14707455977297245e-11, 2.06555127528307454e-28, 6.88907923246664603e-45, 5.72920002655109095e-61},
|
|
1756 |
{7.64716373181981641e-13, 7.03872877733453001e-30, -7.82753927716258345e-48, 1.92138649443790242e-64},
|
|
1757 |
{4.77947733238738525e-14, 4.39920548583408126e-31, -4.89221204822661465e-49, 1.20086655902368901e-65},
|
|
1758 |
{2.81145725434552060e-15, 1.65088427308614326e-31, -2.87777179307447918e-50, 4.27110689256293549e-67}
|
|
1759 |
};
|
|
1760 |
|
|
1761 |
static void
|
5312
|
1762 |
sin_taylor_qd(double *s0, double *s1, double *s2, double *s3, double x0, double x1, double x2, double x3)
|
|
1763 |
{
|
5315
|
1764 |
double eps = 1.21543267145725e-63; // = 2^-209
|
|
1765 |
double thresh = 0.5*fabs(x0)*eps;
|
|
1766 |
double y0,y1,y2,y3,r0,r1,r2,r3,t0,t1,t2,t3;
|
|
1767 |
int i;
|
|
1768 |
|
|
1769 |
if(x0==0.0) {
|
|
1770 |
s0[0]=0.0; s1[0]=0.0; s2[0]=0.0; s3[0]=0.0;
|
|
1771 |
return;
|
|
1772 |
}
|
|
1773 |
|
|
1774 |
i=0;
|
|
1775 |
qd_mul_qd(&y0,&y1,&y2,&y3,x0,x1,x2,x3,x0,x1,x2,x3);
|
|
1776 |
y0 = -y0; y1 = -y1; y2 = -y2; y3 = -y3;
|
|
1777 |
s0[0]=x0; s1[0]=x1; s2[0]=x2; s3[0]=x3;
|
|
1778 |
r0=x0; r1=x1; r2=x2; r3=x3;
|
|
1779 |
|
|
1780 |
qd_mul_qd(&r0,&r1,&r2,&r3,r0,r1,r2,r3,y0,y1,y2,y3);
|
|
1781 |
qd_mul_qd(&t0,&t1,&t2,&t3,r0,r1,r2,r3,inv_fact[i][0],inv_fact[i][1],inv_fact[i][2],inv_fact[i][3]);
|
|
1782 |
qd_add_qd(&s0[0],&s1[0],&s2[0],&s3[0],s0[0],s1[0],s2[0],s3[0],t0,t1,t2,t3);
|
|
1783 |
i=i+2;
|
|
1784 |
while ((i<=15)||(fabs(t0)>thresh)) {
|
|
1785 |
qd_mul_qd(&r0,&r1,&r2,&r3,r0,r1,r2,r3,y0,y1,y2,y3);
|
|
1786 |
qd_mul_qd(&t0,&t1,&t2,&t3,r0,r1,r2,r3,inv_fact[i][0],inv_fact[i][1],inv_fact[i][2],inv_fact[i][3]);
|
|
1787 |
qd_add_qd(&s0[0],&s1[0],&s2[0],&s3[0],s0[0],s1[0],s2[0],s3[0],t0,t1,t2,t3);
|
|
1788 |
i=i+2;
|
|
1789 |
}
|
5312
|
1790 |
}
|
|
1791 |
|
|
1792 |
static void
|
5308
|
1793 |
cos_taylor_qd(double *c0, double *c1, double *c2, double *c3, double x0, double x1, double x2, double x3)
|
|
1794 |
{
|
|
1795 |
double eps = 1.21543267145725e-63; // = 2^-209
|
|
1796 |
double thresh = 0.5*eps;
|
|
1797 |
double y0,y1,y2,y3,r0,r1,r2,r3,t0,t1,t2,t3,p0,p1,p2,p3;
|
|
1798 |
int i;
|
|
1799 |
|
|
1800 |
if(x0==0.0) {
|
5315
|
1801 |
c0[0]=1.0; c1[0]=0.0; c2[0]=0.0; c3[0]=0.0;
|
|
1802 |
return;
|
5308
|
1803 |
}
|
|
1804 |
|
|
1805 |
i=1;
|
|
1806 |
qd_mul_qd(&y0,&y1,&y2,&y3,x0,x1,x2,x3,x0,x1,x2,x3);
|
|
1807 |
y0 = -y0; y1 = -y1; y2 = -y2; y3 = -y3;
|
|
1808 |
r0=y0; r1=y1; r2=y2; r3=y3;
|
|
1809 |
s_mul_qd(&p0,&p1,&p2,&p3,0.5,r0,r1,r2,r3);
|
|
1810 |
qd_add_s(&c0[0],&c1[0],&c2[0],&c3[0],p0,p1,p2,p3,1.0);
|
|
1811 |
|
|
1812 |
qd_mul_qd(&r0,&r1,&r2,&r3,r0,r1,r2,r3,y0,y1,y2,y3);
|
|
1813 |
qd_mul_qd(&t0,&t1,&t2,&t3,r0,r1,r2,r3,inv_fact[i][0],inv_fact[i][1],inv_fact[i][2],inv_fact[i][3]);
|
|
1814 |
qd_add_qd(&c0[0],&c1[0],&c2[0],&c3[0],c0[0],c1[0],c2[0],c3[0],t0,t1,t2,t3);
|
|
1815 |
i=i+2;
|
|
1816 |
|
|
1817 |
while((i<=15)||(fabs(t0)>thresh)) {
|
5315
|
1818 |
qd_mul_qd(&r0,&r1,&r2,&r3,r0,r1,r2,r3,y0,y1,y2,y3);
|
|
1819 |
qd_mul_qd(&t0,&t1,&t2,&t3,r0,r1,r2,r2,inv_fact[i][0],inv_fact[i][1],inv_fact[i][2],inv_fact[i][3]);
|
|
1820 |
qd_add_qd(&c0[0],&c1[0],&c2[0],&c3[0],c0[0],c1[0],c2[0],c3[0],t0,t1,t2,t3);
|
|
1821 |
i=i+2;
|
5308
|
1822 |
}
|
|
1823 |
}
|
|
1824 |
|
|
1825 |
static void
|
|
1826 |
sincos_taylor_qd(double *s0, double *s1, double *s2, double *s3, double *c0, double *c1, double *c2, double *c3, double x0, double x1, double x2, double x3)
|
|
1827 |
{
|
|
1828 |
double eps = 1.21543267145725e-63; // = 2^-209
|
|
1829 |
double thresh = 0.5 * fabs(x0)*eps;
|
|
1830 |
double y0,y1,y2,y3,r0,r1,r2,r3,t0,t1,t2,t3,p0,p1,p2,p3,q0,q1,q2,q3;
|
|
1831 |
int i;
|
|
1832 |
|
|
1833 |
if(x0==0.0) {
|
5315
|
1834 |
s0[0]=0.0; s1[0]=0.0; s2[0]=0.0; s3[0]=0.0;
|
|
1835 |
c0[0]=1.0; c1[0]=0.0; c2[0]=0.0; c3[0]=0.0;
|
|
1836 |
return;
|
5308
|
1837 |
}
|
|
1838 |
|
|
1839 |
i=0;
|
|
1840 |
qd_mul_qd(&y0,&y1,&y2,&y3,x0,x1,x2,x3,x0,x1,x2,x3);
|
|
1841 |
y0 = -y0; y1 = -y1; y2 = -y2; y3 = -y3;
|
|
1842 |
s0[0]=x0; s1[0]=x1; s2[0]=x2; s3[0]=x3;
|
|
1843 |
r0=x0; r1=x1; r2=x2; r3=x3;
|
|
1844 |
|
|
1845 |
qd_mul_qd(&r0,&r1,&r2,&r3,r0,r1,r2,r3,y0,y1,y2,y3);
|
|
1846 |
qd_mul_qd(&t0,&t1,&t2,&t3,r0,r1,r2,r3,inv_fact[i][0],inv_fact[i][1],inv_fact[i][2],inv_fact[i][3]);
|
|
1847 |
qd_add_qd(&s0[0],&s1[0],&s2[0],&s3[0],s0[0],s1[0],s2[0],s3[0],t0,t1,t2,t3);
|
|
1848 |
i=i+2;
|
|
1849 |
while ((i<=15)||((int)fabs(t0)>thresh)) {
|
5315
|
1850 |
qd_mul_qd(&r0,&r1,&r2,&r3,r0,r1,r2,r3,y0,y1,y2,y3);
|
|
1851 |
qd_mul_qd(&t0,&t1,&t2,&t3,r0,r1,r2,r3,inv_fact[i][0],inv_fact[i][1],inv_fact[i][2],inv_fact[i][3]);
|
|
1852 |
qd_add_qd(&s0[0],&s1[0],&s2[0],&s3[0],s0[0],s1[0],s2[0],s3[0],t0,t1,t2,t3);
|
|
1853 |
i=i+2;
|
5308
|
1854 |
}
|
|
1855 |
qd_mul_qd(&p0,&p1,&p2,&p3,s0[0],s1[0],s2[0],s3[0],s0[0],s1[0],s2[0],s3[0]); // Modified,2012/01/16 Saito
|
|
1856 |
s_sub_qd(&q0,&q1,&q2,&q3,1.0,p0,p1,p2,p3);
|
5312
|
1857 |
qd_sqrt(&c0[0],&c1[0],&c2[0],&c3[0],q0,q1,q2,q3);
|
5308
|
1858 |
}
|
|
1859 |
|
|
1860 |
//--------------------------------------------------------------------------------------------
|
|
1861 |
//
|
|
1862 |
// quad-double sine
|
|
1863 |
//
|
|
1864 |
// args
|
|
1865 |
// a0, a1, a2, a3 : double numbers
|
|
1866 |
// a0 + a1 + a2 + a3 = qd number
|
|
1867 |
//
|
|
1868 |
// return (s0,s1,s2,s3) for qd number
|
|
1869 |
//
|
|
1870 |
//--------------------------------------------------------------------------------------------
|
|
1871 |
static void
|
5312
|
1872 |
qd_sin(double *s0, double *s1, double *s2, double *s3, double *a0, double *a1, double *a2, double *a3)
|
5308
|
1873 |
{
|
|
1874 |
double p0,p1,p2,p3, q0,q1,q2,q3, z0,z1,z2,z3, r0,r1,r2,r3, j, t0,t1,t2,t3, k,abs_k;
|
|
1875 |
double _2pi[4] = {6.283185307179586232e+00,2.449293598294706414e-16,-5.989539619436679332e-33,2.224908441726730563e-49}; // 2*pi
|
|
1876 |
double _pi2[4] = {1.570796326794896558e+00,6.123233995736766036e-17,-1.497384904859169833e-33,5.562271104316826408e-50}; // pi/2
|
|
1877 |
double _pi1024[4] = {3.067961575771282340e-03,1.195944139792337116e-19,-2.924579892303066080e-36,1.086381075061880158e-52};
|
|
1878 |
double u0,u1,u2,u3,v0,v1,v2,v3;
|
|
1879 |
double sin0,sin1,sin2,sin3,cos0,cos1,cos2,cos3;
|
|
1880 |
int int_j;
|
|
1881 |
|
|
1882 |
if(a0[0]==0) {
|
5315
|
1883 |
s0[0]=0.0; s1[0]=0.0; s2[0]=0.0; s3[0]=0.0;
|
|
1884 |
return;
|
5308
|
1885 |
}
|
|
1886 |
|
|
1887 |
//approximately reduce modulo 2*pi
|
|
1888 |
qd_div_qd(&p0,&p1,&p2,&p3,a0[0],a1[0],a2[0],a3[0],_2pi[0],_2pi[1],_2pi[2],_2pi[3]);
|
|
1889 |
nint_qd(&z0,&z1,&z2,&z3,p0,p1,p2,p3);
|
|
1890 |
qd_mul_qd(&q0,&q1,&q2,&q3,_2pi[0],_2pi[1],_2pi[2],_2pi[3],z0,z1,z2,z3);
|
|
1891 |
qd_sub_qd(&r0,&r1,&r2,&r3,a0[0],a1[0],a2[0],a3[0],q0,q1,q2,q3);
|
|
1892 |
|
|
1893 |
//approximately reduce modulo pi/2 and then modulo pi/1024
|
|
1894 |
j=floor(r0/_pi2[0]+0.5);
|
|
1895 |
s_mul_qd(&p0, &p1, &p2, &p3, j, _pi2[0], _pi2[1], _pi2[2], _pi2[3]); // Modified,2012/01/16 Saito
|
|
1896 |
qd_sub_qd(&t0,&t1,&t2,&t3,r0,r1,r2,r3,p0,p1,p2,p3);
|
|
1897 |
k=floor(t0/_pi1024[0]+0.5);
|
|
1898 |
s_mul_qd(&q0, &q1, &q2, &q3, k, _pi1024[0], _pi1024[1], _pi1024[2], _pi1024[3]); // Modified,2012/01/16 Saito
|
|
1899 |
qd_sub_qd(&t0,&t1,&t2,&t3,t0,t1,t2,t3,q0,q1,q2,q3);
|
|
1900 |
abs_k=(int)fabs(k);
|
|
1901 |
int_j=(int)j;
|
|
1902 |
|
|
1903 |
//checking errors
|
|
1904 |
if(j<-2 || j>2) {
|
5315
|
1905 |
s0[0]=0.0; s1[0]=0.0; s2[0]=0.0; s3[0]=1.0;
|
|
1906 |
return;
|
5308
|
1907 |
}
|
|
1908 |
|
|
1909 |
if(abs_k >256) {
|
5315
|
1910 |
s0[0]=0.0; s1[0]=0.0; s2[0]=0.0; s3[0]=1.0;
|
|
1911 |
return;
|
5308
|
1912 |
}
|
|
1913 |
|
|
1914 |
if(k==0) {
|
5315
|
1915 |
switch(int_j) {
|
|
1916 |
case 0:
|
|
1917 |
sin_taylor_qd(&s0[0],&s1[0],&s2[0],&s3[0],t0,t1,t2,t3);
|
|
1918 |
return;
|
|
1919 |
case 1:
|
|
1920 |
cos_taylor_qd(&s0[0],&s1[0],&s2[0],&s3[0],t0,t1,t2,t3);
|
|
1921 |
return;
|
|
1922 |
case -1:
|
|
1923 |
cos_taylor_qd(&s0[0],&s1[0],&s2[0],&s3[0],t0,t1,t2,t3);
|
|
1924 |
s0[0]=-s0[0]; s1[0]=-s1[0]; s2[0]=-s2[0]; s3[0]=-s3[0];
|
|
1925 |
return;
|
|
1926 |
case 2:
|
|
1927 |
case -2:
|
|
1928 |
sin_taylor_qd(&s0[0],&s1[0],&s2[0],&s3[0],t0,t1,t2,t3);
|
|
1929 |
s0[0]=-s0[0]; s1[0]=-s1[0]; s2[0]=-s2[0]; s3[0]=-s3[0];
|
|
1930 |
return;
|
|
1931 |
}
|
5308
|
1932 |
}
|
|
1933 |
|
|
1934 |
cos_table_qd(&u0,&u1,&u2,&u3,abs_k);
|
|
1935 |
sin_table_qd(&v0,&v1,&v2,&v3,abs_k);
|
|
1936 |
sincos_taylor_qd(&sin0,&sin1,&sin2,&sin3,&cos0,&cos1,&cos2,&cos3,t0,t1,t2,t3);
|
|
1937 |
|
|
1938 |
if(j==0) {
|
5315
|
1939 |
if(k>0) {
|
|
1940 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,sin0,sin1,sin2,sin3);
|
|
1941 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,cos0,cos1,cos2,cos3);
|
|
1942 |
qd_add_qd(&s0[0],&s1[0],&s2[0],&s3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
1943 |
}
|
|
1944 |
else {
|
|
1945 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,sin0,sin1,sin2,sin3);
|
|
1946 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,cos0,cos1,cos2,cos3);
|
|
1947 |
qd_sub_qd(&s0[0],&s1[0],&s2[0],&s3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
1948 |
}
|
5308
|
1949 |
}
|
|
1950 |
else if(j==1) {
|
5315
|
1951 |
if(k>0) {
|
|
1952 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,cos0,cos1,cos2,cos3);
|
|
1953 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,sin0,sin1,sin2,sin3);
|
|
1954 |
qd_sub_qd(&s0[0],&s1[0],&s2[0],&s3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
1955 |
}
|
|
1956 |
else {
|
|
1957 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,cos0,cos1,cos2,cos3);
|
|
1958 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,sin0,sin1,sin2,sin3);
|
|
1959 |
qd_add_qd(&s0[0],&s1[0],&s2[0],&s3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
1960 |
}
|
5308
|
1961 |
}
|
|
1962 |
else if(j==-1) {
|
5315
|
1963 |
if(k>0) {
|
|
1964 |
qd_mul_qd(&p0,&p1,&p2,&p3,v0,v1,v2,v3,sin0,sin1,sin2,sin3);
|
|
1965 |
qd_mul_qd(&q0,&q1,&q2,&q3,u0,u1,u2,u3,cos0,cos1,cos2,cos3);
|
|
1966 |
qd_sub_qd(&s0[0],&s1[0],&s2[0],&s3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
1967 |
}
|
|
1968 |
else {
|
|
1969 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,cos0,cos1,cos2,cos3);
|
|
1970 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,sin0,sin1,sin2,sin3);
|
|
1971 |
p0=-p0; p1=-p1; p2=-p2; p3=-p3;
|
|
1972 |
qd_sub_qd(&s0[0],&s1[0],&s2[0],&s3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
1973 |
}
|
5308
|
1974 |
}
|
|
1975 |
else {
|
5315
|
1976 |
if(k>0) {
|
|
1977 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,sin0,sin1,sin2,sin3);
|
|
1978 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,cos0,cos1,cos2,cos3);
|
|
1979 |
p0=-p0; p1=-p1; p2=-p2; p3=-p3;
|
|
1980 |
qd_sub_qd(&s0[0],&s1[0],&s2[0],&s3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
1981 |
}
|
|
1982 |
else {
|
|
1983 |
qd_mul_qd(&p0,&p1,&p2,&p3,v0,v1,v2,v3,cos0,cos1,cos2,cos3);
|
|
1984 |
qd_mul_qd(&q0,&q1,&q2,&q3,u0,u1,u2,u3,sin0,sin1,sin2,sin3);
|
|
1985 |
qd_sub_qd(&s0[0],&s1[0],&s2[0],&s3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
1986 |
}
|
5308
|
1987 |
}
|
|
1988 |
}
|
|
1989 |
|
|
1990 |
|
|
1991 |
//--------------------------------------------------------------------------------------------
|
|
1992 |
//
|
|
1993 |
// quad-double cosine
|
|
1994 |
//
|
|
1995 |
// args
|
|
1996 |
// a0, a1, a2, a3 : double numbers
|
|
1997 |
// a0 + a1 + a2 + a3 = qd number
|
|
1998 |
//
|
|
1999 |
// return (c0,c1,c2,c3) for qd number
|
|
2000 |
//
|
|
2001 |
//--------------------------------------------------------------------------------------------
|
|
2002 |
static void
|
5312
|
2003 |
qd_cos(double *c0, double *c1, double *c2, double *c3, double *a0, double *a1, double *a2, double *a3)
|
5308
|
2004 |
{
|
|
2005 |
double p0,p1,p2,p3, q0,q1,q2,q3, z0,z1,z2,z3, r0,r1,r2,r3, j, t0,t1,t2,t3, k,abs_k;
|
|
2006 |
double _2pi[4] = {6.283185307179586232e+00,2.449293598294706414e-16,-5.989539619436679332e-33,2.224908441726730563e-49}; // 2*pi
|
|
2007 |
double _pi2[4] = {1.570796326794896558e+00,6.123233995736766036e-17,-1.497384904859169833e-33,5.562271104316826408e-50}; // pi/2
|
|
2008 |
double _pi1024[4] = {3.067961575771282340e-03,1.195944139792337116e-19,-2.924579892303066080e-36,1.086381075061880158e-52};
|
|
2009 |
double u0,u1,u2,u3,v0,v1,v2,v3;
|
|
2010 |
double sin0,sin1,sin2,sin3,cos0,cos1,cos2,cos3;
|
|
2011 |
int int_j;
|
|
2012 |
|
|
2013 |
if(a0[0]==0) {
|
5315
|
2014 |
c1[0]=1.0; c1[0]=0.0; c2[0]=0.0; c3[0]=0.0;
|
|
2015 |
return;
|
5308
|
2016 |
}
|
|
2017 |
|
|
2018 |
//approximately reduce modulo 2*pi
|
|
2019 |
qd_div_qd(&p0,&p1,&p2,&p3,a0[0],a1[0],a2[0],a3[0],_2pi[0],_2pi[1],_2pi[2],_2pi[3]);
|
|
2020 |
nint_qd(&z0,&z1,&z2,&z3,p0,p1,p2,p3);
|
|
2021 |
qd_mul_qd(&q0,&q1,&q2,&q3,_2pi[0],_2pi[1],_2pi[2],_2pi[3],z0,z1,z2,z3);
|
|
2022 |
qd_sub_qd(&r0,&r1,&r2,&r3,a0[0],a1[0],a2[0],a3[0],q0,q1,q2,q3);
|
|
2023 |
|
|
2024 |
//approximately reduce modulo pi/2 and then modulo pi/1024
|
|
2025 |
j=floor(r0/_pi2[0]+0.5);
|
|
2026 |
s_mul_qd(&p0, &p1, &p2, &p3, j, _pi2[0], _pi2[1], _pi2[2], _pi2[3]); // Modified,2012/01/16 Saito
|
|
2027 |
qd_sub_qd(&t0,&t1,&t2,&t3,r0,r1,r2,r3,p0,p1,p2,p3);
|
|
2028 |
k=floor(t0/_pi1024[0]+0.5);
|
|
2029 |
s_mul_qd(&q0, &q1, &q2, &q3, k, _pi1024[0], _pi1024[1], _pi1024[2], _pi1024[3]); // Modified,2012/01/16 Saito
|
|
2030 |
qd_sub_qd(&t0,&t1,&t2,&t3,t0,t1,t2,t3,q0,q1,q2,q3);
|
|
2031 |
abs_k=(int)fabs(k);
|
|
2032 |
int_j=(int)j;
|
|
2033 |
|
|
2034 |
//checking errors
|
|
2035 |
if(j<-2 || j>2) {
|
5315
|
2036 |
c0[0]=0.0; c1[0]=0.0; c2[0]=0.0; c3[0]=1.0;
|
|
2037 |
return;
|
5308
|
2038 |
}
|
|
2039 |
|
|
2040 |
if(abs_k >256) {
|
5315
|
2041 |
c0[0]=0.0; c1[0]=0.0; c2[0]=0.0; c3[0]=1.0;
|
|
2042 |
return;
|
5308
|
2043 |
}
|
|
2044 |
|
|
2045 |
if(k==0) {
|
5315
|
2046 |
switch(int_j) {
|
|
2047 |
case 0:
|
|
2048 |
cos_taylor_qd(&c0[0],&c1[0],&c2[0],&c3[0],t0,t1,t2,t3);
|
|
2049 |
return;
|
|
2050 |
case 1:
|
|
2051 |
sin_taylor_qd(&c0[0],&c1[0],&c2[0],&c3[0],t0,t1,t2,t3);
|
|
2052 |
c0[0]=-c0[0]; c1[0]=-c1[0]; c2[0]=-c2[0]; c3[0]=-c3[0];
|
|
2053 |
return;
|
|
2054 |
case -1:
|
|
2055 |
sin_taylor_qd(&c0[0],&c1[0],&c2[0],&c3[0],t0,t1,t2,t3);
|
|
2056 |
return;
|
|
2057 |
case 2:
|
|
2058 |
case -2:
|
|
2059 |
cos_taylor_qd(&c0[0],&c1[0],&c2[2],&c3[0],t0,t1,t2,t3);
|
|
2060 |
c0[0]=-c0[0]; c1[0]=-c1[0]; c2[0]=-c2[0]; c3[0]=-c3[0];
|
|
2061 |
return;
|
|
2062 |
}
|
5308
|
2063 |
}
|
|
2064 |
|
|
2065 |
cos_table_qd(&u0,&u1,&u2,&u3,abs_k);
|
|
2066 |
sin_table_qd(&v0,&v1,&v2,&v3,abs_k);
|
|
2067 |
sincos_taylor_qd(&sin0,&sin1,&sin2,&sin3,&cos0,&cos1,&cos2,&cos3,t0,t1,t2,t3);
|
|
2068 |
|
|
2069 |
if(j==0) {
|
5315
|
2070 |
if(k>0) {
|
|
2071 |
//u * cos_t - v * sin_t;
|
|
2072 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,cos0,cos1,cos2,cos3);
|
|
2073 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,sin0,sin1,sin2,sin3);
|
|
2074 |
qd_sub_qd(&c0[0],&c1[0],&c2[0],&c3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2075 |
}
|
|
2076 |
else {
|
|
2077 |
//u * cos_t + v * sin_t;
|
|
2078 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,cos0,cos1,cos2,cos3);
|
|
2079 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,sin0,sin1,sin2,sin3);
|
|
2080 |
qd_add_qd(&c0[0],&c1[0],&c2[0],&c3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2081 |
}
|
5308
|
2082 |
}
|
|
2083 |
else if(j==1) {
|
5315
|
2084 |
if(k>0) {
|
|
2085 |
//-u * sin_t - v * cos_t;
|
|
2086 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,sin0,sin1,sin2,sin3);
|
|
2087 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,cos0,cos1,cos2,cos3);
|
|
2088 |
p0=-p0; p1=-p1; p2=-p2; p3=-p3;
|
|
2089 |
qd_sub_qd(&c0[0],&c1[0],&c2[0],&c3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2090 |
}
|
|
2091 |
else {
|
|
2092 |
//v * cos_t - u * sin_t;
|
|
2093 |
qd_mul_qd(&p0,&p1,&p2,&p3,v0,v1,v2,v3,cos0,cos1,cos2,cos3);
|
|
2094 |
qd_mul_qd(&q0,&q1,&q2,&q3,u0,u1,u2,u3,sin0,sin1,sin2,sin3);
|
|
2095 |
qd_sub_qd(&c0[0],&c1[0],&c2[0],&c3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2096 |
}
|
5308
|
2097 |
}
|
|
2098 |
else if(j==-1) {
|
5315
|
2099 |
if(k>0) {
|
|
2100 |
//u * sin_t + v * cos_t;
|
|
2101 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,sin0,sin1,sin2,sin3);
|
|
2102 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,cos0,cos1,cos2,cos3);
|
|
2103 |
qd_add_qd(&c0[0],&c1[0],&c2[0],&c3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2104 |
}
|
|
2105 |
else {
|
|
2106 |
//u * sin_t - v * cos_t;
|
|
2107 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,sin0,sin1,sin2,sin3);
|
|
2108 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,cos0,cos1,cos2,cos3);
|
|
2109 |
qd_sub_qd(&c0[0],&c1[0],&c2[0],&c3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2110 |
}
|
5308
|
2111 |
}
|
|
2112 |
else {
|
5315
|
2113 |
if(k>0) {
|
|
2114 |
//v * sin_t - u * cos_t;
|
|
2115 |
qd_mul_qd(&p0,&p1,&p2,&p3,v0,v1,v2,v3,sin0,sin1,sin2,sin3);
|
|
2116 |
qd_mul_qd(&q0,&q1,&q2,&q3,u0,u1,u2,u3,cos0,cos1,cos2,cos3);
|
|
2117 |
qd_sub_qd(&c0[0],&c1[0],&c2[0],&c3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2118 |
}
|
|
2119 |
else {
|
|
2120 |
//-u * cos_t - v * sin_t;
|
|
2121 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,cos0,cos1,cos2,cos3);
|
|
2122 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,sin0,sin1,sin2,sin3);
|
|
2123 |
p0=-p0; p1=-p1; p2=-p2; p3=-p3;
|
|
2124 |
qd_sub_qd(&c0[0],&c1[0],&c2[0],&c3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2125 |
}
|
5308
|
2126 |
}
|
|
2127 |
return;
|
|
2128 |
}
|
|
2129 |
|
|
2130 |
//--------------------------------------------------------------------------------------------
|
|
2131 |
//
|
|
2132 |
// quad-double sine and cosine
|
|
2133 |
//
|
|
2134 |
//--------------------------------------------------------------------------------------------
|
|
2135 |
static INLINE void
|
|
2136 |
sincos_qd(double *s0, double *s1, double *s2, double *s3, double *c0, double *c1, double *c2, double *c3, double a0, double a1, double a2, double a3)
|
|
2137 |
{
|
|
2138 |
double p0,p1,p2,p3, q0,q1,q2,q3, z0,z1,z2,z3, r0,r1,r2,r3, j, t0,t1,t2,t3, k,abs_k;
|
|
2139 |
double _2pi[4] = {6.283185307179586232e+00,2.449293598294706414e-16,-5.989539619436679332e-33,2.224908441726730563e-49}; // 2*pi
|
|
2140 |
double _pi2[4] = {1.570796326794896558e+00,6.123233995736766036e-17,-1.497384904859169833e-33,5.562271104316826408e-50}; // pi/2
|
|
2141 |
double _pi1024[4] = {3.067961575771282340e-03,1.195944139792337116e-19,-2.924579892303066080e-36,1.086381075061880158e-52};
|
|
2142 |
double u0,u1,u2,u3,v0,v1,v2,v3;
|
|
2143 |
double sin0,sin1,sin2,sin3,cos0,cos1,cos2,cos3;
|
|
2144 |
int int_j;
|
|
2145 |
|
|
2146 |
if(a0==0.0) {
|
5315
|
2147 |
s0[0]=0.0; s1[0]=0.0; s2[0]=0.0; s3[0]=0.0;
|
|
2148 |
c0[0]=1.0; c1[0]=0.0; c2[0]=0.0; c3[0]=0.0;
|
|
2149 |
return;
|
5308
|
2150 |
}
|
|
2151 |
|
|
2152 |
//approximately reduce modulo 2*pi
|
|
2153 |
qd_div_qd(&p0,&p1,&p2,&p3,a0,a1,a2,a3,_2pi[0],_2pi[1],_2pi[2],_2pi[3]);
|
|
2154 |
nint_qd(&z0,&z1,&z2,&z3,p0,p1,p2,p3);
|
|
2155 |
qd_mul_qd(&q0,&q1,&q2,&q3,_2pi[0],_2pi[1],_2pi[2],_2pi[3],z0,z1,z2,z3);
|
|
2156 |
qd_sub_qd(&r0,&r1,&r2,&r3,a0,a1,a2,a3,q0,q1,q2,q3);
|
|
2157 |
|
|
2158 |
//approximately reduce modulo pi/2 and then modulo pi/1024
|
|
2159 |
j=floor(r0/_pi2[0]+0.5);
|
|
2160 |
s_mul_qd(&p0, &p1, &p2, &p3, j, _pi2[0], _pi2[1], _pi2[2], _pi2[3]); // Modified,2012/01/16 Saito
|
|
2161 |
qd_sub_qd(&t0,&t1,&t2,&t3,r0,r1,r2,r3,p0,p1,p2,p3);
|
|
2162 |
k=floor(t0/_pi1024[0]+0.5);
|
|
2163 |
s_mul_qd(&q0, &q1, &q2, &q3, k, _pi1024[0], _pi1024[1], _pi1024[2], _pi1024[3]); // Modified,2012/01/16 Saito
|
|
2164 |
qd_sub_qd(&t0,&t1,&t2,&t3,t0,t1,t2,t3,q0,q1,q2,q3);
|
|
2165 |
abs_k=(int)fabs(k);
|
|
2166 |
int_j=(int)j;
|
|
2167 |
|
|
2168 |
//checking errors
|
|
2169 |
if(j<-2 || j>2) {
|
5315
|
2170 |
s0[0]=0.0; s1[0]=0.0; s2[0]=0.0; s3[0]=1.0;
|
|
2171 |
c0[0]=0.0; c1[0]=0.0; c2[0]=0.0; c3[0]=1.0;
|
|
2172 |
return;
|
5308
|
2173 |
}
|
|
2174 |
|
|
2175 |
if(abs_k >256) {
|
5315
|
2176 |
s0[0]=0.0; s1[0]=0.0; s2[0]=0.0; s3[0]=1.0;
|
|
2177 |
c0[0]=0.0; c1[0]=0.0; c2[0]=0.0; c3[0]=1.0;
|
|
2178 |
return;
|
5308
|
2179 |
}
|
|
2180 |
|
|
2181 |
sincos_taylor_qd(&sin0,&sin1,&sin2,&sin3,&cos0,&cos1,&cos2,&cos3,t0,t1,t2,t3);
|
|
2182 |
|
|
2183 |
if(k==0) {
|
5315
|
2184 |
if(j==0) {
|
|
2185 |
s0[0]=sin0; s1[0]=sin1; s2[0]=sin2; s3[0]=sin3;
|
|
2186 |
c0[0]=cos0; c1[0]=cos1; c2[0]=cos2; c3[0]=cos3;
|
|
2187 |
return;
|
|
2188 |
}
|
|
2189 |
else if(j==1) {
|
|
2190 |
s0[0]=cos0; s1[0]=cos1; s2[0]=cos2; s3[0]=cos3;
|
|
2191 |
c0[0]=-sin0; c1[0]=-sin1; c2[0]=-sin2; c3[0]=-sin3;
|
|
2192 |
return;
|
|
2193 |
}
|
|
2194 |
else if(j==-1) {
|
|
2195 |
s0[0]=-cos0; s1[0]=-cos1; s2[0]=-cos2; s3[0]=-cos3;
|
|
2196 |
c0[0]=sin0; c1[0]=sin1; c2[0]=sin2; c3[0]=sin3;
|
|
2197 |
return;
|
|
2198 |
}
|
|
2199 |
else {
|
|
2200 |
s0[0]=-sin0; s1[0]=-sin1; s2[0]=-sin2; s3[0]=-sin3;
|
|
2201 |
c0[0]=-cos0; c1[0]=-cos1; c2[0]=-cos2; c3[0]=-cos3;
|
|
2202 |
return;
|
|
2203 |
}
|
5308
|
2204 |
}
|
|
2205 |
|
|
2206 |
cos_table_qd(&u0,&u1,&u2,&u3,abs_k);
|
|
2207 |
sin_table_qd(&v0,&v1,&v2,&v3,abs_k);
|
|
2208 |
|
|
2209 |
if(j==0) {
|
5315
|
2210 |
if(k>0) {
|
|
2211 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,sin0,sin1,sin2,sin3);
|
|
2212 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,cos0,cos1,cos2,cos3);
|
|
2213 |
qd_add_qd(&s0[0],&s1[0],&s2[0],&s3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2214 |
|
|
2215 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,cos0,cos1,cos2,cos3);
|
|
2216 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,sin0,sin1,sin2,sin3);
|
|
2217 |
qd_sub_qd(&c0[0],&c1[0],&c2[0],&c3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2218 |
}
|
|
2219 |
else {
|
|
2220 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,sin0,sin1,sin2,sin3);
|
|
2221 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,cos0,cos1,cos2,cos3);
|
|
2222 |
qd_sub_qd(&s0[0],&s1[0],&s2[0],&s3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2223 |
|
|
2224 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,cos0,cos1,cos2,cos3);
|
|
2225 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,sin0,sin1,sin2,sin3);
|
|
2226 |
qd_add_qd(&c0[0],&c1[0],&c2[0],&c3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2227 |
}
|
5308
|
2228 |
}
|
|
2229 |
else if(j==1) {
|
5315
|
2230 |
if(k>0) {
|
|
2231 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,cos0,cos1,cos2,cos3);
|
|
2232 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,sin0,sin1,sin2,sin3);
|
|
2233 |
qd_sub_qd(&s0[0],&s1[0],&s2[0],&s3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2234 |
|
|
2235 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,sin0,sin1,sin2,sin3);
|
|
2236 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,cos0,cos1,cos2,cos3);
|
|
2237 |
p0=-p0; p1=-p1; p2=-p2; p3=-p3;
|
|
2238 |
qd_sub_qd(&c0[0],&c1[0],&c2[0],&c3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2239 |
}
|
|
2240 |
else {
|
|
2241 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,cos0,cos1,cos2,cos3);
|
|
2242 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,sin0,sin1,sin2,sin3);
|
|
2243 |
qd_add_qd(&s0[0],&s1[0],&s2[0],&s3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2244 |
|
|
2245 |
qd_mul_qd(&p0,&p1,&p2,&p3,v0,v1,v2,v3,cos0,cos1,cos2,cos3);
|
|
2246 |
qd_mul_qd(&q0,&q1,&q2,&q3,u0,u1,u2,u3,sin0,sin1,sin2,sin3);
|
|
2247 |
qd_sub_qd(&c0[0],&c1[0],&c2[0],&c3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2248 |
}
|
5308
|
2249 |
}
|
|
2250 |
else if(j==-1) {
|
5315
|
2251 |
if(k>0) {
|
|
2252 |
qd_mul_qd(&p0,&p1,&p2,&p3,v0,v1,v2,v3,sin0,sin1,sin2,sin3);
|
|
2253 |
qd_mul_qd(&q0,&q1,&q2,&q3,u0,u1,u2,u3,cos0,cos1,cos2,cos3);
|
|
2254 |
qd_sub_qd(&s0[0],&s1[0],&s2[0],&s3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2255 |
|
|
2256 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,sin0,sin1,sin2,sin3);
|
|
2257 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,cos0,cos1,cos2,cos3);
|
|
2258 |
qd_add_qd(&c0[0],&c1[0],&c2[0],&c3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2259 |
}
|
|
2260 |
else {
|
|
2261 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,cos0,cos1,cos2,cos3);
|
|
2262 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,sin0,sin1,sin2,sin3);
|
|
2263 |
p0=-p0; p1=-p1; p2=-p2; p3=-p3;
|
|
2264 |
qd_sub_qd(&s0[0],&s1[0],&s2[0],&s3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2265 |
|
|
2266 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,sin0,sin1,sin2,sin3);
|
|
2267 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,cos0,cos1,cos2,cos3);
|
|
2268 |
qd_sub_qd(&c0[0],&c1[0],&c2[0],&c3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2269 |
}
|
5308
|
2270 |
}
|
|
2271 |
|
|
2272 |
else {
|
5315
|
2273 |
if(k>0) {
|
|
2274 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,sin0,sin1,sin2,sin3);
|
|
2275 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,cos0,cos1,cos2,cos3);
|
|
2276 |
p0=-p0; p1=-p1; p2=-p2; p3=-p3;
|
|
2277 |
qd_sub_qd(&s0[0],&s1[0],&s2[0],&s3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2278 |
|
|
2279 |
qd_mul_qd(&p0,&p1,&p2,&p3,v0,v1,v2,v3,sin0,sin1,sin2,sin3);
|
|
2280 |
qd_mul_qd(&q0,&q1,&q2,&q3,u0,u1,u2,u3,cos0,cos1,cos2,cos3);
|
|
2281 |
qd_sub_qd(&c0[0],&c1[0],&c2[0],&c3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2282 |
}
|
|
2283 |
else {
|
|
2284 |
qd_mul_qd(&p0,&p1,&p2,&p3,v0,v1,v2,v3,cos0,cos1,cos2,cos3);
|
|
2285 |
qd_mul_qd(&q0,&q1,&q2,&q3,u0,u1,u2,u3,sin0,sin1,sin2,sin3);
|
|
2286 |
qd_sub_qd(&s0[0],&s1[0],&s2[0],&s3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2287 |
|
|
2288 |
qd_mul_qd(&p0,&p1,&p2,&p3,u0,u1,u2,u3,cos0,cos1,cos2,cos3);
|
|
2289 |
qd_mul_qd(&q0,&q1,&q2,&q3,v0,v1,v2,v3,sin0,sin1,sin2,sin3);
|
|
2290 |
p0=-p0; p1=-p1; p2=-p2; p3=-p3;
|
|
2291 |
qd_sub_qd(&c0[0],&c1[0],&c2[0],&c3[0],p0,p1,p2,p3,q0,q1,q2,q3);
|
|
2292 |
}
|
5308
|
2293 |
}
|
|
2294 |
}
|
|
2295 |
|
|
2296 |
//--------------------------------------------------------------------------------------------
|
|
2297 |
//
|
|
2298 |
// quad-double tangent
|
|
2299 |
//
|
|
2300 |
// args
|
|
2301 |
// a0, a1, a2, a3 : double numbers
|
|
2302 |
// a0 + a1 + a2 + a3 = qd number
|
|
2303 |
//
|
|
2304 |
// return (t0,t1,t2,t3) for qd number
|
|
2305 |
//
|
|
2306 |
//--------------------------------------------------------------------------------------------
|
|
2307 |
static void
|
5312
|
2308 |
qd_tan(double *t0, double *t1, double *t2, double *t3, double *a0, double *a1, double *a2, double *a3)
|
5308
|
2309 |
{
|
|
2310 |
double sin0,sin1,sin2,sin3,cos0,cos1,cos2,cos3;
|
|
2311 |
sincos_qd(&sin0,&sin1,&sin2,&sin3,&cos0,&cos1,&cos2,&cos3,a0[0],a1[0],a2[0],a3[0]);
|
|
2312 |
qd_div_qd(&t0[0],&t1[0],&t2[0],&t3[0],sin0,sin1,sin2,sin3,cos0,cos1,cos2,cos3);
|
|
2313 |
}
|
|
2314 |
|
|
2315 |
//--------------------------------------------------------------------------------------------
|
|
2316 |
//
|
|
2317 |
// quad-double exponent
|
|
2318 |
//
|
|
2319 |
// args
|
|
2320 |
// x0, x1, x2, x3 : double numbers
|
|
2321 |
// x0 + x1 + x2 + x3 = qd number
|
|
2322 |
//
|
|
2323 |
// return (e0, e1, e2, e3) for qd number
|
|
2324 |
//
|
|
2325 |
//--------------------------------------------------------------------------------------------
|
|
2326 |
static void
|
5315
|
2327 |
qd_exp(double *e0, double *e1, double *e2, double *e3, double x0, double x1, double x2, double x3) {
|
5308
|
2328 |
|
|
2329 |
double k = ldexp(1.0,16);
|
|
2330 |
double inv_k = 1.0 / k;
|
5315
|
2331 |
double log_2[4] = { 6.931471805599452862e-01, 2.319046813846299558e-17, 5.707708438416212066e-34, -3.582432210601811423e-50 };
|
5308
|
2332 |
double m, p0,p1,p2,p3, q0,q1,q2,q3, r0,r1,r2,r3, s0,s1,s2,s3, t0,t1,t2,t3, v0,v1,v2,v3;
|
|
2333 |
int i;
|
|
2334 |
double t=1.0;
|
|
2335 |
double eps = 1.21543267145725e-63; // = 2^-209
|
|
2336 |
double thresh = inv_k * eps;
|
|
2337 |
|
5315
|
2338 |
if((x0==0.0) && (x1==0.0) && (x2==0.0) && (x3==0.0)) {
|
|
2339 |
e0[0] = 1.0;
|
|
2340 |
e1[0] = 0.0;
|
|
2341 |
e2[0] = 0.0;
|
|
2342 |
e3[0] = 0.0;
|
|
2343 |
return;
|
5308
|
2344 |
}
|
|
2345 |
|
5315
|
2346 |
if((x0==1.0) && (x1==0.0) && (x2==0.0) && (x3==0.0)) {
|
|
2347 |
e0[0] = 2.7182818284590451;
|
|
2348 |
e1[0] = 1.4456468917292502e-16;
|
|
2349 |
e2[0] = -2.127717108038176765e-33;
|
|
2350 |
e3[0] = 1.515630159841218954e-49;
|
|
2351 |
return;
|
5308
|
2352 |
}
|
|
2353 |
|
5315
|
2354 |
if(x0 <= -709) { // underflow return zero
|
|
2355 |
e0[0] = 0.0;
|
|
2356 |
e1[0] = 0.0;
|
|
2357 |
e2[0] = 0.0;
|
|
2358 |
e3[0] = 0.0;
|
|
2359 |
return;
|
5308
|
2360 |
}
|
|
2361 |
|
5315
|
2362 |
if(x0 >= 709) { // overflow return INF
|
|
2363 |
e0[0] = 0.0;
|
|
2364 |
e1[0] = 1.0;
|
|
2365 |
e2[0] = 2.0;
|
|
2366 |
e3[0] = 3.0;
|
|
2367 |
return;
|
5308
|
2368 |
}
|
|
2369 |
|
5315
|
2370 |
m = floor(x0 / log_2[0] + 0.5);
|
|
2371 |
|
|
2372 |
s_mul_qd(&p0, &p1, &p2, &p3, m, log_2[0], log_2[1], log_2[2], log_2[3]); // p := m * log2
|
|
2373 |
qd_sub_qd(&q0, &q1, &q2, &q3, x0, x1, x2, x3, p0, p1, p2, p3); // q := x - p;
|
|
2374 |
r0 = q0 * inv_k; // r := q / k;
|
|
2375 |
r1 = q1 * inv_k; // same as mul_pwr2
|
5308
|
2376 |
r2 = q2 * inv_k;
|
|
2377 |
r3 = q3 * inv_k;
|
|
2378 |
|
|
2379 |
qd_sqr(&p0, &p1, &p2, &p3, r0, r1, r2, r3);
|
|
2380 |
qd_add_qd(&s0, &s1, &s2, &s3, r0, r1, r2, r3, 0.5*p0, 0.5*p1, 0.5*p2, 0.5*p3);
|
|
2381 |
i = 0;
|
|
2382 |
do {
|
5315
|
2383 |
qd_mul_qd(&p0, &p1, &p2, &p3, p0, p1, p2, p3, r0, r1, r2, r3);
|
|
2384 |
qd_mul_qd(&t0, &t1, &t2, &t3, p0, p1, p2, p3, inv_fact[i][0], inv_fact[i][1], inv_fact[i][2], inv_fact[i][3]);
|
|
2385 |
i = i+1;
|
|
2386 |
qd_add_qd(&s0, &s1, &s2, &s3, s0, s1, s2, s3, t0, t1, t2, t3);
|
|
2387 |
} while ((i < 9 /* <=17 */) && (fabs(t0)>thresh));
|
|
2388 |
|
|
2389 |
// s := s*2 + s^2
|
5308
|
2390 |
qd_sqr(&v0, &v1, &v2, &v3, s0, s1, s2, s3);
|
|
2391 |
qd_add_qd(&s0, &s1, &s2, &s3, 2.0*s0, 2.0*s1, 2.0*s2, 2.0*s3, v0, v1, v2, v3); //1
|
|
2392 |
qd_sqr(&v0, &v1, &v2, &v3, s0, s1, s2, s3);
|
|
2393 |
qd_add_qd(&s0, &s1, &s2, &s3, 2.0*s0, 2.0*s1, 2.0*s2, 2.0*s3, v0, v1, v2, v3); //2
|
|
2394 |
qd_sqr(&v0, &v1, &v2, &v3, s0, s1, s2, s3);
|
|
2395 |
qd_add_qd(&s0, &s1, &s2, &s3, 2.0*s0, 2.0*s1, 2.0*s2, 2.0*s3, v0, v1, v2, v3); //3
|
|
2396 |
qd_sqr(&v0, &v1, &v2, &v3, s0, s1, s2, s3);
|
|
2397 |
qd_add_qd(&s0, &s1, &s2, &s3, 2.0*s0, 2.0*s1, 2.0*s2, 2.0*s3, v0, v1, v2, v3); //4
|
|
2398 |
qd_sqr(&v0, &v1, &v2, &v3, s0, s1, s2, s3);
|
|
2399 |
qd_add_qd(&s0, &s1, &s2, &s3, 2.0*s0, 2.0*s1, 2.0*s2, 2.0*s3, v0, v1, v2, v3); //5
|
|
2400 |
qd_sqr(&v0, &v1, &v2, &v3, s0, s1, s2, s3);
|
|
2401 |
qd_add_qd(&s0, &s1, &s2, &s3, 2.0*s0, 2.0*s1, 2.0*s2, 2.0*s3, v0, v1, v2, v3); //6
|
|
2402 |
qd_sqr(&v0, &v1, &v2, &v3, s0, s1, s2, s3);
|
|
2403 |
qd_add_qd(&s0, &s1, &s2, &s3, 2.0*s0, 2.0*s1, 2.0*s2, 2.0*s3, v0, v1, v2, v3); //7
|
|
2404 |
qd_sqr(&v0, &v1, &v2, &v3, s0, s1, s2, s3);
|
|
2405 |
qd_add_qd(&s0, &s1, &s2, &s3, 2.0*s0, 2.0*s1, 2.0*s2, 2.0*s3, v0, v1, v2, v3); //8
|
|
2406 |
qd_sqr(&v0, &v1, &v2, &v3, s0, s1, s2, s3);
|
|
2407 |
qd_add_qd(&s0, &s1, &s2, &s3, 2.0*s0, 2.0*s1, 2.0*s2, 2.0*s3, v0, v1, v2, v3); //9
|
|
2408 |
qd_sqr(&v0, &v1, &v2, &v3, s0, s1, s2, s3);
|
|
2409 |
qd_add_qd(&s0, &s1, &s2, &s3, 2.0*s0, 2.0*s1, 2.0*s2, 2.0*s3, v0, v1, v2, v3); //10
|
|
2410 |
qd_sqr(&v0, &v1, &v2, &v3, s0, s1, s2, s3);
|
|
2411 |
qd_add_qd(&s0, &s1, &s2, &s3, 2.0*s0, 2.0*s1, 2.0*s2, 2.0*s3, v0, v1, v2, v3); //11
|
|
2412 |
qd_sqr(&v0, &v1, &v2, &v3, s0, s1, s2, s3);
|
|
2413 |
qd_add_qd(&s0, &s1, &s2, &s3, 2.0*s0, 2.0*s1, 2.0*s2, 2.0*s3, v0, v1, v2, v3); //12
|
|
2414 |
qd_sqr(&v0, &v1, &v2, &v3, s0, s1, s2, s3);
|
|
2415 |
qd_add_qd(&s0, &s1, &s2, &s3, 2.0*s0, 2.0*s1, 2.0*s2, 2.0*s3, v0, v1, v2, v3); //13
|
|
2416 |
qd_sqr(&v0, &v1, &v2, &v3, s0, s1, s2, s3);
|
|
2417 |
qd_add_qd(&s0, &s1, &s2, &s3, 2.0*s0, 2.0*s1, 2.0*s2, 2.0*s3, v0, v1, v2, v3); //14
|
|
2418 |
qd_sqr(&v0, &v1, &v2, &v3, s0, s1, s2, s3);
|
|
2419 |
qd_add_qd(&s0, &s1, &s2, &s3, 2.0*s0, 2.0*s1, 2.0*s2, 2.0*s3, v0, v1, v2, v3); //15
|
|
2420 |
qd_sqr(&v0, &v1, &v2, &v3, s0, s1, s2, s3);
|
|
2421 |
qd_add_qd(&s0, &s1, &s2, &s3, 2.0*s0, 2.0*s1, 2.0*s2, 2.0*s3, v0, v1, v2, v3); //16
|
|
2422 |
qd_add_s(&s0, &s1, &s2, &s3, s0, s1, s2, s3, 1.0);
|
|
2423 |
|
5315
|
2424 |
// ldexp(s, m)
|
|
2425 |
// i.e. s *= 2^m
|
|
2426 |
t = ldexp(1.0, m);
|
|
2427 |
// t = 1.0
|
|
2428 |
// for (i=0; i<m; i++) {
|
|
2429 |
// t=t*2;
|
|
2430 |
// }
|
5308
|
2431 |
|
|
2432 |
e0[0] = s0*t; e1[0] = s1*t; e2[0] = s2*t; e3[0] = s3*t;
|
|
2433 |
}
|
|
2434 |
|
4413
|
2435 |
#if 0
|
|
2436 |
|
|
2437 |
/*********** Basic Functions ************/
|
|
2438 |
/* Computes fl(a+b) and err(a+b). Assumes |a| >= |b|. */
|
5308
|
2439 |
INLINE double
|
4413
|
2440 |
quick_two_sum(double a, double b, double *errPtr) {
|
|
2441 |
double s = a + b;
|
|
2442 |
*errPtr = b - (s - a);
|
|
2443 |
return s;
|
|
2444 |
}
|
|
2445 |
|
|
2446 |
/* Computes fl(a-b) and err(a-b). Assumes |a| >= |b| */
|
5308
|
2447 |
INLINE double
|
4413
|
2448 |
quick_two_diff(double a, double b, double *errPtr) {
|
|
2449 |
double s = a - b;
|
|
2450 |
*errPtr = (a - s) - b;
|
|
2451 |
return s;
|
|
2452 |
}
|
|
2453 |
|
|
2454 |
/* Computes fl(a+b) and err(a+b). */
|
5308
|
2455 |
INLINE double
|
4413
|
2456 |
two_sum(double a, double b, double *errPtr) {
|
|
2457 |
double s = a + b;
|
|
2458 |
double bb = s - a;
|
|
2459 |
*errPtr = (a - (s - bb)) + (b - bb);
|
|
2460 |
return s;
|
|
2461 |
}
|
|
2462 |
|
|
2463 |
/* Computes fl(a-b) and err(a-b). */
|
5308
|
2464 |
INLINE double
|
4413
|
2465 |
two_diff(double a, double b, double *errPtr) {
|
|
2466 |
double s = a - b;
|
|
2467 |
double bb = s - a;
|
|
2468 |
*errPtr = (a - (s - bb)) - (b + bb);
|
|
2469 |
return s;
|
|
2470 |
}
|
|
2471 |
|
|
2472 |
#ifndef QD_FMS
|
|
2473 |
/* Computes high word and lo word of a */
|
5308
|
2474 |
INLINE void
|
4413
|
2475 |
split(double a, double *hiPtr, double *loPtr) {
|
|
2476 |
double temp;
|
|
2477 |
if (a > _QD_SPLIT_THRESH || a < -_QD_SPLIT_THRESH) {
|
|
2478 |
a *= 3.7252902984619140625e-09; // 2^-28
|
|
2479 |
temp = _QD_SPLITTER * a;
|
|
2480 |
*hiPtr = temp - (temp - a);
|
|
2481 |
*loPtr = a - *hiPtr;
|
|
2482 |
*hiPtr *= 268435456.0; // 2^28
|
|
2483 |
*loPtr *= 268435456.0; // 2^28
|
|
2484 |
} else {
|
|
2485 |
temp = _QD_SPLITTER * a;
|
|
2486 |
*hiPtr = temp - (temp - a);
|
|
2487 |
*loPtr = a - *hiPtr;
|
|
2488 |
}
|
|
2489 |
}
|
|
2490 |
#endif
|
|
2491 |
|
|
2492 |
/* Computes fl(a*b) and err(a*b). */
|
5308
|
2493 |
INLINE double
|
4413
|
2494 |
two_prod(double a, double b, double *errPtr) {
|
|
2495 |
#ifdef QD_FMS
|
|
2496 |
double p = a * b;
|
|
2497 |
*errPtr = QD_FMS(a, b, p);
|
|
2498 |
return p;
|
|
2499 |
#else
|
|
2500 |
double a_hi, a_lo, b_hi, b_lo;
|
|
2501 |
double p = a * b;
|
|
2502 |
split(a, &a_hi, &a_lo);
|
|
2503 |
split(b, &b_hi, &b_lo);
|
|
2504 |
*errPtr = ((a_hi * b_hi - p) + a_hi * b_lo + a_lo * b_hi) + a_lo * b_lo;
|
|
2505 |
return p;
|
|
2506 |
#endif
|
|
2507 |
}
|
|
2508 |
|
|
2509 |
/* Computes fl(a*a) and err(a*a). Faster than the above method. */
|
5308
|
2510 |
INLINE double
|
4413
|
2511 |
two_sqr(double a, double *errPtr) {
|
|
2512 |
#ifdef QD_FMS
|
|
2513 |
double p = a * a;
|
|
2514 |
*errPtr = QD_FMS(a, a, p);
|
|
2515 |
return p;
|
|
2516 |
#else
|
|
2517 |
double hi, lo;
|
|
2518 |
double q = a * a;
|
|
2519 |
split(a, &hi, &lo);
|
|
2520 |
*errPtr = ((hi * hi - q) + 2.0 * hi * lo) + lo * lo;
|
|
2521 |
return q;
|
|
2522 |
#endif
|
|
2523 |
}
|
|
2524 |
|
|
2525 |
/* Computes the nearest integer to d. */
|
5308
|
2526 |
INLINE double
|
4413
|
2527 |
nint(double d) {
|
|
2528 |
if (d == floor(d))
|
|
2529 |
return d;
|
|
2530 |
return floor(d + 0.5);
|
|
2531 |
}
|
|
2532 |
|
|
2533 |
/* Computes the truncated integer. */
|
5308
|
2534 |
INLINE double
|
4413
|
2535 |
aint(double d) {
|
|
2536 |
return (d >= 0.0) ? floor(d) : ceil(d);
|
|
2537 |
}
|
|
2538 |
|
5308
|
2539 |
INLINE void
|
4413
|
2540 |
renorm4(double *c0Ptr, double *c1Ptr, double *c2Ptr, double *c3Ptr) {
|
|
2541 |
double s0, s1, s2 = 0.0, s3 = 0.0;
|
|
2542 |
double c0 = *c0Ptr;
|
|
2543 |
|
|
2544 |
if (isinf(c0)) return;
|
|
2545 |
|
|
2546 |
s0 = quick_two_sum(*c2Ptr, *c3Ptr, c3Ptr);
|
|
2547 |
s0 = quick_two_sum(*c1Ptr, s0, c2Ptr);
|
|
2548 |
c0 = quick_two_sum(c0, s0, c1Ptr);
|
|
2549 |
|
|
2550 |
s0 = c0;
|
|
2551 |
s1 = *c1Ptr;
|
|
2552 |
if (s1 != 0.0) {
|
|
2553 |
s1 = quick_two_sum(s1, *c2Ptr, &s2);
|
|
2554 |
if (s2 != 0.0)
|
|
2555 |
s2 = quick_two_sum(s2, *c3Ptr, &s3);
|
|
2556 |
else
|
|
2557 |
s1 = quick_two_sum(s1, *c3Ptr, &s2);
|
4380
|
2558 |
} else {
|
|
2559 |
s0 = quick_two_sum(s0, *c2Ptr, &s1);
|
4413
|
2560 |
if (s1 != 0.0)
|
|
2561 |
s1 = quick_two_sum(s1, *c3Ptr, &s2);
|
|
2562 |
else
|
|
2563 |
s0 = quick_two_sum(s0, *c3Ptr, &s1);
|
|
2564 |
}
|
|
2565 |
|
|
2566 |
*c0Ptr = s0;
|
|
2567 |
*c1Ptr = s1;
|
|
2568 |
*c2Ptr = s2;
|
|
2569 |
*c3Ptr = s3;
|
|
2570 |
}
|
|
2571 |
|
5308
|
2572 |
INLINE void
|
4413
|
2573 |
renorm5(double *c0Ptr, double *c1Ptr, double *c2Ptr, double *c3Ptr, double *c4Ptr) {
|
|
2574 |
double s0, s1, s2 = 0.0, s3 = 0.0;
|
|
2575 |
|
|
2576 |
if (isinf(*c0Ptr)) return;
|
|
2577 |
|
|
2578 |
s0 = quick_two_sum(*c3Ptr, *c4Ptr, c4Ptr);
|
|
2579 |
s0 = quick_two_sum(*c2Ptr, s0, c3Ptr);
|
|
2580 |
s0 = quick_two_sum(*c1Ptr, s0, c2Ptr);
|
|
2581 |
*c0Ptr = quick_two_sum(*c0Ptr, s0, c1Ptr);
|
|
2582 |
|
|
2583 |
s0 = *c0Ptr;
|
|
2584 |
s1 = *c1Ptr;
|
|
2585 |
|
|
2586 |
s0 = quick_two_sum(*c0Ptr, *c1Ptr, &s1);
|
|
2587 |
if (s1 != 0.0) {
|
|
2588 |
s1 = quick_two_sum(s1, *c2Ptr, &s2);
|
|
2589 |
if (s2 != 0.0) {
|
|
2590 |
s2 =quick_two_sum(s2, *c3Ptr, &s3);
|
|
2591 |
if (s3 != 0.0)
|
5315
|
2592 |
s3 += *c4Ptr;
|
4413
|
2593 |
else
|
5315
|
2594 |
s2 += *c4Ptr;
|
4413
|
2595 |
} else {
|
|
2596 |
s1 = quick_two_sum(s1, *c3Ptr, &s2);
|
|
2597 |
if (s2 != 0.0)
|
5315
|
2598 |
s2 = quick_two_sum(s2, *c4Ptr, &s3);
|
4413
|
2599 |
else
|
5315
|
2600 |
s1 = quick_two_sum(s1, *c4Ptr, &s2);
|
4413
|
2601 |
}
|
|
2602 |
} else {
|
|
2603 |
s0 = quick_two_sum(s0, *c2Ptr, &s1);
|
|
2604 |
if (s1 != 0.0) {
|
|
2605 |
s1 = quick_two_sum(s1, *c3Ptr, &s2);
|
|
2606 |
if (s2 != 0.0)
|
5315
|
2607 |
s2 = quick_two_sum(s2, *c4Ptr, &s3);
|
4413
|
2608 |
else
|
5315
|
2609 |
s1 = quick_two_sum(s1, *c4Ptr, &s2);
|
4413
|
2610 |
} else {
|
|
2611 |
s0 = quick_two_sum(s0, *c3Ptr, &s1);
|
|
2612 |
if (s1 != 0.0)
|
5315
|
2613 |
s1 = quick_two_sum(s1, *c4Ptr, &s2);
|
4413
|
2614 |
else
|
5315
|
2615 |
s0 = quick_two_sum(s0, *c4Ptr, &s1);
|
4413
|
2616 |
}
|
|
2617 |
}
|
|
2618 |
|
|
2619 |
*c0Ptr = s0;
|
|
2620 |
*c1Ptr = s1;
|
|
2621 |
*c2Ptr = s2;
|
|
2622 |
*c3Ptr = s3;
|
|
2623 |
}
|
|
2624 |
|
5308
|
2625 |
INLINE void
|
4413
|
2626 |
three_sum(double *aPtr, double *bPtr, double *cPtr) {
|
|
2627 |
double t1, t2, t3;
|
|
2628 |
t1 = two_sum(*aPtr, *bPtr, &t2);
|
|
2629 |
*aPtr = two_sum(*cPtr, t1, &t3);
|
|
2630 |
*bPtr = two_sum(t2, t3, cPtr);
|
|
2631 |
}
|
|
2632 |
|
5308
|
2633 |
INLINE void three_sum2(double *aPtr, double *bPtr, double *cPtr) {
|
4413
|
2634 |
double t1, t2, t3;
|
|
2635 |
t1 = two_sum(*aPtr, *bPtr, &t2);
|
|
2636 |
*aPtr = two_sum(*cPtr, t1, &t3);
|
|
2637 |
*bPtr = t2 + t3;
|
|
2638 |
}
|
|
2639 |
#endif
|
|
2640 |
|
|
2641 |
#if 0
|
|
2642 |
/* These are provided to give consistent
|
|
2643 |
interface for double with double-double and quad-double. */
|
5308
|
2644 |
INLINE void
|
4413
|
2645 |
sincosh(double t, double &sinh_t, double &cosh_t) {
|
|
2646 |
sinh_t = sinh(t);
|
|
2647 |
cosh_t = cosh(t);
|
|
2648 |
}
|
|
2649 |
|
5308
|
2650 |
INLINE double
|
4413
|
2651 |
sqr(double t) {
|
|
2652 |
return t * t;
|
|
2653 |
}
|
|
2654 |
|
5308
|
2655 |
INLINE double
|
4413
|
2656 |
to_double(double a) {
|
|
2657 |
return a;
|
|
2658 |
}
|
|
2659 |
|
5308
|
2660 |
INLINE int
|
4413
|
2661 |
to_int(double a) {
|
|
2662 |
return static_cast<int>(a);
|
|
2663 |
}
|
|
2664 |
#endif
|
|
2665 |
|
|
2666 |
%}
|
|
2667 |
! !
|
4380
|
2668 |
|
|
2669 |
!QDouble class methodsFor:'documentation'!
|
|
2670 |
|
|
2671 |
copyright
|
|
2672 |
"
|
|
2673 |
COPYRIGHT (c) 2017 by eXept Software AG
|
5315
|
2674 |
All Rights Reserved
|
4380
|
2675 |
|
|
2676 |
This software is furnished under a license and may be used
|
|
2677 |
only in accordance with the terms of that license and with the
|
|
2678 |
inclusion of the above copyright notice. This software may not
|
|
2679 |
be provided or otherwise made available to, or used by, any
|
|
2680 |
other person. No title to or ownership of the software is
|
|
2681 |
hereby transferred.
|
|
2682 |
"
|
|
2683 |
!
|
|
2684 |
|
|
2685 |
documentation
|
|
2686 |
"
|
4391
|
2687 |
ATTENTION: ongoing, unfinished work.
|
4450
|
2688 |
No warranty that this works correctly...
|
4391
|
2689 |
|
4380
|
2690 |
QDoubles represent rational numbers with extended, but still limited precision.
|
|
2691 |
|
4451
|
2692 |
In contrast to Floats (which use the C-compiler's native 64bit 'double' format),
|
4430
|
2693 |
QDoubles give you roughly 200 bit or approx. 60 decimal digits of precision.
|
4380
|
2694 |
|
|
2695 |
Representation:
|
5315
|
2696 |
QDoubles use 4 IEEE doubles, each keeping 53 bits of precision.
|
|
2697 |
A qDouble's value is the sum of those 4 doubles,
|
|
2698 |
and a qDouble keeps this unevaluated sum as its state.
|
|
2699 |
(due to overlap and rounding, the final precision is less than 53*4)
|
|
2700 |
The exponent range is still the double exponent range,
|
|
2701 |
but the number of mantissa bits is rougly multiplied by 4.
|
4380
|
2702 |
|
|
2703 |
Range and Precision of Storage Formats: see LimitedPrecisionReal >> documentation
|
5270
|
2704 |
The number of decmal digits:
|
5315
|
2705 |
QDouble decimalPrecision -> 61
|
|
2706 |
LongFloat decimalPrecision -> 19
|
|
2707 |
Float decimalPrecision -> 16
|
|
2708 |
ShortFloat decimalPrecision -> 7
|
5270
|
2709 |
|
|
2710 |
The number of bits:
|
5315
|
2711 |
QDouble precision -> 204
|
|
2712 |
LongFloat precision -> 64
|
|
2713 |
Float precision -> 53
|
|
2714 |
ShortFloat precision -> 24
|
4981
|
2715 |
|
|
2716 |
Notice:
|
5315
|
2717 |
when assigning a converted double precision number as in:
|
|
2718 |
qd := 1.0 asQDouble.
|
|
2719 |
you still get only a regular double precision approximation to 0.1
|
|
2720 |
because the error is already inherit in the double.
|
|
2721 |
|
|
2722 |
For a full precision constant, you (currently) need to convert from a string
|
|
2723 |
(because the compilers do not know about them, yet):
|
|
2724 |
qd := QDouble readFrom:'0.1'.
|
|
2725 |
|
|
2726 |
To see the error of the double precision version, compute:
|
|
2727 |
(0.1 asQDouble) - (QDouble readFrom:'0.1')
|
4981
|
2728 |
|
4380
|
2729 |
[author:]
|
5315
|
2730 |
Claus Gittinger
|
4380
|
2731 |
|
|
2732 |
[see also:]
|
5315
|
2733 |
Number
|
|
2734 |
Float ShortFloat LongFloat
|
|
2735 |
Fraction FixedPoint Integer Complex
|
|
2736 |
FloatArray DoubleArray
|
4380
|
2737 |
"
|
4454
|
2738 |
!
|
|
2739 |
|
|
2740 |
examples
|
|
2741 |
"
|
|
2742 |
Floats, LongFloats suffer from loosing bits:
|
4981
|
2743 |
|
4454
|
2744 |
(Float readFrom:'0.3333333333333333333333333333333333333333333333333333333333')
|
|
2745 |
-(Float readFrom:'0.333333333333333333333333333333333333333333333333333333333')
|
5315
|
2746 |
-> 0.0
|
4981
|
2747 |
|
4454
|
2748 |
(Float readFrom:'0.3333333333333333333333333333333333333333333333333333333333')
|
|
2749 |
= (Float readFrom:'0.333333333333333333333333333333333333333333333333333333333')
|
5315
|
2750 |
-> true
|
4454
|
2751 |
|
|
2752 |
(Float readFrom:'0.33333333333333333333333333333333333333333333333333333333333333333333')
|
|
2753 |
= (Float readFrom:'0.3333333333333333333333333333333333333333333333333333333333333333333')
|
5315
|
2754 |
-> true
|
4454
|
2755 |
1000 0110 1000 0101 1000 0101 1000 0101 1000 0101 1000 0101 1101 0101 0011 1111
|
|
2756 |
(Float readFrom:'0.3333333333333333333333333333333333333333333333333333333333')
|
|
2757 |
= (Float readFrom:'0.3333333333333333333333333333333333333333333333333333333333333333333')
|
|
2758 |
|
|
2759 |
(LongFloat readFrom:'0.3333333333333333333333333333333333333333333333333333333333')
|
|
2760 |
-(LongFloat readFrom:'0.333333333333333333333333333333333333333333333333333333333')
|
5315
|
2761 |
-> 0.0
|
4454
|
2762 |
|
|
2763 |
(LongFloat readFrom:'0.3333333333333333333333333333333333333333333333333333333333')
|
|
2764 |
= (LongFloat readFrom:'0.333333333333333333333333333333333333333333333333333333333')
|
5315
|
2765 |
-> 0.0
|
4454
|
2766 |
|
|
2767 |
(QDouble readFrom:'0.3333333333333333333333333333333333333333333333333333333333')
|
|
2768 |
-(QDouble readFrom:'0.333333333333333333333333333333333333333333333333333333333')
|
|
2769 |
|
|
2770 |
(QDouble readFrom:'0.33333333333333333333333333333333333333333333333333333333333')
|
|
2771 |
-(QDouble readFrom:'0.3333333333333333333333333333333333333333333333333333333333')
|
|
2772 |
|
|
2773 |
|
|
2774 |
(QDouble readFrom:'0.33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333')
|
|
2775 |
-(QDouble readFrom:'0.3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333')
|
|
2776 |
"
|
4380
|
2777 |
! !
|
|
2778 |
|
|
2779 |
!QDouble class methodsFor:'instance creation'!
|
|
2780 |
|
|
2781 |
basicNew
|
|
2782 |
"return a new quad-precision double - here we return 0.0
|
|
2783 |
Notice that numbers are usually NOT created this way ...
|
|
2784 |
It's implemented here to allow things like binary store & load
|
|
2785 |
of floats. (but even this support will go away eventually, it's not
|
|
2786 |
a good idea to store the bits of a float - the reader might have a
|
|
2787 |
totally different representation - so floats should be
|
|
2788 |
binary stored in a device independent format."
|
|
2789 |
|
|
2790 |
%{ /* NOCONTEXT */
|
|
2791 |
#ifdef __SCHTEAM__
|
5308
|
2792 |
ERROR("trying to instantiate a qDouble");
|
4380
|
2793 |
#else
|
5308
|
2794 |
OBJ newQD;
|
|
2795 |
|
|
2796 |
__qNew_qdReal(newQD, 0.0, 0.0, 0.0, 0.0);
|
|
2797 |
RETURN (newQD);
|
4380
|
2798 |
#endif /* not SCHTEAM */
|
|
2799 |
%}
|
|
2800 |
|
|
2801 |
"
|
|
2802 |
self basicNew
|
|
2803 |
"
|
|
2804 |
|
|
2805 |
"Created: / 12-06-2017 / 16:00:38 / cg"
|
|
2806 |
!
|
|
2807 |
|
|
2808 |
d0:d0 d1:d1 d2:d2 d3:d3
|
|
2809 |
"return a new quad-precision double from individual double components"
|
|
2810 |
|
|
2811 |
%{ /* NOCONTEXT */
|
|
2812 |
#ifdef __SCHTEAM__
|
5308
|
2813 |
ERROR("trying to instantiate a qDouble");
|
4380
|
2814 |
#else
|
|
2815 |
OBJ newQD;
|
|
2816 |
|
4395
|
2817 |
if (__isFloatLike(d0)
|
4380
|
2818 |
&& __isFloatLike(d1)
|
|
2819 |
&& __isFloatLike(d2)
|
4395
|
2820 |
&& __isFloatLike(d3)) {
|
5315
|
2821 |
__qNew_qdReal(newQD, __floatVal(d0), __floatVal(d1),
|
|
2822 |
__floatVal(d2), __floatVal(d3));
|
|
2823 |
RETURN (newQD);
|
4380
|
2824 |
}
|
|
2825 |
#endif
|
|
2826 |
%}.
|
|
2827 |
self error:'invalid argument'
|
|
2828 |
|
|
2829 |
"
|
|
2830 |
self d0: 3.141592653589793116e+00
|
5315
|
2831 |
d1: 1.224646799147353207e-16
|
|
2832 |
d2: -2.994769809718339666e-33
|
|
2833 |
d3: 1.112454220863365282e-49
|
4380
|
2834 |
"
|
|
2835 |
|
|
2836 |
"Created: / 12-06-2017 / 20:17:14 / cg"
|
|
2837 |
!
|
|
2838 |
|
|
2839 |
fromDoubleArray:aDoubleArray
|
|
2840 |
"return a new quad-precision double from coercing a double array"
|
|
2841 |
|
|
2842 |
%{ /* NOCONTEXT */
|
|
2843 |
#ifdef __SCHTEAM__
|
5308
|
2844 |
ERROR("trying to instantiate a qDouble");
|
4380
|
2845 |
#else
|
|
2846 |
OBJ newQD;
|
|
2847 |
|
4395
|
2848 |
if (__isDoubleArray(aDoubleArray)) {
|
5315
|
2849 |
double* __d__ = __DoubleArrayInstPtr(aDoubleArray)->d_element;
|
|
2850 |
__qNew_qdReal(newQD, __d__[0], __d__[1], __d__[2], __d__[3]);
|
|
2851 |
RETURN (newQD);
|
4380
|
2852 |
}
|
|
2853 |
#endif
|
|
2854 |
%}.
|
|
2855 |
self error:'invalid argument'
|
|
2856 |
|
|
2857 |
"
|
4395
|
2858 |
self fromDoubleArray(DoubleArray
|
5315
|
2859 |
with: 3.141592653589793116e+00
|
|
2860 |
with: 1.224646799147353207e-16
|
|
2861 |
with: -2.994769809718339666e-33
|
|
2862 |
with: 1.112454220863365282e-49)
|
4380
|
2863 |
"
|
|
2864 |
|
|
2865 |
"Created: / 12-06-2017 / 18:25:32 / cg"
|
|
2866 |
!
|
|
2867 |
|
|
2868 |
fromFloat:aFloat
|
|
2869 |
"return a new quad-precision double from coercing aFloat"
|
|
2870 |
|
|
2871 |
%{ /* NOCONTEXT */
|
|
2872 |
#ifdef __SCHTEAM__
|
5308
|
2873 |
ERROR("trying to instantiate a qDouble");
|
4380
|
2874 |
#else
|
|
2875 |
double dVal;
|
5308
|
2876 |
OBJ newQD;
|
4380
|
2877 |
|
|
2878 |
if (__isFloatLike(aFloat)) {
|
5315
|
2879 |
dVal = __floatVal(aFloat);
|
4395
|
2880 |
} else if (__isShortFloat(aFloat)) {
|
5315
|
2881 |
dVal = __shortFloatVal(aFloat);
|
4380
|
2882 |
} else {
|
5315
|
2883 |
goto badArg;
|
4395
|
2884 |
}
|
|
2885 |
|
5308
|
2886 |
__qNew_qdReal(newQD, dVal, 0.0, 0.0, 0.0);
|
|
2887 |
RETURN (newQD);
|
4380
|
2888 |
|
|
2889 |
badArg: ;
|
|
2890 |
|
|
2891 |
#endif
|
|
2892 |
%}.
|
5308
|
2893 |
self argumentError:'invalid (non-float) argument'
|
4380
|
2894 |
|
|
2895 |
"
|
|
2896 |
self fromFloat:1.0
|
|
2897 |
"
|
|
2898 |
|
|
2899 |
"Created: / 12-06-2017 / 16:06:54 / cg"
|
|
2900 |
!
|
|
2901 |
|
|
2902 |
fromInteger:anInteger
|
|
2903 |
"return a new quad-precision double from coercing anInteger"
|
|
2904 |
|
|
2905 |
%{ /* NOCONTEXT */
|
5308
|
2906 |
#ifdef __SCHTEAM__
|
|
2907 |
ERROR("trying to instantiate a qDouble");
|
|
2908 |
#else
|
|
2909 |
OBJ newQD;
|
4380
|
2910 |
|
|
2911 |
if (__isSmallInteger(anInteger)) {
|
5315
|
2912 |
INT iVal = __smallIntegerVal(anInteger);
|
|
2913 |
double *d;
|
|
2914 |
|
|
2915 |
__qNew(newQD, sizeof(struct __qDoubleStruct));
|
|
2916 |
__stx_setClass(newQD, QDouble);
|
|
2917 |
|
|
2918 |
d = __QDoubleInstPtr(newQD)->d_qDoubleValue;
|
|
2919 |
d[1] = 0.0;
|
|
2920 |
d[2] = 0.0;
|
|
2921 |
d[3] = 0.0;
|
|
2922 |
|
|
2923 |
// need more than 52bits?
|
|
2924 |
if ((sizeof(INT) > 52)
|
|
2925 |
&& ((iVal > 0xFFFFFFFFFFFFF) || (iVal < -0xFFFFFFFFFFFFF))) {
|
|
2926 |
d[0] = (double)(iVal & ~0xFFFFFFFF);
|
|
2927 |
d[1] = (double)(iVal & 0xFFFFFFFF);
|
|
2928 |
renorm(&(d[0]), &(d[1]), &(d[2]), &(d[3]), d[0], d[1], 0.0, 0.0, 0.0);
|
|
2929 |
// renorm4(&(a[0]), &(a[1]), &(a[2]), &(a[3]));
|
|
2930 |
} else {
|
|
2931 |
d[0] = (double)iVal;
|
|
2932 |
}
|
|
2933 |
RETURN (newQD);
|
4380
|
2934 |
}
|
|
2935 |
#endif
|
|
2936 |
%}.
|
|
2937 |
^ super fromInteger:anInteger
|
|
2938 |
|
|
2939 |
"
|
|
2940 |
self fromInteger:2
|
4454
|
2941 |
self fromInteger:16rFFFFFFFF -- 32bit 4294967295.0
|
|
2942 |
self fromInteger:16rFFFFFFFFFFFF -- 48bit 281474976710655.0
|
|
2943 |
self fromInteger:16rFFFFFFFFFFFFF -- 52bit 4503599627370495.0
|
|
2944 |
self fromInteger:16rFFFFFFFFFFFFFF -- 56bit 72057594037927935.0
|
|
2945 |
self fromInteger:16rFFFFFFFFFFFFFFF -- 60bit 1152921504606846975.0
|
|
2946 |
self fromInteger:16r1FFFFFFFFFFFFFFF -- 61bit 2305843009213693951.0
|
|
2947 |
self fromInteger:16r3FFFFFFFFFFFFFFF -- 62bit 4611686018427387903.0
|
|
2948 |
self fromInteger:16r7FFFFFFFFFFFFFFF -- 63bit 9223372036854775807.0
|
|
2949 |
self fromInteger:16rFFFFFFFFFFFFFFFF -- 64bit 18446744073709551615.0
|
4380
|
2950 |
"
|
|
2951 |
|
|
2952 |
"Created: / 12-06-2017 / 16:10:10 / cg"
|
4454
|
2953 |
"Modified: / 04-07-2017 / 12:51:52 / cg"
|
5315
|
2954 |
!
|
|
2955 |
|
|
2956 |
fromLongFloat:aFloat
|
|
2957 |
"return a new quad-precision double from coercing aFloat"
|
|
2958 |
|
|
2959 |
%{ /* NOCONTEXT */
|
|
2960 |
#ifdef __SCHTEAM__
|
|
2961 |
ERROR("trying to instantiate a qDouble");
|
|
2962 |
#else
|
|
2963 |
if (__isLongFloat(aFloat)) {
|
|
2964 |
LONGFLOAT_t lVal;
|
|
2965 |
double l0, l1, l2, l3;
|
|
2966 |
OBJ newQD;
|
|
2967 |
|
|
2968 |
lVal = __longFloatVal(aFloat);
|
|
2969 |
l0 = (double)lVal;
|
|
2970 |
lVal -= l0;
|
|
2971 |
l1 = (double)lVal;
|
|
2972 |
renorm(&l0, &l1, &l2, &l3, l0, l1, 0.0, 0.0, 0.0);
|
|
2973 |
__qNew_qdReal(newQD, l0, l1, l2, l3);
|
|
2974 |
RETURN (newQD);
|
|
2975 |
}
|
|
2976 |
badArg: ;
|
|
2977 |
|
|
2978 |
#endif
|
|
2979 |
%}.
|
|
2980 |
self argumentError:'invalid (non-float) argument'
|
|
2981 |
|
|
2982 |
"
|
|
2983 |
self fromLongFloat:1.0 asLongFloat
|
|
2984 |
1.0 asLongFloat asQDouble 1.
|
|
2985 |
|
|
2986 |
(1.0 + 1e-16) - 1.0 -> 0.0
|
|
2987 |
(1.0 asLongFloat + 1e-16) - 1.0 -> 9.996344030316350881E-17
|
|
2988 |
|
|
2989 |
(1.0 asLongFloat + 1e-16) asQDouble - 1.0
|
|
2990 |
-> 9.99634403031635016638603121124e-17
|
|
2991 |
"
|
4380
|
2992 |
! !
|
|
2993 |
|
4395
|
2994 |
!QDouble class methodsFor:'coercing & converting'!
|
|
2995 |
|
|
2996 |
coerce:aNumber
|
5326
|
2997 |
"convert the argument aNumber into an instance of the receiver (class) and return it."
|
4395
|
2998 |
|
|
2999 |
^ aNumber asQDouble
|
|
3000 |
|
|
3001 |
"Created: / 12-06-2017 / 17:13:47 / cg"
|
|
3002 |
"Modified: / 12-06-2017 / 21:09:06 / cg"
|
|
3003 |
! !
|
|
3004 |
|
4380
|
3005 |
!QDouble class methodsFor:'constants'!
|
|
3006 |
|
4440
|
3007 |
NaN
|
|
3008 |
"return a QDouble which represents not-a-Number (i.e. an invalid number)"
|
|
3009 |
|
|
3010 |
NaN isNil ifTrue:[
|
5315
|
3011 |
NaN := self d0:(Float NaN) d1:(Float NaN) d2:(Float NaN) d3:(Float NaN)
|
4440
|
3012 |
].
|
|
3013 |
^ NaN
|
|
3014 |
|
|
3015 |
"Created: / 21-06-2017 / 20:44:57 / cg"
|
|
3016 |
!
|
|
3017 |
|
4380
|
3018 |
e
|
|
3019 |
"return the constant e as quad precision double.
|
4433
|
3020 |
(returns approx. 200 bits of precision)"
|
4380
|
3021 |
|
|
3022 |
E isNil ifTrue:[
|
5315
|
3023 |
E := self d0: 2.718281828459045091e+00
|
|
3024 |
d1: 1.445646891729250158e-16
|
|
3025 |
d2: -2.127717108038176765e-33
|
|
3026 |
d3: 1.515630159841218954e-49
|
4388
|
3027 |
].
|
4380
|
3028 |
^ E
|
|
3029 |
|
|
3030 |
"
|
5308
|
3031 |
self e printfPrintString:'%.61f'
|
5304
|
3032 |
-> '2.7182818284590452353602874713526624977572470936999595749669676'
|
5288
|
3033 |
Wolfram says:
|
5315
|
3034 |
2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516642742746
|
4380
|
3035 |
"
|
|
3036 |
|
|
3037 |
"Created: / 12-06-2017 / 18:29:36 / cg"
|
|
3038 |
!
|
|
3039 |
|
4392
|
3040 |
fmax
|
|
3041 |
"return the constant e as quad precision double.
|
4433
|
3042 |
(returns approx. 200 bits of precision)"
|
4392
|
3043 |
|
|
3044 |
FMax isNil ifTrue:[
|
5315
|
3045 |
FMax := self d0: 1.797693134862314E+308
|
|
3046 |
d1: 9.97920154767359795037e+291
|
|
3047 |
d2: 5.53956966280111259858e+275
|
|
3048 |
d3: 3.07507889307840487279e+259
|
4392
|
3049 |
].
|
|
3050 |
^ FMax
|
|
3051 |
|
|
3052 |
"
|
|
3053 |
Float fmax
|
|
3054 |
self fmax
|
|
3055 |
"
|
|
3056 |
|
|
3057 |
"Created: / 14-06-2017 / 19:14:18 / cg"
|
|
3058 |
!
|
|
3059 |
|
|
3060 |
fmin
|
|
3061 |
"return the smallest representable instance of this class"
|
|
3062 |
|
|
3063 |
FMin isNil ifTrue:[
|
5315
|
3064 |
FMin := Float fmin asQDouble. "/ 1.6259745436952323e-260 asQDouble
|
4392
|
3065 |
].
|
|
3066 |
^ FMin
|
|
3067 |
|
|
3068 |
"
|
|
3069 |
QDouble fmin
|
|
3070 |
Float fmin
|
|
3071 |
"
|
|
3072 |
|
|
3073 |
"Created: / 14-06-2017 / 19:14:49 / cg"
|
|
3074 |
!
|
|
3075 |
|
4411
|
3076 |
infinity
|
|
3077 |
^ Infinity positive
|
|
3078 |
|
|
3079 |
"Created: / 18-06-2017 / 23:41:07 / cg"
|
|
3080 |
!
|
|
3081 |
|
4380
|
3082 |
ln10
|
|
3083 |
"return the constant e as quad precision double.
|
4433
|
3084 |
(returns approx. 200 bits of precision)"
|
4380
|
3085 |
|
|
3086 |
Ln10 isNil ifTrue:[
|
5315
|
3087 |
Ln10 := self d0: 2.302585092994045901e+00
|
|
3088 |
d1: -2.170756223382249351e-16
|
|
3089 |
d2: -9.984262454465776570e-33
|
|
3090 |
d3: -4.023357454450206379e-49
|
4388
|
3091 |
].
|
4380
|
3092 |
^ Ln10
|
|
3093 |
|
|
3094 |
"
|
5309
|
3095 |
self ln10 printfPrintString:'%.61f'
|
5315
|
3096 |
-> '2.3025850929940456840179914546843642076011014886287729760333279'
|
5304
|
3097 |
Wolfram says:
|
5315
|
3098 |
2.30258509299404568401799145468436420760110148862877297603332790096757260967735248023599720508959829834196778404228...
|
4380
|
3099 |
"
|
|
3100 |
|
|
3101 |
"Created: / 12-06-2017 / 18:32:29 / cg"
|
|
3102 |
!
|
|
3103 |
|
|
3104 |
ln2
|
|
3105 |
"return the constant e as quad precision double.
|
4433
|
3106 |
(returns approx. 200 bits of precision)"
|
4380
|
3107 |
|
|
3108 |
Ln2 isNil ifTrue:[
|
5315
|
3109 |
Ln2 := self d0: 6.931471805599452862e-01
|
|
3110 |
d1: 2.319046813846299558e-17
|
|
3111 |
d2: 5.707708438416212066e-34
|
|
3112 |
d3: -3.582432210601811423e-50
|
4388
|
3113 |
].
|
4380
|
3114 |
^ Ln2
|
|
3115 |
|
|
3116 |
"
|
5308
|
3117 |
self ln2 printfPrintString:'%.61f'
|
5315
|
3118 |
-> '0.6931471805599452709398341558750792990469129794959648865081141'
|
5304
|
3119 |
Wolfram says:
|
5315
|
3120 |
0.69314718055994530941723212145817656807550013436025525412068000949339362196969471560586332699641868754200148102057...
|
4380
|
3121 |
"
|
|
3122 |
|
|
3123 |
"Created: / 12-06-2017 / 18:31:34 / cg"
|
|
3124 |
!
|
|
3125 |
|
4411
|
3126 |
negativeInfinity
|
|
3127 |
^ Infinity negative
|
|
3128 |
|
|
3129 |
"Created: / 18-06-2017 / 23:40:47 / cg"
|
|
3130 |
!
|
|
3131 |
|
4380
|
3132 |
pi
|
|
3133 |
"return the constant pi as quad precision double.
|
4433
|
3134 |
(returns approx. 200 bits of precision)"
|
4380
|
3135 |
|
|
3136 |
Pi isNil ifTrue:[
|
5315
|
3137 |
Pi := self d0: 3.141592653589793116e+00
|
|
3138 |
d1: 1.224646799147353207e-16
|
|
3139 |
d2: -2.994769809718339666e-33
|
|
3140 |
d3: 1.112454220863365282e-49
|
5308
|
3141 |
].
|
4380
|
3142 |
^ Pi
|
|
3143 |
|
|
3144 |
"
|
5308
|
3145 |
self pi printfPrintString:'%.60f'
|
5315
|
3146 |
'3.141592653589793238462643383279502884197169399375105820974945'
|
5288
|
3147 |
Wolfram says:
|
5315
|
3148 |
3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068
|
5288
|
3149 |
|
|
3150 |
(QDouble readFrom:'3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253')
|
5308
|
3151 |
printfPrintString:'%.60f'
|
5288
|
3152 |
|
4380
|
3153 |
"
|
|
3154 |
|
|
3155 |
"Created: / 12-06-2017 / 18:27:13 / cg"
|
4395
|
3156 |
!
|
|
3157 |
|
|
3158 |
unity
|
|
3159 |
"return the neutral element for multiplication (1.0) as QDouble"
|
|
3160 |
|
|
3161 |
QDoubleOne isNil ifTrue:[
|
5315
|
3162 |
QDoubleOne := 1.0 asQDouble.
|
4395
|
3163 |
].
|
|
3164 |
^ QDoubleOne
|
|
3165 |
|
|
3166 |
"
|
|
3167 |
self unity
|
|
3168 |
"
|
|
3169 |
|
|
3170 |
"Created: / 15-06-2017 / 11:45:22 / cg"
|
|
3171 |
!
|
|
3172 |
|
|
3173 |
zero
|
|
3174 |
"return the neutral element for addition (0.0) as QDouble"
|
|
3175 |
|
|
3176 |
QDoubleZero isNil ifTrue:[
|
5315
|
3177 |
QDoubleZero := 0.0 asQDouble
|
4395
|
3178 |
].
|
|
3179 |
^ QDoubleZero
|
|
3180 |
|
|
3181 |
"
|
|
3182 |
self zero
|
|
3183 |
"
|
|
3184 |
|
|
3185 |
"Created: / 15-06-2017 / 11:44:13 / cg"
|
4380
|
3186 |
! !
|
|
3187 |
|
|
3188 |
!QDouble class methodsFor:'queries'!
|
|
3189 |
|
4395
|
3190 |
defaultPrintPrecision
|
|
3191 |
"return the number of decimal digits printed by default"
|
|
3192 |
|
5336
|
3193 |
^ DefaultPrintPrecision ? 10
|
4395
|
3194 |
|
|
3195 |
"
|
5308
|
3196 |
ShortFloat defaultPrintPrecision
|
|
3197 |
Float defaultPrintPrecision
|
|
3198 |
LongFloat defaultPrintPrecision
|
|
3199 |
QDouble defaultPrintPrecision
|
|
3200 |
QuadFloat defaultPrintPrecision
|
|
3201 |
OctaFloat defaultPrintPrecision
|
4395
|
3202 |
"
|
|
3203 |
|
|
3204 |
"Created: / 17-06-2017 / 02:58:51 / cg"
|
4440
|
3205 |
"Modified: / 21-06-2017 / 13:39:08 / cg"
|
4395
|
3206 |
!
|
|
3207 |
|
4380
|
3208 |
epsilon
|
|
3209 |
"return the maximum relative spacing of instances of mySelf
|
5270
|
3210 |
(i.e. the value-delta of the least significant bit)
|
|
3211 |
see https://en.wikipedia.org/wiki/Machine_epsilon"
|
4380
|
3212 |
|
5288
|
3213 |
"/ ^ 1.2154326714572500565324311366323150942261000827598106963711353e-63
|
5273
|
3214 |
Epsilon isNil ifTrue:[
|
5315
|
3215 |
Epsilon := self computeEpsilon.
|
5273
|
3216 |
].
|
|
3217 |
^ Epsilon
|
4380
|
3218 |
|
|
3219 |
"
|
5308
|
3220 |
Float epsilon -> 2.22044604925031E-16
|
4440
|
3221 |
ShortFloat epsilon -> 1.19209289550781E-07
|
|
3222 |
LongFloat epsilon -> 1.0842021724855E-19
|
5288
|
3223 |
QDouble epsilon -> 7.77876909732643E-62 / (1.215432671457250056532e-63 read comment in precision)
|
4380
|
3224 |
"
|
|
3225 |
|
|
3226 |
"Created: / 12-06-2017 / 18:52:44 / cg"
|
4443
|
3227 |
"Modified: / 22-06-2017 / 15:34:56 / cg"
|
4380
|
3228 |
!
|
|
3229 |
|
|
3230 |
numBitsInExponent
|
5275
|
3231 |
"answer the number of bits in the exponent.
|
|
3232 |
I use regular IEEE doubles to store the value,
|
|
3233 |
thus my exponent bits are the same as double's exponent bits"
|
4380
|
3234 |
|
|
3235 |
^ Float numBitsInExponent
|
|
3236 |
|
|
3237 |
"
|
4963
|
3238 |
1.0 asQDouble numBitsInExponent
|
4380
|
3239 |
"
|
|
3240 |
|
|
3241 |
"Created: / 12-06-2017 / 11:11:04 / cg"
|
4963
|
3242 |
"Modified (comment): / 28-05-2019 / 08:55:04 / Claus Gittinger"
|
4380
|
3243 |
!
|
|
3244 |
|
|
3245 |
numBitsInMantissa
|
5336
|
3246 |
"answer the number of bits in the mantissa (the significant).
|
4430
|
3247 |
Here, a fake number is returned"
|
|
3248 |
|
|
3249 |
^ (Float numBitsInMantissa - 1) * 4
|
4395
|
3250 |
|
4380
|
3251 |
"
|
4963
|
3252 |
1.0 asFloat numBitsInMantissa
|
|
3253 |
1.0 asShortFloat numBitsInMantissa
|
|
3254 |
1.0 asLongFloat numBitsInMantissa
|
|
3255 |
1.0 asQDouble numBitsInMantissa
|
4380
|
3256 |
1.0 asQDouble class numBitsInMantissa
|
|
3257 |
|
|
3258 |
Float numBitsInMantissa
|
|
3259 |
ShortFloat numBitsInMantissa
|
|
3260 |
QDouble numBitsInMantissa
|
|
3261 |
"
|
|
3262 |
|
|
3263 |
"Created: / 12-06-2017 / 11:13:44 / cg"
|
4430
|
3264 |
"Modified (comment): / 20-06-2017 / 11:05:26 / cg"
|
4963
|
3265 |
"Modified (comment): / 28-05-2019 / 09:07:07 / Claus Gittinger"
|
4380
|
3266 |
!
|
|
3267 |
|
|
3268 |
precision
|
|
3269 |
"answer the number of bits in the mantissa"
|
|
3270 |
|
4431
|
3271 |
"/ subtract some due to overlap in the component numbers
|
5308
|
3272 |
"/ actual precision seems to be more like:
|
5288
|
3273 |
"/ ^ (Float precision) * 4 - 3 + 1.
|
|
3274 |
"/ but I am a bit conservative here:
|
4431
|
3275 |
^ (Float precision - 2) * 4
|
4395
|
3276 |
|
4380
|
3277 |
"
|
5273
|
3278 |
ShortFloat precision -> 24
|
|
3279 |
Float precision -> 53
|
|
3280 |
LongFloat precision -> 64
|
5308
|
3281 |
QDouble precision -> 204
|
5273
|
3282 |
QuadFloat precision -> 113
|
|
3283 |
OctaFloat precision -> 237
|
|
3284 |
|
4380
|
3285 |
1.0 class numBitsInMantissa
|
|
3286 |
1.0 asShortFloat class numBitsInMantissa
|
|
3287 |
1.0 asLongFloat class numBitsInMantissa
|
|
3288 |
1.0 asQDouble class numBitsInMantissa
|
|
3289 |
|
|
3290 |
Float numBitsInMantissa
|
|
3291 |
ShortFloat numBitsInMantissa
|
|
3292 |
QDouble numBitsInMantissa
|
|
3293 |
"
|
|
3294 |
|
|
3295 |
"Created: / 12-06-2017 / 18:49:11 / cg"
|
4431
|
3296 |
"Modified (comment): / 20-06-2017 / 12:59:00 / cg"
|
4380
|
3297 |
!
|
|
3298 |
|
|
3299 |
radix
|
5057
|
3300 |
"answer the radix of a QDouble's exponent
|
4380
|
3301 |
This is an IEEE float, which is represented as binary"
|
|
3302 |
|
|
3303 |
^ Float radix
|
|
3304 |
|
|
3305 |
"Created: / 12-06-2017 / 18:50:04 / cg"
|
5057
|
3306 |
"Modified (comment): / 19-07-2019 / 17:28:25 / Claus Gittinger"
|
4380
|
3307 |
! !
|
|
3308 |
|
|
3309 |
!QDouble methodsFor:'arithmetic'!
|
|
3310 |
|
|
3311 |
* aNumber
|
|
3312 |
"return the product of the receiver and the argument, aNumber"
|
|
3313 |
|
5308
|
3314 |
%{
|
|
3315 |
if (__isFloatLike(aNumber)) {
|
5315
|
3316 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
3317 |
double b = __floatVal(aNumber);
|
|
3318 |
double c0, c1, c2, c3;
|
|
3319 |
OBJ newQD;
|
|
3320 |
int savedCV;
|
|
3321 |
|
|
3322 |
fpu_fix_start(&savedCV);
|
|
3323 |
s_mul_qd(&c0, &c1, &c2, &c3, b, a[0], a[1], a[2], a[3]);
|
|
3324 |
fpu_fix_end(&savedCV);
|
|
3325 |
__qNew_qdReal(newQD, c0, c1, c2, c3);
|
|
3326 |
RETURN( newQD );
|
5308
|
3327 |
}
|
|
3328 |
if (__isQDouble(aNumber)) {
|
5315
|
3329 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
3330 |
double *b = __QDoubleInstPtr(aNumber)->d_qDoubleValue;
|
|
3331 |
double c0, c1, c2, c3;
|
|
3332 |
OBJ newQD;
|
|
3333 |
int savedCV;
|
|
3334 |
|
|
3335 |
fpu_fix_start(&savedCV);
|
|
3336 |
qd_mul_qd(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
|
|
3337 |
fpu_fix_end(&savedCV);
|
|
3338 |
__qNew_qdReal(newQD, c0, c1, c2, c3);
|
|
3339 |
RETURN( newQD );
|
5308
|
3340 |
}
|
|
3341 |
%}.
|
4380
|
3342 |
^ aNumber productFromQDouble:self
|
|
3343 |
|
|
3344 |
"
|
5309
|
3345 |
(QDouble fromFloat:1e20) * 2.0
|
|
3346 |
(QDouble fromFloat:1e20) * 1e20
|
|
3347 |
(QDouble fromFloat:1e20) * (QDouble fromFloat:1e20)
|
5308
|
3348 |
((QDouble fromFloat:1e20) * (QDouble fromFloat:2.0)) asDoubleArray
|
|
3349 |
((QDouble fromFloat:1e-20) * (QDouble fromFloat:2.0)) asDoubleArray
|
|
3350 |
((QDouble fromFloat:2.0) * (QDouble fromFloat:2.0)) asDoubleArray
|
4380
|
3351 |
"
|
|
3352 |
|
5308
|
3353 |
"Created: / 12-06-2017 / 23:41:39 / cg"
|
|
3354 |
"Modified (comment): / 15-06-2017 / 00:34:41 / cg"
|
4380
|
3355 |
!
|
|
3356 |
|
|
3357 |
+ aNumber
|
|
3358 |
"return the sum of the receiver and the argument, aNumber"
|
|
3359 |
|
5308
|
3360 |
%{
|
|
3361 |
if (__isFloatLike(aNumber)) {
|
5315
|
3362 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
3363 |
double b = __floatVal(aNumber);
|
|
3364 |
double c0, c1, c2, c3;
|
|
3365 |
OBJ newQD;
|
|
3366 |
int savedCV;
|
|
3367 |
|
|
3368 |
fpu_fix_start(&savedCV);
|
|
3369 |
qd_add_s(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b);
|
|
3370 |
fpu_fix_end(&savedCV);
|
|
3371 |
__qNew_qdReal(newQD, c0, c1, c2, c3);
|
|
3372 |
RETURN( newQD );
|
5308
|
3373 |
}
|
|
3374 |
if (__isQDouble(aNumber)) {
|
5315
|
3375 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
3376 |
double *b = __QDoubleInstPtr(aNumber)->d_qDoubleValue;
|
|
3377 |
double c0, c1, c2, c3;
|
|
3378 |
OBJ newQD;
|
|
3379 |
int savedCV;
|
|
3380 |
|
|
3381 |
fpu_fix_start(&savedCV);
|
|
3382 |
qd_add_qd(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
|
|
3383 |
fpu_fix_end(&savedCV);
|
|
3384 |
__qNew_qdReal(newQD, c0, c1, c2, c3);
|
|
3385 |
RETURN( newQD );
|
5308
|
3386 |
}
|
|
3387 |
%}.
|
4380
|
3388 |
^ aNumber sumFromQDouble:self
|
|
3389 |
|
|
3390 |
"
|
5308
|
3391 |
((QDouble fromFloat:1e20) + 1.0) asDoubleArray
|
4380
|
3392 |
((QDouble fromFloat:1e20) + (QDouble fromFloat:1.0)) asDoubleArray
|
|
3393 |
"
|
|
3394 |
|
|
3395 |
"Created: / 12-06-2017 / 16:17:46 / cg"
|
|
3396 |
"Modified: / 12-06-2017 / 23:06:22 / cg"
|
|
3397 |
!
|
|
3398 |
|
|
3399 |
- aNumber
|
|
3400 |
"return the sum of the receiver and the argument, aNumber"
|
|
3401 |
|
5308
|
3402 |
%{
|
|
3403 |
if (__isFloatLike(aNumber)) {
|
5315
|
3404 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
3405 |
double b = __floatVal(aNumber);
|
|
3406 |
double c0, c1, c2, c3;
|
|
3407 |
OBJ newQD;
|
|
3408 |
int savedCV;
|
|
3409 |
|
|
3410 |
fpu_fix_start(&savedCV);
|
|
3411 |
qd_add_s(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], -b);
|
|
3412 |
fpu_fix_end(&savedCV);
|
|
3413 |
__qNew_qdReal(newQD, c0, c1, c2, c3);
|
|
3414 |
RETURN( newQD );
|
5308
|
3415 |
}
|
|
3416 |
if (__isQDouble(aNumber)) {
|
5315
|
3417 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
3418 |
double *b = __QDoubleInstPtr(aNumber)->d_qDoubleValue;
|
|
3419 |
double c0, c1, c2, c3;
|
|
3420 |
OBJ newQD;
|
|
3421 |
int savedCV;
|
|
3422 |
|
|
3423 |
fpu_fix_start(&savedCV);
|
|
3424 |
qd_sub_qd(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
|
|
3425 |
fpu_fix_end(&savedCV);
|
|
3426 |
__qNew_qdReal(newQD, c0, c1, c2, c3);
|
|
3427 |
RETURN( newQD );
|
5308
|
3428 |
}
|
|
3429 |
%}.
|
4393
|
3430 |
^ self + (aNumber negated)
|
4380
|
3431 |
|
|
3432 |
"
|
5308
|
3433 |
(QDouble fromFloat:1e20) - 1.0
|
4380
|
3434 |
((QDouble fromFloat:1e20) - (QDouble fromFloat:1.0)) asDoubleArray
|
|
3435 |
(QDouble fromFloat:1e-20) asDoubleArray
|
|
3436 |
((QDouble fromFloat:1e-20) - (QDouble fromFloat:1.0)) asDoubleArray
|
|
3437 |
((QDouble fromFloat:2.0) - (QDouble fromFloat:1.0)) asDoubleArray
|
4395
|
3438 |
|
4393
|
3439 |
((QDouble fromFloat:2.0) - (QDouble fromFloat:1.0) + (QDouble fromFloat:1.0)) asDoubleArray
|
|
3440 |
((QDouble fromFloat:1e-20) - (QDouble fromFloat:1.0) + (QDouble fromFloat:1.0)) asDoubleArray
|
4380
|
3441 |
"
|
|
3442 |
|
|
3443 |
"Created: / 12-06-2017 / 23:41:39 / cg"
|
4393
|
3444 |
"Modified (comment): / 15-06-2017 / 00:34:41 / cg"
|
4386
|
3445 |
!
|
|
3446 |
|
|
3447 |
/ aNumber
|
|
3448 |
"return the quotient of the receiver and the argument, aNumber"
|
|
3449 |
|
5308
|
3450 |
%{
|
|
3451 |
if (__isFloatLike(aNumber)) {
|
5315
|
3452 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
3453 |
double b = __floatVal(aNumber);
|
|
3454 |
double c0, c1, c2, c3;
|
|
3455 |
OBJ newQD;
|
|
3456 |
int savedCV;
|
|
3457 |
|
|
3458 |
fpu_fix_start(&savedCV);
|
|
3459 |
qd_div_s(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b);
|
|
3460 |
fpu_fix_end(&savedCV);
|
|
3461 |
__qNew_qdReal(newQD, c0, c1, c2, c3);
|
|
3462 |
RETURN( newQD );
|
5308
|
3463 |
}
|
|
3464 |
if (__isQDouble(aNumber)) {
|
5315
|
3465 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
3466 |
double *b = __QDoubleInstPtr(aNumber)->d_qDoubleValue;
|
|
3467 |
double c0, c1, c2, c3;
|
|
3468 |
OBJ newQD;
|
|
3469 |
int savedCV;
|
|
3470 |
|
|
3471 |
fpu_fix_start(&savedCV);
|
|
3472 |
qd_div_qd(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
|
|
3473 |
fpu_fix_end(&savedCV);
|
|
3474 |
__qNew_qdReal(newQD, c0, c1, c2, c3);
|
|
3475 |
RETURN( newQD );
|
5308
|
3476 |
}
|
|
3477 |
%}.
|
4386
|
3478 |
^ aNumber quotientFromQDouble:self
|
|
3479 |
|
|
3480 |
"
|
|
3481 |
((QDouble fromFloat:1e20) / (QDouble fromFloat:2.0)) asDoubleArray
|
4395
|
3482 |
|
4393
|
3483 |
((QDouble fromFloat:1.2345) / (QDouble fromFloat:10.0)) asDoubleArray
|
|
3484 |
((QDouble fromFloat:1.2345) / 10.0) asDoubleArray
|
|
3485 |
|
4386
|
3486 |
"
|
|
3487 |
|
|
3488 |
"Created: / 13-06-2017 / 17:59:09 / cg"
|
4393
|
3489 |
"Modified (comment): / 15-06-2017 / 00:14:26 / cg"
|
4380
|
3490 |
! !
|
|
3491 |
|
|
3492 |
!QDouble methodsFor:'coercing & converting'!
|
|
3493 |
|
|
3494 |
asDoubleArray
|
4395
|
3495 |
^ DoubleArray
|
5315
|
3496 |
with:self d0
|
|
3497 |
with:self d1
|
|
3498 |
with:self d2
|
|
3499 |
with:self d3.
|
4380
|
3500 |
|
|
3501 |
"
|
5308
|
3502 |
(QDouble fromFloat:1.0) asDoubleArray
|
|
3503 |
(1.0 asQDouble + 1e-40) asDoubleArray
|
4386
|
3504 |
(QDouble fromFloat:2.0) asDoubleArray
|
4380
|
3505 |
"
|
|
3506 |
|
|
3507 |
"Created: / 12-06-2017 / 18:19:19 / cg"
|
4386
|
3508 |
"Modified (comment): / 13-06-2017 / 17:58:09 / cg"
|
4380
|
3509 |
!
|
|
3510 |
|
|
3511 |
asFloat
|
5306
|
3512 |
^ self d0 + self d1
|
4380
|
3513 |
|
|
3514 |
"
|
5306
|
3515 |
(QDouble fromFloat:1.0) asFloat -> 1.0
|
|
3516 |
(QDouble fromFloat:2.0) asFloat -> 2.0
|
|
3517 |
(2.0 asQDouble + 1e-14) asFloat -> 2.00000000000001
|
|
3518 |
(2.0 + 1e-14) - 2.0 -> 1.02140518265514E-14
|
|
3519 |
(2.0 + 1e-15) - 2.0 -> 8.88178419700125E-16
|
|
3520 |
(2.0 + 1e-16) - 2.0 -> 0.0
|
4380
|
3521 |
"
|
|
3522 |
|
|
3523 |
"Created: / 12-06-2017 / 18:15:27 / cg"
|
4386
|
3524 |
"Modified: / 13-06-2017 / 17:56:50 / cg"
|
4380
|
3525 |
!
|
|
3526 |
|
4421
|
3527 |
asInteger
|
|
3528 |
^ self d0 asInteger
|
4981
|
3529 |
+ self d1 asInteger
|
|
3530 |
+ self d2 asInteger
|
4421
|
3531 |
+ self d3 asInteger
|
|
3532 |
|
|
3533 |
"Created: / 19-06-2017 / 18:07:17 / cg"
|
|
3534 |
!
|
|
3535 |
|
5306
|
3536 |
asLargeFloat
|
|
3537 |
^ (self d0 asLargeFloat precision:self precision) + self d1 + self d2 + self d3
|
|
3538 |
|
|
3539 |
"
|
|
3540 |
(QDouble fromFloat:1.0) asLargeFloat -> 1.000000000000000000000000000000
|
|
3541 |
(QDouble fromFloat:2.0) asLargeFloat -> 2.000000000000000000000000000000
|
|
3542 |
(2.0 asQDouble + 1e-14) asLargeFloat -> 2.000000000000010214051826551440
|
|
3543 |
(2.0 asLargeFloat + 1e-14) - 2.0 -> 0.000000000000010214051826551440
|
|
3544 |
(2.0 + 1e-14) - 2.0 -> 1.02140518265514E-14
|
|
3545 |
(2.0 asLargeFloat + 1e-14) - 2.0 -> 0.000000000000010214051826551440
|
|
3546 |
(2.0 asLargeFloat + 1e-15) - 2.0 -> 0.000000000000000888178419700125
|
|
3547 |
(2.0 asLargeFloat + 1e-16) - 2.0 -> 0.0
|
|
3548 |
(2QL + 1QL-14) - 2QL -> 0.000000000000010000000000000000
|
|
3549 |
"
|
|
3550 |
!
|
|
3551 |
|
|
3552 |
asLongFloat
|
|
3553 |
^ self d0 asLongFloat + self d1
|
|
3554 |
|
|
3555 |
"
|
|
3556 |
(QDouble fromFloat:1.0) asLongFloat -> 1.0
|
|
3557 |
(QDouble fromFloat:2.0) asLongFloat -> 2.0
|
|
3558 |
(2.0 asQDouble + 1e-14) asLongFloat -> 2.00000000000001
|
|
3559 |
(2.0 asLongFloat + 1e-14) - 2.0 -> 1.00000303177028016E-14
|
|
3560 |
(2.0 + 1e-14) - 2.0 -> 1.02140518265514E-14
|
|
3561 |
(2.0 asLargeFloat + 1e-14) - 2.0 -> 0.000000000000010214051826551440
|
|
3562 |
(2.0 asLargeFloat + 1e-15) - 2.0 -> 0.000000000000000888178419700125
|
|
3563 |
(2.0 asLargeFloat + 1e-16) - 2.0 -> 0.0
|
|
3564 |
(2QL + 1QL-14) - 2QL -> 0.000000000000010000000000000000
|
|
3565 |
"
|
|
3566 |
|
|
3567 |
"Created: / 12-06-2017 / 18:15:27 / cg"
|
|
3568 |
"Modified: / 13-06-2017 / 17:56:50 / cg"
|
|
3569 |
!
|
|
3570 |
|
4395
|
3571 |
asQDouble
|
|
3572 |
"return a QDouble with same value as myself."
|
|
3573 |
|
|
3574 |
^ self
|
|
3575 |
!
|
|
3576 |
|
4430
|
3577 |
asTrueFraction
|
|
3578 |
^ self d0 asTrueFraction
|
|
3579 |
+ self d1 asTrueFraction
|
|
3580 |
+ self d2 asTrueFraction
|
|
3581 |
+ self d3 asTrueFraction
|
|
3582 |
|
|
3583 |
"
|
|
3584 |
1e10 asTrueFraction -> 10000000000
|
|
3585 |
1e20 asTrueFraction -> 100000000000000000000
|
|
3586 |
(1e20 + 1) asTrueFraction -> 100000000000000000000 ouch!!
|
|
3587 |
|
|
3588 |
1e10 asQDouble asTrueFraction -> 10000000000
|
|
3589 |
1e20 asQDouble asTrueFraction -> 100000000000000000000
|
|
3590 |
(1e20 asQDouble + 1) asTrueFraction -> 100000000000000000001
|
|
3591 |
|
4981
|
3592 |
(1e40 asQDouble + 1e20 + 1) asTrueFraction -> 10000000000000000303886028427003666890753
|
|
3593 |
(1e40 asQDouble + 1e20) asTrueFraction
|
4430
|
3594 |
"
|
|
3595 |
|
|
3596 |
"Created: / 20-06-2017 / 11:09:03 / cg"
|
|
3597 |
!
|
|
3598 |
|
4380
|
3599 |
coerce:aNumber
|
|
3600 |
"convert the argument aNumber into an instance of the receiver's class and return it."
|
|
3601 |
|
|
3602 |
^ aNumber asQDouble
|
|
3603 |
|
|
3604 |
"Created: / 12-06-2017 / 17:13:47 / cg"
|
|
3605 |
"Modified: / 12-06-2017 / 21:09:06 / cg"
|
|
3606 |
!
|
|
3607 |
|
4430
|
3608 |
exponent
|
5275
|
3609 |
"extract a normalized float's (unbiased) exponent.
|
|
3610 |
The returned value depends on the float-representation of
|
|
3611 |
the underlying machine and is therefore highly unportable.
|
|
3612 |
This is not for general use.
|
|
3613 |
This assumes that the mantissa is normalized to
|
|
3614 |
0.5 .. 1.0 and the float's value is: mantissa * 2^exp"
|
|
3615 |
|
4430
|
3616 |
^ self d0 exponent
|
|
3617 |
|
|
3618 |
"Created: / 20-06-2017 / 11:06:02 / cg"
|
|
3619 |
!
|
|
3620 |
|
4380
|
3621 |
generality
|
|
3622 |
"return the generality value - see ArithmeticValue>>retry:coercing:"
|
|
3623 |
|
|
3624 |
^ 95
|
|
3625 |
|
|
3626 |
"Created: / 12-06-2017 / 17:13:14 / cg"
|
5288
|
3627 |
!
|
|
3628 |
|
|
3629 |
mantissa
|
|
3630 |
"extract a normalized float's mantissa.
|
|
3631 |
The returned value depends on the float-representation of
|
|
3632 |
the underlying machine and is therefore highly unportable.
|
|
3633 |
This is not for general use.
|
|
3634 |
This assumes that the mantissa is normalized to
|
|
3635 |
0.5 .. 1.0 and the float's value is mantissa * 2^exp"
|
|
3636 |
|
|
3637 |
"/ fake it here
|
|
3638 |
^ self / (2 raisedTo:self exponent)
|
|
3639 |
|
|
3640 |
"
|
|
3641 |
1.0 exponent -> 1
|
|
3642 |
1.0 mantissa -> 0.5
|
|
3643 |
12345.0 exponent -> 14
|
|
3644 |
12345.0 mantissa -> 0.75347900390625
|
|
3645 |
-1.0 exponent -> 1
|
|
3646 |
-1.0 mantissa -> -0.5
|
|
3647 |
-12345.0 exponent -> 14
|
|
3648 |
-12345.0 mantissa -> -0.75347900390625
|
|
3649 |
(1e40 + 1e-40) exponent -> 133
|
|
3650 |
(1e40 + 1e-40) mantissa -> 0.918354961579912
|
|
3651 |
|
|
3652 |
1.0 asQDouble exponent -> 1
|
|
3653 |
1.0 asQDouble mantissa -> 0.5
|
5344
|
3654 |
1.0QD asQDouble exponent -> 1
|
5288
|
3655 |
12345.0 asQDouble exponent -> 14
|
|
3656 |
12345.0 asQDouble mantissa -> 0.75347900390625
|
|
3657 |
-1.0 asQDouble exponent -> 1
|
|
3658 |
-1.0 asQDouble mantissa -> -0.5
|
|
3659 |
-12345.0 asQDouble exponent -> 14
|
|
3660 |
-12345.0 asQDouble mantissa -> -0.75347900390625
|
|
3661 |
(1e40 + 1e-40) asQDouble exponent -> 133
|
|
3662 |
(1e40 + 1e-40) asQDouble mantissa -> 0.918354961579912
|
5326
|
3663 |
|
|
3664 |
self assert:(1.0 asQDouble mantissa * (2 raisedTo:1.0 asQDouble exponent)) = 1.0 asQDouble.
|
|
3665 |
self assert:(100.0 asQDouble mantissa * (2 raisedTo:100.0 asQDouble exponent)) = 100.0 asQDouble.
|
|
3666 |
self assert:(10e15 asQDouble mantissa * (2 raisedTo:10e15 asQDouble exponent)) = 10e15 asQDouble.
|
|
3667 |
self assert:(10e-15 asQDouble mantissa * (2 raisedTo:10e-15 asQDouble exponent)) = 10e-15 asQDouble.
|
5288
|
3668 |
"
|
|
3669 |
|
|
3670 |
"Created: / 20-06-2017 / 11:06:02 / cg"
|
4380
|
3671 |
! !
|
|
3672 |
|
4385
|
3673 |
!QDouble methodsFor:'comparing'!
|
|
3674 |
|
|
3675 |
< aNumber
|
|
3676 |
"return true, if the argument, aNumber is greater than the receiver"
|
|
3677 |
|
|
3678 |
^ aNumber lessFromQDouble:self
|
|
3679 |
|
|
3680 |
"Created: / 13-06-2017 / 16:58:53 / cg"
|
|
3681 |
!
|
|
3682 |
|
|
3683 |
= aNumber
|
|
3684 |
"return true, if the argument, aNumber has the same value as than the receiver"
|
|
3685 |
|
5273
|
3686 |
%{
|
5308
|
3687 |
if (__isSmallInteger(aNumber)) {
|
5315
|
3688 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
3689 |
double b = (double)(__intVal(aNumber));
|
|
3690 |
|
|
3691 |
RETURN ((a[0] == b
|
|
3692 |
&& a[1] == 0.0
|
|
3693 |
&& a[2] == 0.0
|
|
3694 |
&& a[3] == 0.0) ? true : false);
|
5308
|
3695 |
}
|
|
3696 |
if (aNumber == nil) {
|
5315
|
3697 |
RETURN(false);
|
5273
|
3698 |
}
|
5308
|
3699 |
if (__qClass(aNumber) == QDouble) {
|
5315
|
3700 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
3701 |
double *b = __QDoubleInstPtr(aNumber)->d_qDoubleValue;
|
|
3702 |
|
|
3703 |
RETURN ((a[0] == b[0]
|
|
3704 |
&& a[1] == b[1]
|
|
3705 |
&& a[2] == b[2]
|
|
3706 |
&& a[3] == b[3]) ? true : false);
|
5273
|
3707 |
}
|
5308
|
3708 |
if (__qClass(aNumber) == Float) {
|
5315
|
3709 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
3710 |
double b = __floatVal(aNumber);
|
|
3711 |
|
|
3712 |
RETURN ((a[0] == b
|
|
3713 |
&& a[1] == 0.0
|
|
3714 |
&& a[2] == 0.0
|
|
3715 |
&& a[3] == 0.0) ? true : false);
|
5273
|
3716 |
}
|
|
3717 |
%}.
|
4385
|
3718 |
^ aNumber equalFromQDouble:self
|
|
3719 |
|
5273
|
3720 |
"
|
5308
|
3721 |
1.0 asQDouble = 1.0 asQDouble
|
|
3722 |
1.0 asQDouble = 1.0
|
|
3723 |
1.0 asQDouble = 1
|
|
3724 |
1.0 asQDouble = 2
|
5273
|
3725 |
"
|
|
3726 |
|
4385
|
3727 |
"Created: / 13-06-2017 / 17:12:09 / cg"
|
|
3728 |
! !
|
|
3729 |
|
4380
|
3730 |
!QDouble methodsFor:'double dispatching'!
|
|
3731 |
|
|
3732 |
differenceFromFloat:aFloat
|
5308
|
3733 |
%{
|
|
3734 |
if (__isFloatLike(aFloat)) {
|
5315
|
3735 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
3736 |
double b = __floatVal(aFloat);
|
|
3737 |
double c0, c1, c2, c3;
|
|
3738 |
double e;
|
|
3739 |
OBJ newQD;
|
|
3740 |
int savedCV;
|
|
3741 |
|
|
3742 |
fpu_fix_start(&savedCV);
|
|
3743 |
s_sub_qd(&c0, &c1, &c2, &c3, b, a[0], a[1], a[2], a[3]);
|
|
3744 |
fpu_fix_end(&savedCV);
|
|
3745 |
__qNew_qdReal(newQD, c0, c1, c2, c3);
|
|
3746 |
RETURN( newQD );
|
5308
|
3747 |
}
|
|
3748 |
%}.
|
|
3749 |
^ super differenceFromFloat:aFloat.
|
4380
|
3750 |
|
|
3751 |
"
|
|
3752 |
1.0 - (QDouble fromFloat:1.0)
|
|
3753 |
1e20 - (QDouble fromFloat:1.0)
|
|
3754 |
(1.0 - (QDouble fromFloat:1.0)) asFloat
|
|
3755 |
(1e20 - (QDouble fromFloat:1.0)) asFloat
|
|
3756 |
|
|
3757 |
(1.0 - (QDouble fromFloat:1.0)) asDoubleArray
|
|
3758 |
(1e20 - (QDouble fromFloat:1.0)) asDoubleArray
|
|
3759 |
(1e20 - (QDouble fromFloat:1.0) + 1e-20) asDoubleArray
|
|
3760 |
"
|
|
3761 |
|
5308
|
3762 |
|
4380
|
3763 |
!
|
|
3764 |
|
|
3765 |
differenceFromQDouble:aQDouble
|
5308
|
3766 |
%{
|
|
3767 |
if (__isQDouble(aQDouble)) {
|
5315
|
3768 |
double *a = __QDoubleInstPtr(aQDouble)->d_qDoubleValue;
|
|
3769 |
double *b = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
3770 |
double c0, c1, c2, c3;
|
|
3771 |
OBJ newQD;
|
|
3772 |
int savedCV;
|
|
3773 |
|
|
3774 |
fpu_fix_start(&savedCV);
|
|
3775 |
qd_sub_qd(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
|
|
3776 |
fpu_fix_end(&savedCV);
|
|
3777 |
__qNew_qdReal(newQD, c0, c1, c2, c3);
|
|
3778 |
RETURN( newQD );
|
5308
|
3779 |
}
|
|
3780 |
%}.
|
|
3781 |
^ super differenceFromQDouble:aQDouble
|
4380
|
3782 |
|
|
3783 |
"
|
5308
|
3784 |
(QDouble fromFloat:1.0) - (QDouble fromFloat:1.0)
|
|
3785 |
(QDouble fromFloat:1.0) - 1.0
|
4380
|
3786 |
1.0 - (QDouble fromFloat:1.0)
|
5308
|
3787 |
|
|
3788 |
((QDouble fromFloat:1.0) - (QDouble fromFloat:1.0)) asDoubleArray
|
|
3789 |
((QDouble fromFloat:1.0) - 1.0) asDoubleArray
|
4380
|
3790 |
(1.0 - (QDouble fromFloat:1.0)) asDoubleArray
|
5308
|
3791 |
(1e-20 - (QDouble fromFloat:1.0)) asDoubleArray
|
4380
|
3792 |
(1e20 - (QDouble fromFloat:1.0)) asDoubleArray
|
5308
|
3793 |
"
|
4380
|
3794 |
!
|
|
3795 |
|
5339
|
3796 |
equalFromFloat:aFloat
|
|
3797 |
%{ /* NOCONTEXT */
|
|
3798 |
if (__isFloat(aFloat)) {
|
|
3799 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
3800 |
double b = __floatVal(aFloat);
|
|
3801 |
|
|
3802 |
RETURN ((a[0] == b
|
|
3803 |
&& a[1] == 0.0
|
|
3804 |
&& a[2] == 0.0
|
|
3805 |
&& a[3] == 0.0) ? true : false);
|
|
3806 |
}
|
|
3807 |
%}.
|
|
3808 |
^ (self d0 = aFloat)
|
|
3809 |
and:[ (self d1 = 0.0)
|
|
3810 |
and:[ (self d2 = 0.0)
|
|
3811 |
and:[ (self d3 = 0.0) ]]]
|
|
3812 |
|
|
3813 |
"
|
|
3814 |
(QDouble fromFloat:1.0) = 1.0
|
|
3815 |
(QDouble fromFloat:1.0) = 1.0
|
|
3816 |
1.0 = (QDouble fromFloat:1.0)
|
|
3817 |
1.1 = (QDouble fromFloat:1.0)
|
|
3818 |
1.1 = (QDouble fromFloat:1.1)
|
|
3819 |
"
|
|
3820 |
!
|
|
3821 |
|
4380
|
3822 |
equalFromQDouble:aQDouble
|
5339
|
3823 |
%{ /* NOCONTEXT */
|
4380
|
3824 |
if (__Class(aQDouble) == QDouble) {
|
5315
|
3825 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
3826 |
double *b = __QDoubleInstPtr(aQDouble)->d_qDoubleValue;
|
|
3827 |
|
|
3828 |
RETURN ((a[0] == b[0]
|
|
3829 |
&& a[1] == b[1]
|
|
3830 |
&& a[2] == b[2]
|
|
3831 |
&& a[3] == b[3]) ? true : false);
|
4380
|
3832 |
}
|
|
3833 |
%}.
|
4386
|
3834 |
^ (aQDouble d0 = self d0)
|
|
3835 |
and:[ (aQDouble d1 = self d1)
|
|
3836 |
and:[ (aQDouble d2 = self d2)
|
|
3837 |
and:[ (aQDouble d3 = self d3) ]]]
|
4395
|
3838 |
|
4380
|
3839 |
"
|
|
3840 |
(QDouble fromFloat:1.0) = (QDouble fromFloat:1.0)
|
|
3841 |
(QDouble fromFloat:1.0) = 1.0
|
5339
|
3842 |
1.0 = (QDouble fromFloat:1.0)
|
|
3843 |
1e20 = 1e20 asQDouble
|
|
3844 |
1e20 = (1e20 asQDouble + 1e-20)
|
4380
|
3845 |
"
|
|
3846 |
|
|
3847 |
"Created: / 13-06-2017 / 03:01:19 / cg"
|
4386
|
3848 |
"Modified: / 13-06-2017 / 18:01:52 / cg"
|
4380
|
3849 |
!
|
|
3850 |
|
5340
|
3851 |
lessFromFloat:aFloat
|
|
3852 |
|d0|
|
|
3853 |
|
|
3854 |
^ ((d0 := self d0) > aFloat)
|
|
3855 |
or:[ d0 = aFloat and:[ self d1 > 0.0 ]]
|
|
3856 |
|
|
3857 |
"
|
|
3858 |
1.0 < (1.0 asQDouble)
|
|
3859 |
1.0 < (1.1 asQDouble)
|
|
3860 |
-1.0 < (-1.1 asQDouble)
|
|
3861 |
-1.1 < (-1.0 asQDouble)
|
|
3862 |
"
|
|
3863 |
!
|
|
3864 |
|
4385
|
3865 |
lessFromQDouble:aQDouble
|
|
3866 |
"sent when aQDouble does not know how to compare to the receiver..
|
|
3867 |
Return true if aQDouble < self"
|
4380
|
3868 |
|
4385
|
3869 |
%{
|
|
3870 |
if (__Class(aQDouble) == QDouble) {
|
5315
|
3871 |
double *a = __QDoubleInstPtr(aQDouble)->d_qDoubleValue;
|
|
3872 |
double *b = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
3873 |
|
|
3874 |
// now compare if a < b!
|
|
3875 |
RETURN
|
|
3876 |
((a[0] < b[0] ||
|
|
3877 |
(a[0] == b[0] && (a[1] < b[1] ||
|
|
3878 |
(a[1] == b[1] && (a[2] < b[2] ||
|
|
3879 |
(a[2] == b[2] && a[3] < b[3])))))) ? true : false);
|
4380
|
3880 |
}
|
|
3881 |
%}.
|
4385
|
3882 |
^ super lessFromQDouble:aQDouble
|
4380
|
3883 |
|
|
3884 |
"
|
4385
|
3885 |
(1.0 + 1e-40) > 1.0
|
|
3886 |
((QDouble fromFloat:1.0) + (QDouble fromFloat:1e-40)) > (QDouble fromFloat:1.0)
|
4380
|
3887 |
|
4385
|
3888 |
(QDouble fromFloat:1.0) > (QDouble fromFloat:1.0)
|
|
3889 |
(QDouble fromFloat:1.1) > (QDouble fromFloat:1.0)
|
|
3890 |
(QDouble fromFloat:1.0) > 1.0
|
|
3891 |
(QDouble fromFloat:1.1) > 1.0
|
|
3892 |
1.0 > (QDouble fromFloat:1.0)
|
|
3893 |
"
|
|
3894 |
|
|
3895 |
"Created: / 13-06-2017 / 17:07:47 / cg"
|
4380
|
3896 |
!
|
|
3897 |
|
|
3898 |
productFromFloat:aFloat
|
|
3899 |
%{
|
|
3900 |
if (__isFloatLike(aFloat)) {
|
5315
|
3901 |
double a = __floatVal(aFloat);
|
|
3902 |
double *b = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
3903 |
double c0, c1, c2, c3;
|
|
3904 |
OBJ newQD;
|
|
3905 |
int savedCV;
|
|
3906 |
|
|
3907 |
fpu_fix_start(&savedCV);
|
|
3908 |
s_mul_qd(&c0, &c1, &c2, &c3, a, b[0], b[1], b[2], b[3]);
|
|
3909 |
fpu_fix_end(&savedCV);
|
|
3910 |
__qNew_qdReal(newQD, c0, c1, c2, c3);
|
|
3911 |
RETURN( newQD );
|
4380
|
3912 |
}
|
|
3913 |
%}.
|
|
3914 |
^ super productFromFloat:aFloat.
|
|
3915 |
|
|
3916 |
"
|
4421
|
3917 |
loosing bits here:
|
4981
|
3918 |
|
5308
|
3919 |
(1e20+1.0)*2.0 - 2E20 -> 0.0
|
|
3920 |
(1e20+1.0)*100.0 - 1E+22 -> 0.0
|
|
3921 |
(1e20+1.0)*1000.0 - 1E+23 -> 0.0
|
|
3922 |
(1e20+1.0)*1e20 - 1E+40 -> 0.0
|
|
3923 |
(1e40+1.0)*2.0 - 2E+40 -> 0.0
|
4421
|
3924 |
|
|
3925 |
but not here:
|
|
3926 |
|
5308
|
3927 |
((1e20 asQDouble) + (1.0)) * 2.0 - 2E20 -> 2.0
|
5309
|
3928 |
((1e20 asQDouble) + (1.0)) * 100.0 - 1E+22 -> 100.0
|
5308
|
3929 |
((1e20 asQDouble) + (1.0)) * 1000.0 - 1E+23 -> 8389608.0 WRONG
|
|
3930 |
((1e20 asQDouble) + (1.0)) * 1e20 - 1E+40 ->
|
|
3931 |
((1e40 asQDouble) + (1.0)) * 2.0 - 2E+40 ->
|
4387
|
3932 |
|
4380
|
3933 |
2.0 * (QDouble fromFloat:1.0)
|
4387
|
3934 |
2.0 * (QDouble fromFloat:3.0)
|
4421
|
3935 |
(QDouble fromFloat:2.0) * (QDouble fromFloat:3.0)
|
4981
|
3936 |
|
4421
|
3937 |
QDouble ln2 DoubleArray(0.693147180559945 2.3190468138463E-17 5.70770843841621E-34 -3.58243221060181E-50)
|
|
3938 |
2.0 * QDouble ln2 DoubleArray(1.38629436111989 4.6380936276926E-17 1.14154168768324E-33 -7.16486442120362E-50)
|
4981
|
3939 |
QDouble ln2 * 2.0
|
|
3940 |
|
4421
|
3941 |
2.0 * ((QDouble fromFloat:1e20) + (QDouble fromFloat:1.0)) DoubleArray(2E+20 2.0 0.0 0.0)
|
|
3942 |
((QDouble fromFloat:1e20) + (QDouble fromFloat:1.0)) * 2.0 DoubleArray(2E+20 4E+20 0.0 0.0)
|
|
3943 |
((QDouble fromFloat:1e20) + (QDouble fromFloat:1.0)) * (QDouble fromFloat:2.0) DoubleArray(2E+20 4E+20 0.0 0.0)
|
|
3944 |
(QDouble fromFloat:2.0) * ((QDouble fromFloat:1e20) + (QDouble fromFloat:1.0)) DoubleArray(2E+20 4E+20 0.0 0.0)
|
4981
|
3945 |
|
4387
|
3946 |
(2.0 * ((QDouble fromFloat:1e20) + (QDouble fromFloat:1.0))) - (QDouble fromFloat:1e20) - (QDouble fromFloat:1e20)
|
|
3947 |
|
4380
|
3948 |
(2.0 * (QDouble fromFloat:1.0)) asFloat
|
|
3949 |
(1e20 * (QDouble fromFloat:1.0)) asFloat
|
|
3950 |
|
|
3951 |
(1e20 * (QDouble fromFloat:1.0) * 1e-20) asDoubleArray
|
|
3952 |
"
|
|
3953 |
|
|
3954 |
"Created: / 13-06-2017 / 00:58:56 / cg"
|
4421
|
3955 |
"Modified: / 19-06-2017 / 16:48:18 / cg"
|
|
3956 |
"Modified (comment): / 19-06-2017 / 18:11:43 / cg"
|
4380
|
3957 |
!
|
|
3958 |
|
|
3959 |
productFromQDouble:aQDouble
|
|
3960 |
%{
|
5308
|
3961 |
if (__isQDouble(aQDouble)) {
|
5315
|
3962 |
double *a = __QDoubleInstPtr(aQDouble)->d_qDoubleValue;
|
|
3963 |
double *b = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
3964 |
double c0, c1, c2, c3;
|
|
3965 |
OBJ newQD;
|
|
3966 |
int savedCV;
|
|
3967 |
|
|
3968 |
fpu_fix_start(&savedCV);
|
|
3969 |
qd_mul_qd(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
|
|
3970 |
fpu_fix_end(&savedCV);
|
|
3971 |
__qNew_qdReal(newQD, c0, c1, c2, c3);
|
|
3972 |
RETURN( newQD );
|
4380
|
3973 |
}
|
|
3974 |
%}.
|
|
3975 |
^ super productFromQDouble:aQDouble.
|
|
3976 |
|
|
3977 |
"
|
4387
|
3978 |
(QDouble fromFloat:1.0) * 2.0
|
4380
|
3979 |
2.0 * (QDouble fromFloat:1.0)
|
4387
|
3980 |
(QDouble fromFloat:1.0) * (QDouble fromFloat:2.0)
|
|
3981 |
|
5308
|
3982 |
1e20 * (QDouble fromFloat:2.0)
|
|
3983 |
2.0 * (QDouble fromFloat:1e20)
|
|
3984 |
(QDouble fromFloat:1e20) * (QDouble fromFloat:1e20)
|
4380
|
3985 |
|
|
3986 |
(1e20 * (QDouble fromFloat:1.0) * 1e-20) asDoubleArray
|
4392
|
3987 |
|
|
3988 |
( ((QDouble fromFloat:1.0) + (QDouble fromFloat:1e20)) * (QDouble fromFloat:2.0)) asDoubleArray
|
4380
|
3989 |
"
|
|
3990 |
|
|
3991 |
"Created: / 13-06-2017 / 01:06:22 / cg"
|
4454
|
3992 |
"Modified: / 05-07-2017 / 11:07:16 / cg"
|
4380
|
3993 |
!
|
|
3994 |
|
5308
|
3995 |
quotientFromFloat:aFloat
|
|
3996 |
%{
|
|
3997 |
if (__isFloatLike(aFloat)) {
|
5315
|
3998 |
double a = __floatVal(aFloat);
|
|
3999 |
double *b = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
4000 |
double c0, c1, c2, c3;
|
|
4001 |
OBJ newQD;
|
|
4002 |
int savedCV;
|
|
4003 |
|
|
4004 |
fpu_fix_start(&savedCV);
|
|
4005 |
s_div_qd(&c0, &c1, &c2, &c3, a, b[0], b[1], b[2], b[3]);
|
|
4006 |
fpu_fix_end(&savedCV);
|
|
4007 |
__qNew_qdReal(newQD, c0, c1, c2, c3);
|
|
4008 |
RETURN( newQD );
|
5308
|
4009 |
}
|
|
4010 |
%}.
|
|
4011 |
^ super quotientFromFloat:aFloat.
|
4380
|
4012 |
|
|
4013 |
"
|
4385
|
4014 |
2.0 / (QDouble fromFloat:2.0)
|
4387
|
4015 |
2.0 / (QDouble fromFloat:1.0)
|
4385
|
4016 |
1e20 / (QDouble fromFloat:1.0)
|
5308
|
4017 |
1e20 / (QDouble fromFloat:2.0)
|
5304
|
4018 |
(2.0 / (QDouble fromFloat:1.0)) asFloat
|
|
4019 |
(1e20 / (QDouble fromFloat:1.0)) asFloat
|
|
4020 |
|
|
4021 |
(QDouble fromFloat:2.0) / 2.0
|
|
4022 |
(QDouble fromFloat:1e20) / 2.0
|
|
4023 |
((QDouble fromFloat:1.0) / 2.0) asFloat
|
|
4024 |
((QDouble fromFloat:1e20 / 2.0)) asFloat
|
|
4025 |
|
|
4026 |
((1e20 + (QDouble fromFloat:1.0) + 1e-20) / 2.0) asDoubleArray
|
|
4027 |
|
|
4028 |
((QDouble fromFloat:10.0) quotientFromQDouble: (QDouble fromFloat:1.234)) asDoubleArray
|
|
4029 |
((QDouble fromFloat:1.234) / (QDouble fromFloat:10.0)) asDoubleArray
|
|
4030 |
"
|
5308
|
4031 |
|
|
4032 |
"Created: / 13-06-2017 / 17:50:35 / cg"
|
|
4033 |
"Modified (comment): / 15-06-2017 / 01:02:05 / cg"
|
5304
|
4034 |
!
|
|
4035 |
|
5308
|
4036 |
quotientFromQDouble:aQDouble
|
|
4037 |
%{
|
|
4038 |
if (__isQDouble(aQDouble)) {
|
5315
|
4039 |
double *a = __QDoubleInstPtr(aQDouble)->d_qDoubleValue;
|
|
4040 |
double *b = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
4041 |
double c0, c1, c2, c3;
|
|
4042 |
OBJ newQD;
|
|
4043 |
int savedCV;
|
|
4044 |
|
|
4045 |
fpu_fix_start(&savedCV);
|
|
4046 |
qd_div_qd(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
|
|
4047 |
fpu_fix_end(&savedCV);
|
|
4048 |
__qNew_qdReal(newQD, c0, c1, c2, c3);
|
|
4049 |
RETURN( newQD );
|
5308
|
4050 |
}
|
|
4051 |
%}.
|
|
4052 |
^ super quotientFromQDouble:aQDouble.
|
5304
|
4053 |
|
|
4054 |
"
|
|
4055 |
2.0 / (QDouble fromFloat:2.0)
|
|
4056 |
2.0 / (QDouble fromFloat:1.0)
|
|
4057 |
1e20 / (QDouble fromFloat:1.0)
|
5308
|
4058 |
1e20 / (QDouble fromFloat:2.0)
|
5304
|
4059 |
(2.0 / (QDouble fromFloat:1.0)) asFloat
|
|
4060 |
(1e20 / (QDouble fromFloat:1.0)) asFloat
|
|
4061 |
|
|
4062 |
(QDouble fromFloat:2.0) / 2.0
|
|
4063 |
(QDouble fromFloat:1e20) / 2.0
|
|
4064 |
((QDouble fromFloat:1.0) / 2.0) asFloat
|
|
4065 |
((QDouble fromFloat:1e20 / 2.0)) asFloat
|
|
4066 |
|
|
4067 |
((1e20 + (QDouble fromFloat:1.0) + 1e-20) / 2.0) asDoubleArray
|
|
4068 |
|
|
4069 |
((QDouble fromFloat:10.0) quotientFromQDouble: (QDouble fromFloat:1.234)) asDoubleArray
|
|
4070 |
((QDouble fromFloat:1.234) / (QDouble fromFloat:10.0)) asDoubleArray
|
|
4071 |
"
|
|
4072 |
|
|
4073 |
"Created: / 13-06-2017 / 17:50:35 / cg"
|
|
4074 |
"Modified (comment): / 15-06-2017 / 01:02:05 / cg"
|
|
4075 |
!
|
|
4076 |
|
4380
|
4077 |
sumFromFloat:aFloat
|
|
4078 |
%{
|
|
4079 |
if (__isFloatLike(aFloat)) {
|
5315
|
4080 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
4081 |
double b = __floatVal(aFloat);
|
|
4082 |
double c0, c1, c2, c3;
|
|
4083 |
double e;
|
|
4084 |
OBJ newQD;
|
|
4085 |
int savedCV;
|
|
4086 |
|
|
4087 |
fpu_fix_start(&savedCV);
|
|
4088 |
qd_add_s(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b);
|
|
4089 |
fpu_fix_end(&savedCV);
|
|
4090 |
__qNew_qdReal(newQD, c0, c1, c2, c3);
|
|
4091 |
RETURN( newQD );
|
4380
|
4092 |
}
|
|
4093 |
%}.
|
|
4094 |
^ super sumFromFloat:aFloat.
|
|
4095 |
|
|
4096 |
"
|
|
4097 |
1.0 + (QDouble fromFloat:1.0)
|
|
4098 |
1e20 + (QDouble fromFloat:1.0)
|
|
4099 |
(1.0 + (QDouble fromFloat:1.0)) asFloat
|
|
4100 |
(1e20 + (QDouble fromFloat:1.0)) asFloat
|
|
4101 |
|
|
4102 |
(1.0 + (QDouble fromFloat:1.0)) asDoubleArray
|
|
4103 |
(1e20 + (QDouble fromFloat:1.0)) asDoubleArray
|
|
4104 |
(1e20 + (QDouble fromFloat:1.0) + 1e-20) asDoubleArray
|
|
4105 |
"
|
|
4106 |
|
|
4107 |
"Created: / 12-06-2017 / 17:16:41 / cg"
|
4387
|
4108 |
"Modified: / 14-06-2017 / 11:43:47 / cg"
|
4380
|
4109 |
!
|
|
4110 |
|
4454
|
4111 |
sumFromInteger:anInteger
|
|
4112 |
^ self sumFromFloat:(anInteger asFloat)
|
|
4113 |
|
|
4114 |
"
|
|
4115 |
1 + (QDouble fromFloat:1.0)
|
|
4116 |
1e20 asInteger + (QDouble fromFloat:1.0)
|
|
4117 |
(1 + (QDouble fromFloat:1.0)) asFloat
|
|
4118 |
(1e20 asInteger + (QDouble fromFloat:1.0)) asFloat
|
|
4119 |
"
|
|
4120 |
|
|
4121 |
"Created: / 03-07-2017 / 10:35:46 / cg"
|
|
4122 |
!
|
|
4123 |
|
4380
|
4124 |
sumFromQDouble:aQDouble
|
|
4125 |
%{
|
5308
|
4126 |
if (__isQDouble(aQDouble)) {
|
5315
|
4127 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
4128 |
double *b = __QDoubleInstPtr(aQDouble)->d_qDoubleValue;
|
|
4129 |
double c0, c1, c2, c3;
|
|
4130 |
OBJ newQD;
|
|
4131 |
int savedCV;
|
|
4132 |
|
|
4133 |
fpu_fix_start(&savedCV);
|
|
4134 |
qd_add_qd(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
|
|
4135 |
fpu_fix_end(&savedCV);
|
|
4136 |
__qNew_qdReal(newQD, c0, c1, c2, c3);
|
|
4137 |
RETURN( newQD );
|
4380
|
4138 |
}
|
|
4139 |
%}.
|
|
4140 |
^ super sumFromQDouble:aQDouble
|
4395
|
4141 |
|
4380
|
4142 |
"
|
|
4143 |
(QDouble fromFloat:1.0) + (QDouble fromFloat:1.0)
|
|
4144 |
(QDouble fromFloat:1.0) + 1.0
|
|
4145 |
1.0 + (QDouble fromFloat:1.0)
|
|
4146 |
|
|
4147 |
((QDouble fromFloat:1.0) + (QDouble fromFloat:1.0)) asDoubleArray
|
|
4148 |
((QDouble fromFloat:1.0) + 1.0) asDoubleArray
|
|
4149 |
(1.0 + (QDouble fromFloat:1.0)) asDoubleArray
|
|
4150 |
(1e-20 + (QDouble fromFloat:1.0)) asDoubleArray
|
|
4151 |
(1e20 + (QDouble fromFloat:1.0)) asDoubleArray
|
|
4152 |
"
|
|
4153 |
|
|
4154 |
"Created: / 12-06-2017 / 21:15:43 / cg"
|
4454
|
4155 |
"Modified: / 03-07-2017 / 23:09:11 / cg"
|
4380
|
4156 |
! !
|
|
4157 |
|
|
4158 |
|
4385
|
4159 |
!QDouble methodsFor:'mathematical functions'!
|
|
4160 |
|
5308
|
4161 |
cos
|
|
4162 |
|
|
4163 |
%{
|
|
4164 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
4165 |
double q0, q1, q2, q3;
|
|
4166 |
OBJ newQD;
|
|
4167 |
int savedCV;
|
|
4168 |
|
|
4169 |
fpu_fix_start(&savedCV);
|
5312
|
4170 |
qd_cos(&q0, &q1, &q2, &q3, &a[0], &a[1], &a[2], &a[3]);
|
5308
|
4171 |
fpu_fix_end(&savedCV);
|
|
4172 |
__qNew_qdReal(newQD, q0, q1, q2, q3);
|
|
4173 |
RETURN( newQD );
|
|
4174 |
%}.
|
4981
|
4175 |
|
4440
|
4176 |
"
|
5309
|
4177 |
1.0 cos
|
|
4178 |
(QDouble fromFloat:1.0) cos
|
5308
|
4179 |
"
|
4440
|
4180 |
!
|
|
4181 |
|
5308
|
4182 |
exp
|
|
4183 |
|
|
4184 |
%{
|
|
4185 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
4186 |
double q0, q1, q2, q3;
|
|
4187 |
OBJ newQD;
|
|
4188 |
int savedCV;
|
|
4189 |
|
|
4190 |
fpu_fix_start(&savedCV);
|
5315
|
4191 |
qd_exp(&q0, &q1, &q2, &q3, a[0], a[1], a[2], a[3]);
|
5308
|
4192 |
fpu_fix_end(&savedCV);
|
|
4193 |
__qNew_qdReal(newQD, q0, q1, q2, q3);
|
|
4194 |
RETURN( newQD );
|
|
4195 |
%}.
|
4412
|
4196 |
|
|
4197 |
"
|
5309
|
4198 |
1.0 exp
|
|
4199 |
(QDouble fromFloat:1.0) exp
|
5313
|
4200 |
|
|
4201 |
3.0 exp
|
|
4202 |
(QDouble fromFloat:3.0) exp
|
4412
|
4203 |
"
|
4454
|
4204 |
!
|
|
4205 |
|
5270
|
4206 |
ldexp:exp
|
|
4207 |
"multiply the receiver by an integral power of 2.
|
5288
|
4208 |
I.e. return self * (2 ^ exp).
|
|
4209 |
This is also the operation to reconstruct the original float from its
|
|
4210 |
mantissa and exponent: (f mantissa ldexp:f exponent) = f"
|
5270
|
4211 |
|
|
4212 |
^ self class
|
5315
|
4213 |
d0:(self d0 ldexp:exp)
|
|
4214 |
d1:(self d1 ldexp:exp)
|
|
4215 |
d2:(self d2 ldexp:exp)
|
|
4216 |
d3:(self d3 ldexp:exp)
|
5270
|
4217 |
"
|
5308
|
4218 |
|f| f := 1 asQDouble. (f mantissa ldexp:f exponent) -> 1.0
|
|
4219 |
|f| f := (1e40 asQDouble + 1e-40). (f mantissa ldexp:f exponent) -> (1e40 asQDouble + 1e-40)
|
5288
|
4220 |
|
5270
|
4221 |
1.0 ldexp:16 -> 65536.0
|
|
4222 |
1.0 asQDouble ldexp:16 -> 65536.0
|
|
4223 |
1.0 ldexp:100 -> 1.26765060022823E+30
|
|
4224 |
1.0 asQDouble ldexp:100 -> 1.26765060022823E+30
|
|
4225 |
"
|
|
4226 |
|
|
4227 |
"Created: / 19-06-2017 / 01:43:35 / cg"
|
|
4228 |
!
|
|
4229 |
|
4411
|
4230 |
ln
|
4442
|
4231 |
"return the natural logarithm of myself.
|
4445
|
4232 |
Raises an exception, if the receiver is less or equal to zero.
|
|
4233 |
|
|
4234 |
Not sure if this is really faster than using a taylor right away:
|
|
4235 |
the three exp-computations at the end are done in qDouble and are tailors themself..."
|
4442
|
4236 |
|
4412
|
4237 |
|d0 x|
|
|
4238 |
|
5306
|
4239 |
"/ ^ super ln.
|
4981
|
4240 |
|
4412
|
4241 |
d0 := self d0.
|
|
4242 |
d0 = 1.0 ifTrue:[
|
5315
|
4243 |
"/ note: d0 checking alone is not sufficient - there could still be more in d1...
|
|
4244 |
self isOne ifTrue:[ ^ self class zero ].
|
4412
|
4245 |
].
|
4454
|
4246 |
d0 > 0.0 ifTrue:[
|
5315
|
4247 |
"/ initial approx.
|
|
4248 |
x := d0 ln asQDouble.
|
|
4249 |
"/ three more iterations of newton...
|
|
4250 |
x := x + (self * (x negated exp)) - 1.0.
|
|
4251 |
x := x + (self * (x negated exp)) - 1.0.
|
|
4252 |
x := x + (self * (x negated exp)) - 1.0.
|
|
4253 |
|
|
4254 |
^ x
|
4412
|
4255 |
].
|
4981
|
4256 |
|
4454
|
4257 |
"/ now done via trapInfinity; was:
|
|
4258 |
"/ d0 = 0.0 ifTrue:[
|
|
4259 |
"/ ^ Infinity negative
|
|
4260 |
"/ ].
|
|
4261 |
|
|
4262 |
"/ if you need -INF for a zero receiver, try Number trapInfinity:[...]
|
|
4263 |
^ self class
|
5315
|
4264 |
raise:(self = 0 ifTrue:[#infiniteResultSignal] ifFalse:[#domainErrorSignal])
|
|
4265 |
receiver:self
|
|
4266 |
selector:#ln
|
|
4267 |
arguments:#()
|
|
4268 |
errorString:'bad receiver in ln (not strictly positive)'
|
|
4269 |
|
|
4270 |
"
|
|
4271 |
inaccurate:
|
|
4272 |
(1e-100 asQDouble log10 + 100.0) < (2*QDouble epsilon).
|
|
4273 |
|
4412
|
4274 |
-1 ln
|
4442
|
4275 |
|
4454
|
4276 |
-1.0 asQDouble ln
|
|
4277 |
0.0 asQDouble ln
|
4411
|
4278 |
1.0 asQDouble ln
|
5314
|
4279 |
0.5 ln
|
|
4280 |
0.5 asQDouble ln
|
4442
|
4281 |
|
4981
|
4282 |
3.0 ln printfPrintString:'%60.58lf'
|
5315
|
4283 |
-> 1.0986122886681097821082175869378261268138885498046875000000'
|
|
4284 |
^
|
4981
|
4285 |
|
|
4286 |
3.0 asQDouble ln printfPrintString:'%60.58f'
|
5315
|
4287 |
-> 1.0986122886681096913952452369225257046474905578227494517347
|
4981
|
4288 |
|
|
4289 |
3.0 asQDouble ln printfPrintString:'%70.68f'
|
5315
|
4290 |
-> 1.09861228866810969139524523692252570464749055782274945173469433364779
|
4443
|
4291 |
|
|
4292 |
(3.0 asQDouble ln_withAccuracy:1e-64) printfPrintString:'%70.68f'
|
5315
|
4293 |
1.09861228866810969139524523692252570464749055782274945173469433364475
|
4443
|
4294 |
(3.0 asQDouble ln_withAccuracy:1e-100) printfPrintString:'%70.68f'
|
5315
|
4295 |
'1.098612288668109691395245236922525704647490557822749451734694333656909'
|
4442
|
4296 |
|
|
4297 |
actual result:
|
5315
|
4298 |
-> 1.0986122886681096913952452369225257046474905578227494517346943336374942932186089668736157548137320887879700290659...
|
4411
|
4299 |
"
|
|
4300 |
|
|
4301 |
"Created: / 18-06-2017 / 23:32:54 / cg"
|
4454
|
4302 |
"Modified: / 04-07-2017 / 11:46:27 / cg"
|
4411
|
4303 |
!
|
|
4304 |
|
4385
|
4305 |
negated
|
4395
|
4306 |
^ self class
|
5315
|
4307 |
d0:(self d0) negated
|
|
4308 |
d1:(self d1) negated
|
|
4309 |
d2:(self d2) negated
|
|
4310 |
d3:(self d3) negated
|
4395
|
4311 |
|
|
4312 |
"
|
4385
|
4313 |
(QDouble fromFloat:1.0) negated
|
|
4314 |
((QDouble fromFloat:1e20) + (QDouble fromFloat:1.0)) negated asDoubleArray
|
|
4315 |
|
|
4316 |
(((QDouble fromFloat:1e20) + (QDouble fromFloat:1.0))
|
|
4317 |
+ ((QDouble fromFloat:1e20) + (QDouble fromFloat:1.0))) asDoubleArray
|
|
4318 |
"
|
|
4319 |
|
|
4320 |
"Created: / 12-06-2017 / 20:14:55 / cg"
|
|
4321 |
"Modified (comment): / 12-06-2017 / 23:46:57 / cg"
|
|
4322 |
!
|
|
4323 |
|
5308
|
4324 |
raisedToInteger:n
|
|
4325 |
|
|
4326 |
%{
|
|
4327 |
if (__isSmallInteger(n)) {
|
5315
|
4328 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
4329 |
double q0, q1, q2, q3;
|
|
4330 |
OBJ newQD;
|
|
4331 |
int savedCV;
|
|
4332 |
|
|
4333 |
fpu_fix_start(&savedCV);
|
|
4334 |
qd_pow(&q0, &q1, &q2, &q3, a[0], a[1], a[2], a[3], __intVal(n));
|
|
4335 |
fpu_fix_end(&savedCV);
|
|
4336 |
__qNew_qdReal(newQD, q0, q1, q2, q3);
|
|
4337 |
RETURN( newQD );
|
5308
|
4338 |
}
|
|
4339 |
%}.
|
|
4340 |
^ super raisedToInteger:n.
|
|
4341 |
|
|
4342 |
"
|
5309
|
4343 |
(QDouble fromFloat:4.0) raisedToInteger:4
|
|
4344 |
(QDouble fromFloat:10.0) raisedToInteger:10
|
|
4345 |
(QDouble fromFloat:10.0000000000001) raisedToInteger:10
|
|
4346 |
10.0000000000001 raisedToInteger:10
|
5308
|
4347 |
"
|
|
4348 |
!
|
|
4349 |
|
|
4350 |
sin
|
|
4351 |
|
|
4352 |
%{
|
|
4353 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
4354 |
double q0, q1, q2, q3;
|
|
4355 |
OBJ newQD;
|
|
4356 |
int savedCV;
|
|
4357 |
|
|
4358 |
fpu_fix_start(&savedCV);
|
5312
|
4359 |
qd_sin(&q0, &q1, &q2, &q3, &a[0], &a[1], &a[2], &a[3]);
|
5308
|
4360 |
fpu_fix_end(&savedCV);
|
|
4361 |
__qNew_qdReal(newQD, q0, q1, q2, q3);
|
|
4362 |
RETURN( newQD );
|
|
4363 |
%}.
|
|
4364 |
|
|
4365 |
"
|
5309
|
4366 |
1.0 sin
|
|
4367 |
(QDouble fromFloat:1.0) sin
|
5308
|
4368 |
"
|
|
4369 |
!
|
|
4370 |
|
4442
|
4371 |
sqrt
|
|
4372 |
"Return the square root of the receiver"
|
|
4373 |
|
5308
|
4374 |
%{
|
|
4375 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
4376 |
double q0, q1, q2, q3;
|
|
4377 |
OBJ newQD;
|
|
4378 |
int savedCV;
|
|
4379 |
|
|
4380 |
fpu_fix_start(&savedCV);
|
5312
|
4381 |
qd_sqrt(&q0, &q1, &q2, &q3, a[0], a[1], a[2], a[3]);
|
5308
|
4382 |
fpu_fix_end(&savedCV);
|
|
4383 |
__qNew_qdReal(newQD, q0, q1, q2, q3);
|
|
4384 |
RETURN( newQD );
|
|
4385 |
%}.
|
|
4386 |
|
|
4387 |
"
|
5309
|
4388 |
(QDouble fromFloat:4.0) sqrt
|
|
4389 |
(QDouble fromFloat:2.0) sqrt
|
5308
|
4390 |
(QDouble fromFloat:1e20) sqrt
|
|
4391 |
"
|
4442
|
4392 |
!
|
|
4393 |
|
4385
|
4394 |
squared
|
4442
|
4395 |
"return receiver * receiver"
|
|
4396 |
|
4385
|
4397 |
%{
|
5308
|
4398 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
4385
|
4399 |
double q0, q1, q2, q3;
|
|
4400 |
OBJ newQD;
|
5308
|
4401 |
int savedCV;
|
|
4402 |
|
|
4403 |
fpu_fix_start(&savedCV);
|
|
4404 |
qd_sqr(&q0, &q1, &q2, &q3, a[0], a[1], a[2], a[3]);
|
|
4405 |
fpu_fix_end(&savedCV);
|
|
4406 |
__qNew_qdReal(newQD, q0, q1, q2, q3);
|
4385
|
4407 |
RETURN( newQD );
|
|
4408 |
%}.
|
|
4409 |
|
|
4410 |
"
|
|
4411 |
(QDouble fromFloat:4.0) squared
|
4395
|
4412 |
(1e20 + (QDouble fromFloat:1.0)) squared
|
4385
|
4413 |
"
|
|
4414 |
|
|
4415 |
"Created: / 13-06-2017 / 01:27:58 / cg"
|
4442
|
4416 |
"Modified: / 22-06-2017 / 14:08:31 / cg"
|
5308
|
4417 |
!
|
|
4418 |
|
|
4419 |
tan
|
|
4420 |
|
|
4421 |
%{
|
|
4422 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
|
4423 |
double q0, q1, q2, q3;
|
|
4424 |
OBJ newQD;
|
|
4425 |
int savedCV;
|
|
4426 |
|
|
4427 |
fpu_fix_start(&savedCV);
|
5312
|
4428 |
qd_tan(&q0, &q1, &q2, &q3, &a[0], &a[1], &a[2], &a[3]);
|
5308
|
4429 |
fpu_fix_end(&savedCV);
|
|
4430 |
__qNew_qdReal(newQD, q0, q1, q2, q3);
|
|
4431 |
RETURN( newQD );
|
|
4432 |
%}.
|
|
4433 |
|
|
4434 |
"
|
5309
|
4435 |
1.0 tan
|
|
4436 |
(QDouble fromFloat:1.0) tan
|
5308
|
4437 |
"
|
4385
|
4438 |
! !
|
|
4439 |
|
4380
|
4440 |
!QDouble methodsFor:'printing & storing'!
|
|
4441 |
|
4393
|
4442 |
digitsWithPrecision:precision
|
4454
|
4443 |
<resource: #obsolete>
|
4395
|
4444 |
"generate digits and exponent.
|
|
4445 |
if precision is >0, that many digits are generated.
|
|
4446 |
If it is 0 the required number of digits is generated
|
|
4447 |
(but never more than the decimalPrecision, which is 65)"
|
|
4448 |
|
4393
|
4449 |
|numDigits r exp i d out str|
|
|
4450 |
|
|
4451 |
numDigits := precision+1. "/ number of digits
|
|
4452 |
r := self abs.
|
|
4453 |
self d0 = 0.0 ifTrue:[
|
5315
|
4454 |
^ { String new:(precision max:1) withAll:$0 . 0 }
|
4393
|
4455 |
].
|
|
4456 |
|
|
4457 |
out := WriteStream on:(String new:precision+5).
|
|
4458 |
|
|
4459 |
"/ determine approx. exponent
|
|
4460 |
exp := self d0 abs log10 floor.
|
|
4461 |
exp < -300 ifTrue:[
|
5315
|
4462 |
"/ 1e-305 asQDouble
|
|
4463 |
r := r * (10.0 raisedToInteger:300).
|
|
4464 |
r := r / (10.0 raisedToInteger:(exp+300)).
|
4393
|
4465 |
] ifFalse:[
|
5315
|
4466 |
exp > 300 ifTrue:[
|
|
4467 |
"/ 1e305 asQDouble
|
|
4468 |
"/ lexpr(x,exp) = x * 2 ^ exp
|
4393
|
4469 |
self halt.
|
5315
|
4470 |
r := r * (2 raisedTo:-53).
|
|
4471 |
r := r / (10.0 asQDouble raisedTo: exp).
|
|
4472 |
r := r * (2 raisedTo:53).
|
|
4473 |
] ifFalse:[
|
|
4474 |
r := r / (10.0 asQDouble raisedTo:exp).
|
|
4475 |
]
|
4393
|
4476 |
].
|
|
4477 |
|
|
4478 |
"/ Fix exponent if we are off by one
|
|
4479 |
(r >= 10.0) ifTrue:[
|
5315
|
4480 |
r := r / 10.0.
|
|
4481 |
exp := exp + 1.
|
4393
|
4482 |
] ifFalse:[
|
5315
|
4483 |
(r < 1.0) ifTrue:[
|
|
4484 |
r := r * 10.0.
|
|
4485 |
exp := exp - 1.
|
|
4486 |
]
|
4393
|
4487 |
].
|
|
4488 |
|
|
4489 |
((r >= 10.0) or:[ r < 1.0 ]) ifTrue:[
|
5315
|
4490 |
self error:'can''t compute exponent.'.
|
4393
|
4491 |
].
|
|
4492 |
|
4395
|
4493 |
"/
|
4393
|
4494 |
"/ Extract the digits
|
4395
|
4495 |
"/ notice, that the d1,d2 and d3 components might
|
|
4496 |
"/ be negative; therefore characters out of the 0..9 range
|
|
4497 |
"/ might be produced here
|
|
4498 |
"/
|
|
4499 |
i := 1.
|
|
4500 |
[ (precision ~~ 0 and:[ i <= numDigits ])
|
|
4501 |
or:[ (precision == 0 and:[r d0 ~= 0.0]) ]] whileTrue:[
|
5315
|
4502 |
d := r d0 truncated.
|
|
4503 |
r := r - d.
|
|
4504 |
r := r * 10.0.
|
|
4505 |
|
|
4506 |
out nextPut:($0 + d).
|
|
4507 |
i := i + 1.
|
4393
|
4508 |
].
|
4395
|
4509 |
numDigits := i-1.
|
4393
|
4510 |
|
|
4511 |
str := out contents.
|
4395
|
4512 |
|
4393
|
4513 |
"/ Fix out-of-range digits.
|
4395
|
4514 |
numDigits to:2 by:-1 do:[:i |
|
5315
|
4515 |
(str at:i) < $0 ifTrue:[
|
|
4516 |
str at:i-1 put:(str at:i-1) - 1.
|
|
4517 |
str at:i put:(str at:i) + 10.
|
|
4518 |
] ifFalse:[
|
|
4519 |
(str at:i) > $9 ifTrue:[
|
|
4520 |
str at:i-1 put:(str at:i-1) + 1.
|
|
4521 |
str at:i put:(str at:i) - 10.
|
|
4522 |
].
|
|
4523 |
].
|
4393
|
4524 |
].
|
|
4525 |
|
4395
|
4526 |
str first <= $0 ifTrue:[
|
5315
|
4527 |
self error:'non-positive leading digit'
|
4395
|
4528 |
].
|
|
4529 |
|
|
4530 |
"/ Round, handle carry
|
4393
|
4531 |
(str at:numDigits) >= $5 ifTrue:[
|
5315
|
4532 |
str at:numDigits-1 put:(str at:numDigits-1) + 1.
|
|
4533 |
i := numDigits-1.
|
|
4534 |
[i > 1 and:[(str at:i) > $9]] whileTrue:[
|
|
4535 |
str at:i put:(str at:i) - 10.
|
|
4536 |
i := i - 1.
|
|
4537 |
str at:i put:(str at:i) + 1.
|
|
4538 |
]
|
4395
|
4539 |
].
|
4393
|
4540 |
|
|
4541 |
"/ If first digit is 10, shift everything.
|
4395
|
4542 |
str first > $9 ifTrue:[
|
5315
|
4543 |
exp := exp + 1.
|
|
4544 |
str at:1 put:$0.
|
|
4545 |
str := '1',str
|
4395
|
4546 |
].
|
|
4547 |
^ { (str copyTo:numDigits-1) . exp }
|
|
4548 |
|
4393
|
4549 |
"
|
4395
|
4550 |
0 asQDouble digitsWithPrecision:1 -> #('0' 0)
|
|
4551 |
0 asQDouble digitsWithPrecision:0 -> #('0' 0)
|
|
4552 |
|
|
4553 |
|
|
4554 |
1.2345 printfPrintString:'%.4f'
|
|
4555 |
1.2345 asQDouble digitsWithPrecision:5 -> #('12345' 0)
|
|
4556 |
|
|
4557 |
--- but 1.2345 is not really what you think:
|
|
4558 |
1.2345 printfPrintString:'%.20f'
|
|
4559 |
1.2345 asQDouble digitsWithPrecision:20 -> #('12344999999999999307' 0)
|
|
4560 |
|
|
4561 |
12.345 asQDouble digitsWithPrecision:5 -> #('12345' 1)
|
|
4562 |
12345 asQDouble digitsWithPrecision:5 -> #('12345' 4)
|
|
4563 |
12345.1 asQDouble digitsWithPrecision:5 -> #('12345' 4)
|
|
4564 |
12345.9 asQDouble digitsWithPrecision:5 -> #('12346' 4)
|
|
4565 |
|
4393
|
4566 |
1.2345 asQDouble / 10.0 asQDouble
|
4395
|
4567 |
1.2345 asQDouble / 10.0
|
4393
|
4568 |
"
|
|
4569 |
|
4395
|
4570 |
"Created: / 15-06-2017 / 09:10:01 / cg"
|
|
4571 |
"Modified: / 16-06-2017 / 10:01:03 / cg"
|
4393
|
4572 |
!
|
|
4573 |
|
|
4574 |
printOn:aStream
|
4395
|
4575 |
"return a printed representation of the receiver.
|
|
4576 |
|
|
4577 |
Notice:
|
5315
|
4578 |
this code was adapted from an ugly piece of c++ code,
|
|
4579 |
which was obviously hacked.
|
|
4580 |
It does need a rework.
|
|
4581 |
As an alternative, use the printf functions, which should also deal wth QDoubles"
|
5270
|
4582 |
|
5313
|
4583 |
"/ self d1 = 0.0 ifTrue:[
|
|
4584 |
"/ self d0 printOn:aStream.
|
|
4585 |
"/ ^ self
|
|
4586 |
"/ ].
|
4981
|
4587 |
thisContext isRecursive ifTrue:[
|
5344
|
4588 |
aStream nextPutAll:'aQDouble (recursion error while printing)'.
|
5315
|
4589 |
^ self.
|
4978
|
4590 |
].
|
4981
|
4591 |
|
4438
|
4592 |
PrintfScanf printf:'%g' on:aStream argument:self.
|
4395
|
4593 |
|
|
4594 |
"/ self
|
|
4595 |
"/ printOn:aStream precision:40 width:0
|
|
4596 |
"/ fixed:true showPositive:false uppercase:false fillChar:(Character space)
|
4393
|
4597 |
|
|
4598 |
"
|
5308
|
4599 |
(1.2345 asQDouble) printString
|
|
4600 |
(2 asQDouble squared) printString
|
|
4601 |
|
|
4602 |
(1.2345 asQDouble) printString.
|
|
4603 |
(1.2345 asFloat) printString.
|
|
4604 |
(1.2345 asLongFloat) printString.
|
5270
|
4605 |
(1.2345 asShortFloat) printString.
|
|
4606 |
|
5308
|
4607 |
((QDouble fromFloat:1.2345) / 10.0) printString
|
|
4608 |
((QDouble fromFloat:1.2345) / 10000.0) printString
|
5270
|
4609 |
((QDouble fromFloat:1.2345) / 1000000000.0) printString -> '0.0000123449999999999987156270014193593714e-4'
|
|
4610 |
(1.2345 / 1000000000.0) printString -> '1.2345E-09'
|
4393
|
4611 |
"
|
|
4612 |
|
|
4613 |
"Created: / 15-06-2017 / 01:51:36 / cg"
|
4439
|
4614 |
"Modified (comment): / 21-06-2017 / 09:55:10 / cg"
|
4978
|
4615 |
"Modified: / 05-06-2019 / 20:38:58 / Claus Gittinger"
|
4393
|
4616 |
!
|
|
4617 |
|
4395
|
4618 |
printOn:aStream precision:precisionIn width:width
|
4393
|
4619 |
fixed:fixed showPositive:showPositive uppercase:uppercase fillChar:fillChar
|
4454
|
4620 |
<resource: #obsolete>
|
4393
|
4621 |
|
|
4622 |
"return a printed representation of the receiver.
|
4395
|
4623 |
This is a parametrized entry, which can be used by printf-like functions.
|
|
4624 |
Notice:
|
5315
|
4625 |
this code was adapted from an ugly piece of c++ code,
|
|
4626 |
which was obviously hacked.
|
|
4627 |
It does need a rework.
|
|
4628 |
As an alternative, use the printf functions, which should also deal wth QDoubles
|
4395
|
4629 |
"
|
|
4630 |
|
|
4631 |
"
|
|
4632 |
1.2345 asQDouble printString
|
|
4633 |
12.345 asQDouble printString
|
|
4634 |
12345 asQDouble printString
|
|
4635 |
"
|
|
4636 |
|
|
4637 |
|sgn count delta exp precision|
|
|
4638 |
|
|
4639 |
"/ self d1 = 0.0 ifTrue:[
|
|
4640 |
"/ self d0 printOn:aStream.
|
|
4641 |
"/ ^ self.
|
|
4642 |
"/ ].
|
4385
|
4643 |
|
4393
|
4644 |
count := 0.
|
|
4645 |
sgn := true.
|
|
4646 |
exp := 0.
|
4395
|
4647 |
precision := precisionIn.
|
|
4648 |
|
4393
|
4649 |
self isInfinite ifTrue:[
|
5315
|
4650 |
self < 0 ifTrue:[
|
|
4651 |
aStream nextPut:$-.
|
|
4652 |
count := 1.
|
|
4653 |
] ifFalse:[
|
|
4654 |
showPositive ifTrue:[
|
|
4655 |
aStream nextPut:$+.
|
|
4656 |
count := 1.
|
|
4657 |
] ifFalse:[
|
|
4658 |
sgn := false.
|
|
4659 |
].
|
|
4660 |
].
|
|
4661 |
uppercase ifTrue:[
|
|
4662 |
aStream nextPutAll:'INF'
|
|
4663 |
] ifFalse:[
|
|
4664 |
aStream nextPutAll:'inf'
|
|
4665 |
].
|
|
4666 |
count := count + 3.
|
4385
|
4667 |
] ifFalse:[
|
5315
|
4668 |
self isNaN ifTrue:[
|
|
4669 |
uppercase ifTrue:[
|
|
4670 |
aStream nextPutAll:'NAN'
|
|
4671 |
] ifFalse:[
|
|
4672 |
aStream nextPutAll:'nan'
|
|
4673 |
].
|
|
4674 |
count := count + 3.
|
|
4675 |
] ifFalse:[
|
|
4676 |
self < 0 ifTrue:[
|
|
4677 |
aStream nextPut:$-.
|
|
4678 |
count := count + 1.
|
|
4679 |
] ifFalse:[
|
|
4680 |
showPositive ifTrue:[
|
|
4681 |
aStream nextPut:$+.
|
|
4682 |
count := count + 1.
|
|
4683 |
] ifFalse:[
|
|
4684 |
sgn := false.
|
|
4685 |
].
|
|
4686 |
].
|
|
4687 |
self = 0.0 ifTrue:[
|
|
4688 |
aStream nextPut:$0.
|
|
4689 |
count := count + 1.
|
|
4690 |
precision > 0 ifTrue:[
|
|
4691 |
aStream nextPut:$..
|
|
4692 |
count := count + 1.
|
|
4693 |
precision timesRepeat:[ aStream nextPut:$0 ].
|
|
4694 |
count := count + precision.
|
|
4695 |
].
|
|
4696 |
self halt.
|
|
4697 |
] ifFalse:[
|
|
4698 |
|off d d_width_extra|
|
|
4699 |
|
|
4700 |
"/ non-zero case
|
|
4701 |
off := fixed
|
|
4702 |
ifTrue:[ 1 + self asFloat abs log10 floor asInteger ]
|
|
4703 |
ifFalse:[1].
|
|
4704 |
d := precision + off.
|
|
4705 |
d_width_extra := d.
|
|
4706 |
fixed ifTrue:[
|
|
4707 |
d_width_extra := 40 max:d.
|
|
4708 |
].
|
|
4709 |
"/ highly special case - fixed mode, precision is zero, abs(*this) < 1.0
|
|
4710 |
"/ without this trap a number like 0.9 printed fixed with 0 precision prints as 0
|
|
4711 |
"/ should be rounded to 1.
|
|
4712 |
(fixed and:[ (precision == 0) and:[ (self abs < 1.0) ]]) ifTrue:[
|
|
4713 |
(self abs >= 0.5) ifTrue:[
|
|
4714 |
aStream nextPut:$1
|
|
4715 |
] ifFalse:[
|
|
4716 |
aStream nextPut:$0
|
|
4717 |
].
|
|
4718 |
^ self
|
|
4719 |
].
|
|
4720 |
|
|
4721 |
"/ handle near zero to working precision (but not exactly zero)
|
|
4722 |
(fixed and:[ d <= 0 ]) ifTrue:[
|
|
4723 |
aStream nextPut:$0.
|
|
4724 |
(precision > 0) ifTrue:[
|
|
4725 |
aStream nextPut:$. .
|
|
4726 |
aStream next:precision put:$0.
|
|
4727 |
]
|
|
4728 |
] ifFalse:[
|
|
4729 |
"/ default
|
|
4730 |
|
|
4731 |
|t j|
|
|
4732 |
|
|
4733 |
t := self digitsWithPrecision:(fixed ifTrue:[d_width_extra] ifFalse:[d])+1.
|
|
4734 |
exp := t second.
|
|
4735 |
t := t first.
|
|
4736 |
|
|
4737 |
fixed ifTrue:[
|
|
4738 |
"/ fix the string if it's been computed incorrectly
|
|
4739 |
"/ round here in the decimal string if required
|
|
4740 |
t := self round_string_qd:t at:(d + 1) offset:off.
|
|
4741 |
precision := t at:3.
|
|
4742 |
off := t at:2.
|
|
4743 |
t := t at:1.
|
|
4744 |
|
|
4745 |
(off > 0) ifTrue:[
|
|
4746 |
aStream next:off putAll:t startingAt:1.
|
|
4747 |
(precision > 0) ifTrue:[
|
|
4748 |
aStream nextPut:$. .
|
|
4749 |
aStream next:precision-1 putAll:t startingAt:off+1.
|
|
4750 |
]
|
|
4751 |
] ifFalse:[
|
|
4752 |
aStream nextPutAll:'0.'.
|
|
4753 |
(off < 0) ifTrue:[
|
|
4754 |
aStream next:off negated put:$0.
|
|
4755 |
].
|
|
4756 |
aStream next:d putAll:t startingAt:0.
|
|
4757 |
]
|
|
4758 |
] ifFalse:[
|
|
4759 |
aStream nextPut:(t at:1).
|
|
4760 |
(precision > 0) ifTrue:[
|
|
4761 |
aStream nextPut:$. .
|
|
4762 |
].
|
|
4763 |
aStream next:precision putAll:t startingAt:2.
|
|
4764 |
]
|
|
4765 |
].
|
|
4766 |
].
|
|
4767 |
]
|
4385
|
4768 |
].
|
4393
|
4769 |
|
|
4770 |
"/ trap for improper offset with large values
|
|
4771 |
"/ without this trap, output of values of the for 10^j - 1 fail for j > 28
|
|
4772 |
"/ and are output with the point in the wrong place, leading to a dramatically off value
|
4385
|
4773 |
|
4393
|
4774 |
"/ (fixed and:[ (precision > 0) ]) ifTrue:[
|
|
4775 |
"/ "/ make sure that the value isn't dramatically larger
|
|
4776 |
"/ from_string = atof(s.c_str());
|
|
4777 |
"/
|
|
4778 |
"/ // if this ratio is large, then we've got problems
|
|
4779 |
"/ if( fabs( from_string / this->x[0] ) > 3.0 ){
|
|
4780 |
"/
|
|
4781 |
"/ int point_position;
|
|
4782 |
"/ char temp;
|
|
4783 |
"/
|
|
4784 |
"/ // loop on the string, find the point, move it up one
|
|
4785 |
"/ // don't act on the first character
|
|
4786 |
"/ for(i=1; i < s.length(); i++){
|
|
4787 |
"/ if(s[i] == '.'){
|
|
4788 |
"/ s[i] = s[i-1] ;
|
|
4789 |
"/ s[i-1] = '.' ;
|
|
4790 |
"/ break;
|
|
4791 |
"/ }
|
|
4792 |
"/ }
|
|
4793 |
"/
|
|
4794 |
"/ from_string = atof(s.c_str());
|
|
4795 |
"/ // if this ratio is large, then the string has not been fixed
|
|
4796 |
"/ if( fabs( from_string / this->x[0] ) > 3.0 ){
|
|
4797 |
"/ dd_real::error("Re-rounding unsuccessful in large number fixed point trap.") ;
|
|
4798 |
"/ }
|
|
4799 |
"/ }
|
|
4800 |
"/ }
|
|
4801 |
"/
|
4395
|
4802 |
fixed ifFalse:[
|
|
4803 |
"/ Fill in exponent part
|
|
4804 |
aStream nextPut:(uppercase ifTrue:[$E] ifFalse:[$e]).
|
|
4805 |
aStream print:exp.
|
|
4806 |
].
|
4393
|
4807 |
|
|
4808 |
"/ fill in the blanks
|
|
4809 |
(delta := width-count) > 0 ifTrue:[
|
5315
|
4810 |
self halt.
|
4393
|
4811 |
"/ if (fmt & ios_base::internal) {
|
|
4812 |
"/ if (sgn)
|
|
4813 |
"/ s.insert(static_cast<string::size_type>(1), delta, fill);
|
|
4814 |
"/ else
|
|
4815 |
"/ s.insert(static_cast<string::size_type>(0), delta, fill);
|
|
4816 |
"/ } else if (fmt & ios_base::left) {
|
|
4817 |
"/ s.append(delta, fill);
|
|
4818 |
"/ } else {
|
|
4819 |
"/ s.insert(static_cast<string::size_type>(0), delta, fill);
|
|
4820 |
"/ }
|
|
4821 |
"/ }
|
|
4822 |
].
|
|
4823 |
|
|
4824 |
"Created: / 15-06-2017 / 02:37:31 / cg"
|
4395
|
4825 |
"Modified (comment): / 16-06-2017 / 14:48:30 / cg"
|
4385
|
4826 |
!
|
|
4827 |
|
4395
|
4828 |
round_string_qd:str at:precisionIn offset:offsetIn
|
4454
|
4829 |
<resource: #obsolete>
|
4395
|
4830 |
"returns a triple of: { new-str . new-offset . new-precision }"
|
|
4831 |
|
|
4832 |
"/
|
|
4833 |
"/ Input string must be all digits or errors will occur.
|
|
4834 |
"/
|
|
4835 |
|
|
4836 |
|i numDigits offsetOut precisionOut|
|
|
4837 |
|
|
4838 |
numDigits := precisionIn.
|
|
4839 |
|
|
4840 |
offsetOut := offsetIn.
|
|
4841 |
precisionOut := precisionIn.
|
|
4842 |
|
|
4843 |
"/ Round, handle carry
|
|
4844 |
((str at:numDigits) >= $5) ifTrue:[
|
5315
|
4845 |
str at:numDigits-1 put:(str at:numDigits-1)+1.
|
|
4846 |
i := numDigits-1.
|
|
4847 |
[ i > 1 and:[ (str at:i) > $9] ] whileTrue:[
|
|
4848 |
str at:i put:(str at:i)-10.
|
|
4849 |
i := i - 1.
|
|
4850 |
str at:i put:(str at:i)+1.
|
|
4851 |
]
|
4395
|
4852 |
].
|
|
4853 |
|
|
4854 |
"/ If first digit is 10, shift everything.
|
|
4855 |
(str at:1) > $9 ifTrue:[
|
5315
|
4856 |
"/ e++; // don't modify exponent here
|
|
4857 |
str replaceFrom:2 with:str startingAt:1.
|
|
4858 |
str at:1 put:$1.
|
|
4859 |
str at:2 put:$0.
|
|
4860 |
offsetOut := offsetOut + 1.
|
|
4861 |
precisionOut := precisionOut + 1.
|
4395
|
4862 |
].
|
|
4863 |
^ { (str copyTo:precisionOut) . offsetOut . precisionOut }
|
|
4864 |
|
|
4865 |
"Created: / 16-06-2017 / 10:12:39 / cg"
|
|
4866 |
"Modified (comment): / 16-06-2017 / 11:22:03 / cg"
|
4380
|
4867 |
! !
|
|
4868 |
|
5273
|
4869 |
!QDouble methodsFor:'private'!
|
|
4870 |
|
|
4871 |
nintAsFloat
|
|
4872 |
"return the receiver truncated towards negative infinity"
|
|
4873 |
|
|
4874 |
%{
|
|
4875 |
/* Computes the nearest integer to d. */
|
5308
|
4876 |
#define nint(d) (((d) == floor(d)) ? (d) : floor((d) + 0.5))
|
|
4877 |
|
|
4878 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
5273
|
4879 |
OBJ newQD;
|
|
4880 |
|
|
4881 |
double x0, x1, x2, x3;
|
|
4882 |
x0 = nint(a[0]);
|
|
4883 |
x1 = x2 = x3 = 0.0;
|
|
4884 |
|
|
4885 |
if (x0 == a[0]) {
|
5315
|
4886 |
/* First double is already an integer. */
|
|
4887 |
x1 = nint(a[1]);
|
|
4888 |
|
|
4889 |
if (x1 == a[1]) {
|
|
4890 |
/* Second double is already an integer. */
|
|
4891 |
x2 = nint(a[2]);
|
|
4892 |
|
|
4893 |
if (x2 == a[2]) {
|
|
4894 |
/* Third double is already an integer. */
|
|
4895 |
x3 = nint(a[3]);
|
|
4896 |
} else {
|
5326
|
4897 |
if (fabs(x2 - a[2]) == 0.5 && a[3] < 0.0) {
|
5315
|
4898 |
x2 -= 1.0;
|
|
4899 |
}
|
|
4900 |
}
|
|
4901 |
} else {
|
5326
|
4902 |
if (fabs(x1 - a[1]) == 0.5 && a[2] < 0.0) {
|
5315
|
4903 |
x1 -= 1.0;
|
|
4904 |
}
|
|
4905 |
}
|
5273
|
4906 |
} else {
|
5315
|
4907 |
/* First double is not an integer. */
|
5326
|
4908 |
if (fabs(x0 - a[0]) == 0.5 && a[1] < 0.0) {
|
5315
|
4909 |
x0 -= 1.0;
|
|
4910 |
}
|
5273
|
4911 |
}
|
5312
|
4912 |
renorm(&x0, &x1, &x2, &x3, x0, x1, x2, x3, 0.0);
|
|
4913 |
// m_renorm4(x0, x1, x2, x3);
|
|
4914 |
|
5273
|
4915 |
__qNew_qdReal(newQD, x0, x1, x2, x3);
|
|
4916 |
RETURN( newQD );
|
|
4917 |
%}.
|
|
4918 |
|
|
4919 |
"
|
5308
|
4920 |
(QDouble fromFloat:4.0) roundedAsFloat
|
|
4921 |
(QDouble fromFloat:4.6) roundedAsFloat
|
|
4922 |
(QDouble fromFloat:4.50000001) roundedAsFloat
|
|
4923 |
(QDouble fromFloat:4.5) roundedAsFloat
|
|
4924 |
(QDouble fromFloat:4.49999999) roundedAsFloat
|
|
4925 |
(QDouble fromFloat:4.4) roundedAsFloat
|
|
4926 |
(QDouble fromFloat:4.1) roundedAsFloat
|
|
4927 |
(QDouble fromFloat:0.1) roundedAsFloat
|
|
4928 |
(QDouble fromFloat:0.5) roundedAsFloat
|
|
4929 |
(QDouble fromFloat:0.49999) roundedAsFloat
|
|
4930 |
(QDouble fromFloat:0.4) roundedAsFloat
|
|
4931 |
|
|
4932 |
(QDouble fromFloat:-4.0) roundedAsFloat
|
|
4933 |
(QDouble fromFloat:-4.6) roundedAsFloat
|
|
4934 |
(QDouble fromFloat:-4.4) roundedAsFloat
|
|
4935 |
(QDouble fromFloat:-4.499999999) roundedAsFloat
|
|
4936 |
(QDouble fromFloat:-4.5) roundedAsFloat
|
|
4937 |
(QDouble fromFloat:-4.5000000001) roundedAsFloat
|
|
4938 |
(QDouble fromFloat:-4.1) roundedAsFloat
|
|
4939 |
(QDouble fromFloat:-0.1) roundedAsFloat
|
|
4940 |
(QDouble fromFloat:-0.5) roundedAsFloat
|
|
4941 |
(QDouble fromFloat:-0.4) roundedAsFloat
|
5273
|
4942 |
"
|
|
4943 |
|
|
4944 |
"Created: / 13-06-2017 / 01:52:44 / cg"
|
|
4945 |
"Modified (comment): / 13-06-2017 / 17:33:19 / cg"
|
|
4946 |
!
|
|
4947 |
|
|
4948 |
renorm
|
|
4949 |
"destructive renormalization"
|
|
4950 |
%{
|
5308
|
4951 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
5273
|
4952 |
double c0, c1, c2, c3;
|
|
4953 |
|
5315
|
4954 |
renorm(&c0, &c1, &c2, &c3, a[0], a[1], a[2], a[3], 0.0);
|
5273
|
4955 |
a[0] = c0;
|
|
4956 |
a[1] = c1;
|
|
4957 |
a[2] = c2;
|
|
4958 |
a[3] = c3;
|
|
4959 |
RETURN( self );
|
|
4960 |
%}.
|
|
4961 |
^ self error.
|
|
4962 |
|
|
4963 |
"
|
|
4964 |
(QDouble fromFloat:1.0) renorm
|
|
4965 |
"
|
|
4966 |
|
|
4967 |
"Created: / 13-06-2017 / 18:05:33 / cg"
|
|
4968 |
"Modified: / 15-06-2017 / 00:12:59 / cg"
|
|
4969 |
! !
|
|
4970 |
|
4380
|
4971 |
!QDouble methodsFor:'private accessing'!
|
|
4972 |
|
|
4973 |
d0
|
4386
|
4974 |
"the most significant (and highest valued) 53 bits of precision"
|
4380
|
4975 |
%{
|
5308
|
4976 |
RETURN ( __MKFLOAT(__QDoubleInstPtr(self)->d_qDoubleValue[0]) );
|
4380
|
4977 |
%}
|
|
4978 |
|
|
4979 |
"Created: / 12-06-2017 / 20:15:12 / cg"
|
4386
|
4980 |
"Modified (comment): / 13-06-2017 / 17:59:47 / cg"
|
4380
|
4981 |
!
|
|
4982 |
|
|
4983 |
d1
|
4386
|
4984 |
"the next most significant (and next highest valued) 53 bits of precision"
|
4380
|
4985 |
%{
|
5308
|
4986 |
RETURN ( __MKFLOAT(__QDoubleInstPtr(self)->d_qDoubleValue[1]) );
|
4380
|
4987 |
%}
|
|
4988 |
|
|
4989 |
"Created: / 12-06-2017 / 20:15:12 / cg"
|
4386
|
4990 |
"Modified (comment): / 13-06-2017 / 18:00:00 / cg"
|
4380
|
4991 |
!
|
|
4992 |
|
|
4993 |
d2
|
|
4994 |
%{
|
5308
|
4995 |
RETURN ( __MKFLOAT(__QDoubleInstPtr(self)->d_qDoubleValue[2]) );
|
4380
|
4996 |
%}
|
|
4997 |
|
|
4998 |
"Created: / 12-06-2017 / 20:15:29 / cg"
|
|
4999 |
!
|
|
5000 |
|
|
5001 |
d3
|
4386
|
5002 |
"the least significant (and smallest valued) 53 bits of precision"
|
4380
|
5003 |
%{
|
5308
|
5004 |
RETURN ( __MKFLOAT(__QDoubleInstPtr(self)->d_qDoubleValue[3]) );
|
4380
|
5005 |
%}
|
|
5006 |
|
|
5007 |
"Created: / 12-06-2017 / 20:15:32 / cg"
|
4386
|
5008 |
"Modified (comment): / 13-06-2017 / 18:00:18 / cg"
|
4393
|
5009 |
! !
|
|
5010 |
|
|
5011 |
!QDouble methodsFor:'testing'!
|
|
5012 |
|
4404
|
5013 |
isFinite
|
5195
|
5014 |
"return true, if the receiver is a finite float (not NaN and not +/-INF)"
|
|
5015 |
|
4404
|
5016 |
^ self d0 isFinite
|
|
5017 |
|
|
5018 |
"Created: / 17-06-2017 / 03:40:30 / cg"
|
|
5019 |
!
|
|
5020 |
|
4393
|
5021 |
isInfinite
|
5195
|
5022 |
"return true, if the receiver is an infinite float (+Inf or -Inf)."
|
|
5023 |
|
4393
|
5024 |
^ self d0 isInfinite
|
|
5025 |
|
|
5026 |
"Created: / 15-06-2017 / 01:57:57 / cg"
|
|
5027 |
!
|
|
5028 |
|
|
5029 |
isNaN
|
5195
|
5030 |
"return true, if the receiver is an invalid float (NaN - not a number)"
|
|
5031 |
|
|
5032 |
^ self d0 isNaN
|
4393
|
5033 |
|
|
5034 |
"Created: / 15-06-2017 / 01:57:35 / cg"
|
4411
|
5035 |
!
|
|
5036 |
|
|
5037 |
isOne
|
|
5038 |
^ self d0 = 1.0
|
|
5039 |
and:[ self d1 = 0.0
|
|
5040 |
and:[ self d2 = 0.0
|
|
5041 |
and:[ self d3 = 0.0 ]]]
|
|
5042 |
|
|
5043 |
"Created: / 18-06-2017 / 23:29:07 / cg"
|
|
5044 |
!
|
|
5045 |
|
|
5046 |
isZero
|
|
5047 |
^ self d0 = 0.0
|
|
5048 |
|
|
5049 |
"Created: / 18-06-2017 / 23:29:25 / cg"
|
5270
|
5050 |
!
|
|
5051 |
|
|
5052 |
negative
|
|
5053 |
^ self d0 negative
|
|
5054 |
|
|
5055 |
"
|
|
5056 |
(QDouble fromFloat:0.0) negative
|
|
5057 |
(QDouble fromFloat:1.0) negative
|
|
5058 |
(QDouble fromFloat:-1.0) negative
|
|
5059 |
"
|
|
5060 |
|
|
5061 |
"Created: / 13-06-2017 / 01:57:39 / cg"
|
|
5062 |
"Modified: / 13-06-2017 / 17:58:26 / cg"
|
|
5063 |
!
|
|
5064 |
|
|
5065 |
positive
|
|
5066 |
"return true, if the receiver is greater or equal to zero (not negative)"
|
|
5067 |
|
|
5068 |
^ self d0 positive
|
|
5069 |
|
|
5070 |
"
|
|
5071 |
(QDouble fromFloat:1.0) positive
|
|
5072 |
(QDouble fromFloat:-1.0) positive
|
5308
|
5073 |
(1.0 asQDouble + 1e-100) positive
|
|
5074 |
(0.0 asQDouble + 1e-100) positive
|
|
5075 |
(0.0 asQDouble - 1e-100) positive
|
5270
|
5076 |
"
|
|
5077 |
|
|
5078 |
"Created: / 13-06-2017 / 01:56:53 / cg"
|
|
5079 |
"Modified: / 13-06-2017 / 17:58:41 / cg"
|
|
5080 |
"Modified (comment): / 28-05-2019 / 05:55:55 / Claus Gittinger"
|
5306
|
5081 |
!
|
|
5082 |
|
|
5083 |
sign
|
|
5084 |
"return the sign of the receiver"
|
|
5085 |
|
|
5086 |
^ self d0 sign
|
|
5087 |
|
|
5088 |
"
|
5308
|
5089 |
Float nan isNaN
|
|
5090 |
Float nan sign
|
|
5091 |
Float infinity sign
|
|
5092 |
Float infinity negated sign
|
|
5093 |
|
|
5094 |
ShortFloat nan isNaN
|
|
5095 |
ShortFloat nan sign
|
|
5096 |
ShortFloat infinity sign
|
|
5097 |
ShortFloat infinity negated sign
|
|
5098 |
|
|
5099 |
QDouble nan isNaN
|
|
5100 |
QDouble nan sign
|
|
5101 |
QDouble infinity sign
|
|
5102 |
QDouble infinity negated sign
|
|
5103 |
0 asQDouble sign
|
|
5104 |
1 asQDouble sign
|
|
5105 |
-1 asQDouble sign
|
5306
|
5106 |
"
|
4380
|
5107 |
! !
|
|
5108 |
|
5273
|
5109 |
!QDouble methodsFor:'truncation & rounding'!
|
|
5110 |
|
|
5111 |
ceiling
|
|
5112 |
"return the smallest integer which is greater or equal to the receiver."
|
|
5113 |
|
|
5114 |
|f|
|
|
5115 |
|
|
5116 |
f := self ceilingAsFloat.
|
|
5117 |
^ f d0 asInteger + f d1 asInteger + f d2 asInteger + f d3 asInteger
|
|
5118 |
|
|
5119 |
"
|
5308
|
5120 |
(QDouble fromFloat:4.0) ceiling
|
|
5121 |
(QDouble fromFloat:4.1) ceiling
|
|
5122 |
(QDouble fromFloat:0.1) ceiling
|
|
5123 |
(0.1 + (QDouble fromFloat:1.0)) ceiling
|
5273
|
5124 |
(1e20 + (QDouble fromFloat:1.0)) ceiling
|
5308
|
5125 |
(1e20 + (QDouble fromFloat:1.1)) ceiling
|
5273
|
5126 |
|
|
5127 |
(QDouble fromFloat:1.5) ceiling
|
|
5128 |
(QDouble fromFloat:0.5) ceiling
|
|
5129 |
(QDouble fromFloat:-0.5) ceiling
|
|
5130 |
(QDouble fromFloat:-1.5) ceiling
|
|
5131 |
"
|
|
5132 |
!
|
|
5133 |
|
|
5134 |
ceilingAsFloat
|
|
5135 |
"return the smallest integer-valued float greater or equal to the receiver.
|
|
5136 |
This is much like #ceiling, but avoids a (possibly expensive) conversion
|
|
5137 |
of the result to an integer.
|
|
5138 |
It may be useful, if the result is to be further used in another float-operation."
|
|
5139 |
|
|
5140 |
%{
|
5308
|
5141 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
5273
|
5142 |
OBJ newQD;
|
5308
|
5143 |
int savedCV;
|
5273
|
5144 |
|
|
5145 |
double x0, x1, x2, x3;
|
|
5146 |
x1 = x2 = x3 = 0.0;
|
|
5147 |
x0 = ceil(a[0]);
|
|
5148 |
|
|
5149 |
if (x0 == a[0]) {
|
5315
|
5150 |
x1 = ceil(a[1]);
|
|
5151 |
if (x1 == a[1]) {
|
|
5152 |
x2 = ceil(a[2]);
|
|
5153 |
if (x2 == a[2]) {
|
|
5154 |
x3 = ceil(a[3]);
|
|
5155 |
}
|
|
5156 |
}
|
|
5157 |
fpu_fix_start(&savedCV);
|
|
5158 |
renorm(&x0, &x1, &x2, &x3, x0, x1, x2, x3, 0.0);
|
|
5159 |
// m_renorm4(x0, x1, x2, x3);
|
|
5160 |
fpu_fix_end(&savedCV);
|
5273
|
5161 |
}
|
|
5162 |
__qNew_qdReal(newQD, x0, x1, x2, x3);
|
|
5163 |
RETURN( newQD );
|
|
5164 |
%}.
|
|
5165 |
|
|
5166 |
"
|
|
5167 |
(QDouble fromFloat:4.0) ceiling
|
|
5168 |
(QDouble fromFloat:4.1) ceiling
|
|
5169 |
(QDouble fromFloat:0.1) ceiling
|
|
5170 |
(0.1 + (QDouble fromFloat:1.0)) ceiling
|
|
5171 |
(1e20 + (QDouble fromFloat:1.0)) ceiling
|
|
5172 |
|
|
5173 |
(QDouble fromFloat:1.5) ceiling
|
|
5174 |
(QDouble fromFloat:0.5) ceiling
|
|
5175 |
(QDouble fromFloat:-0.5) ceiling
|
|
5176 |
(QDouble fromFloat:-1.5) ceiling
|
|
5177 |
"
|
|
5178 |
!
|
|
5179 |
|
|
5180 |
floor
|
|
5181 |
"return the receiver truncated towards negative infinity"
|
|
5182 |
|
|
5183 |
|f|
|
|
5184 |
|
|
5185 |
f := self floorAsFloat.
|
|
5186 |
^ f d0 asInteger + f d1 asInteger + f d2 asInteger + f d3 asInteger
|
|
5187 |
|
|
5188 |
"
|
|
5189 |
(QDouble fromFloat:4.0) floor
|
|
5190 |
(QDouble fromFloat:4.1) floor
|
|
5191 |
(QDouble fromFloat:0.1) floor
|
|
5192 |
(0.1 + (QDouble fromFloat:1.0)) floor
|
|
5193 |
(1e20 + (QDouble fromFloat:1.0)) floor
|
|
5194 |
|
|
5195 |
(QDouble fromFloat:1.5) floor
|
|
5196 |
(QDouble fromFloat:0.5) floor
|
|
5197 |
(QDouble fromFloat:-0.5) floor
|
|
5198 |
(QDouble fromFloat:-1.5) floor
|
|
5199 |
"
|
|
5200 |
|
|
5201 |
"Created: / 13-06-2017 / 01:52:44 / cg"
|
|
5202 |
"Modified (comment): / 13-06-2017 / 17:33:19 / cg"
|
|
5203 |
!
|
|
5204 |
|
|
5205 |
floorAsFloat
|
|
5206 |
"return the receiver truncated towards negative infinity"
|
|
5207 |
|
|
5208 |
%{
|
5308
|
5209 |
double *a = __QDoubleInstPtr(self)->d_qDoubleValue;
|
5273
|
5210 |
OBJ newQD;
|
5308
|
5211 |
int savedCV;
|
5273
|
5212 |
|
|
5213 |
double x0, x1, x2, x3;
|
|
5214 |
x1 = x2 = x3 = 0.0;
|
|
5215 |
x0 =floor(a[0]);
|
|
5216 |
|
|
5217 |
if (x0 == a[0]) {
|
5315
|
5218 |
x1 = floor(a[1]);
|
|
5219 |
if (x1 == a[1]) {
|
|
5220 |
x2 = floor(a[2]);
|
|
5221 |
if (x2 == a[2]) {
|
|
5222 |
x3 = floor(a[3]);
|
|
5223 |
}
|
|
5224 |
}
|
|
5225 |
fpu_fix_start(&savedCV);
|
|
5226 |
renorm(&x0, &x1, &x2, &x3, x0, x1, x2, x3, 0.0);
|
|
5227 |
// m_renorm4(x0, x1, x2, x3);
|
|
5228 |
fpu_fix_end(&savedCV);
|
5273
|
5229 |
}
|
|
5230 |
__qNew_qdReal(newQD, x0, x1, x2, x3);
|
|
5231 |
RETURN( newQD );
|
|
5232 |
%}.
|
|
5233 |
|
|
5234 |
"
|
|
5235 |
(QDouble fromFloat:4.0) floor
|
|
5236 |
(QDouble fromFloat:4.1) floor
|
|
5237 |
(QDouble fromFloat:0.1) floor
|
|
5238 |
(0.1 + (QDouble fromFloat:1.0)) floor
|
|
5239 |
(1e20 + (QDouble fromFloat:1.0)) floor
|
|
5240 |
|
|
5241 |
(QDouble fromFloat:1.5) floor
|
|
5242 |
(QDouble fromFloat:0.5) floor
|
|
5243 |
(QDouble fromFloat:-0.5) floor
|
|
5244 |
(QDouble fromFloat:-1.5) floor
|
|
5245 |
"
|
|
5246 |
|
|
5247 |
"Created: / 13-06-2017 / 01:52:44 / cg"
|
|
5248 |
"Modified (comment): / 13-06-2017 / 17:33:19 / cg"
|
|
5249 |
!
|
|
5250 |
|
|
5251 |
rounded
|
|
5252 |
"return the smallest integer which is greater or equal to the receiver."
|
|
5253 |
|
|
5254 |
|f|
|
|
5255 |
|
|
5256 |
f := self roundedAsFloat.
|
|
5257 |
"/ ^ (f d0 + f d1 + f d2 + f d3) asInteger
|
|
5258 |
^ f d0 asInteger + f d1 asInteger + f d2 asInteger + f d3 asInteger
|
|
5259 |
|
|
5260 |
"
|
5308
|
5261 |
(QDouble fromFloat:4.0) rounded
|
|
5262 |
(QDouble fromFloat:4.6) rounded
|
|
5263 |
(QDouble fromFloat:4.50000001) rounded
|
|
5264 |
(QDouble fromFloat:4.5) rounded
|
|
5265 |
(QDouble fromFloat:4.49999999) rounded
|
|
5266 |
(QDouble fromFloat:4.4) rounded
|
|
5267 |
(QDouble fromFloat:4.1) rounded
|
|
5268 |
(QDouble fromFloat:0.1) rounded
|
|
5269 |
(QDouble fromFloat:0.5) rounded
|
|
5270 |
(QDouble fromFloat:0.49999) rounded
|
|
5271 |
(QDouble fromFloat:0.4) rounded
|
|
5272 |
|
|
5273 |
(QDouble fromFloat:-4.0) rounded
|
|
5274 |
(QDouble fromFloat:-4.6) rounded
|
|
5275 |
(QDouble fromFloat:-4.4) rounded
|
|
5276 |
(QDouble fromFloat:-4.499999999) rounded
|
|
5277 |
(QDouble fromFloat:-4.5) rounded
|
|
5278 |
(QDouble fromFloat:-4.5000000001) rounded
|
|
5279 |
(QDouble fromFloat:-4.1) rounded
|
|
5280 |
(QDouble fromFloat:-0.1) rounded
|
|
5281 |
(QDouble fromFloat:-0.5) rounded
|
|
5282 |
(QDouble fromFloat:-0.4) rounded
|
5273
|
5283 |
"
|
|
5284 |
!
|
|
5285 |
|
|
5286 |
roundedAsFloat
|
|
5287 |
"return the receiver truncated towards negative infinity"
|
|
5288 |
|
|
5289 |
self positive ifTrue:[
|
5315
|
5290 |
^ self nintAsFloat
|
5273
|
5291 |
].
|
|
5292 |
^ self negated nintAsFloat negated
|
|
5293 |
|
|
5294 |
"
|
5308
|
5295 |
(QDouble fromFloat:4.0) roundedAsFloat
|
|
5296 |
(QDouble fromFloat:4.6) roundedAsFloat
|
|
5297 |
(QDouble fromFloat:4.50000001) roundedAsFloat
|
|
5298 |
(QDouble fromFloat:4.5) roundedAsFloat
|
|
5299 |
(QDouble fromFloat:4.49999999) roundedAsFloat
|
|
5300 |
(QDouble fromFloat:4.4) roundedAsFloat
|
|
5301 |
(QDouble fromFloat:4.1) roundedAsFloat
|
|
5302 |
(QDouble fromFloat:0.1) roundedAsFloat
|
|
5303 |
(QDouble fromFloat:0.5) roundedAsFloat
|
|
5304 |
(QDouble fromFloat:0.49999) roundedAsFloat
|
|
5305 |
(QDouble fromFloat:0.4) roundedAsFloat
|
|
5306 |
|
|
5307 |
(QDouble fromFloat:-4.0) roundedAsFloat
|
|
5308 |
(QDouble fromFloat:-4.6) roundedAsFloat
|
|
5309 |
(QDouble fromFloat:-4.4) roundedAsFloat
|
|
5310 |
(QDouble fromFloat:-4.499999999) roundedAsFloat
|
|
5311 |
(QDouble fromFloat:-4.5) roundedAsFloat
|
|
5312 |
(QDouble fromFloat:-4.5000000001) roundedAsFloat
|
|
5313 |
(QDouble fromFloat:-4.1) roundedAsFloat
|
|
5314 |
(QDouble fromFloat:-0.1) roundedAsFloat
|
|
5315 |
(QDouble fromFloat:-0.5) roundedAsFloat
|
|
5316 |
(QDouble fromFloat:-0.4) roundedAsFloat
|
5273
|
5317 |
"
|
|
5318 |
|
|
5319 |
"Created: / 13-06-2017 / 01:52:44 / cg"
|
|
5320 |
"Modified (comment): / 13-06-2017 / 17:33:19 / cg"
|
|
5321 |
! !
|
|
5322 |
|
4380
|
5323 |
!QDouble class methodsFor:'documentation'!
|
|
5324 |
|
|
5325 |
version
|
|
5326 |
^ '$Header$'
|
|
5327 |
!
|
|
5328 |
|
|
5329 |
version_CVS
|
|
5330 |
^ '$Header$'
|
|
5331 |
! !
|
5326
|
5332 |
|