intervals 0.3.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. data/VERSION.txt +1 -0
  2. data/ext/crlibm/AUTHORS +2 -0
  3. data/ext/crlibm/COPYING +504 -0
  4. data/ext/crlibm/ChangeLog +80 -0
  5. data/ext/crlibm/INSTALL +182 -0
  6. data/ext/crlibm/Makefile.am +84 -0
  7. data/ext/crlibm/Makefile.in +530 -0
  8. data/ext/crlibm/NEWS +0 -0
  9. data/ext/crlibm/README +31 -0
  10. data/ext/crlibm/TODO +47 -0
  11. data/ext/crlibm/VERSION +1 -0
  12. data/ext/crlibm/aclocal.m4 +989 -0
  13. data/ext/crlibm/atan-itanium.c +846 -0
  14. data/ext/crlibm/atan-pentium.c +261 -0
  15. data/ext/crlibm/atan_accurate.c +244 -0
  16. data/ext/crlibm/atan_accurate.h +191 -0
  17. data/ext/crlibm/atan_fast.c +324 -0
  18. data/ext/crlibm/atan_fast.h +678 -0
  19. data/ext/crlibm/config.guess +1461 -0
  20. data/ext/crlibm/config.sub +1566 -0
  21. data/ext/crlibm/configure +7517 -0
  22. data/ext/crlibm/configure.ac +364 -0
  23. data/ext/crlibm/crlibm.h +125 -0
  24. data/ext/crlibm/crlibm_config.h +149 -0
  25. data/ext/crlibm/crlibm_config.h.in +148 -0
  26. data/ext/crlibm/crlibm_private.c +293 -0
  27. data/ext/crlibm/crlibm_private.h +658 -0
  28. data/ext/crlibm/csh_fast.c +631 -0
  29. data/ext/crlibm/csh_fast.h +771 -0
  30. data/ext/crlibm/double-extended.h +496 -0
  31. data/ext/crlibm/exp-td.c +962 -0
  32. data/ext/crlibm/exp-td.h +685 -0
  33. data/ext/crlibm/exp_accurate.c +197 -0
  34. data/ext/crlibm/exp_accurate.h +85 -0
  35. data/ext/crlibm/gappa/log-de-E0-logir0.gappa +106 -0
  36. data/ext/crlibm/gappa/log-de-E0.gappa +79 -0
  37. data/ext/crlibm/gappa/log-de.gappa +81 -0
  38. data/ext/crlibm/gappa/log-td-E0-logir0.gappa +126 -0
  39. data/ext/crlibm/gappa/log-td-E0.gappa +143 -0
  40. data/ext/crlibm/gappa/log-td-accurate-E0-logir0.gappa +230 -0
  41. data/ext/crlibm/gappa/log-td-accurate-E0.gappa +213 -0
  42. data/ext/crlibm/gappa/log-td-accurate.gappa +217 -0
  43. data/ext/crlibm/gappa/log-td.gappa +156 -0
  44. data/ext/crlibm/gappa/trigoSinCosCase3.gappa +204 -0
  45. data/ext/crlibm/gappa/trigoTanCase2.gappa +73 -0
  46. data/ext/crlibm/install-sh +269 -0
  47. data/ext/crlibm/log-de.c +431 -0
  48. data/ext/crlibm/log-de.h +732 -0
  49. data/ext/crlibm/log-td.c +852 -0
  50. data/ext/crlibm/log-td.h +819 -0
  51. data/ext/crlibm/log10-td.c +906 -0
  52. data/ext/crlibm/log10-td.h +823 -0
  53. data/ext/crlibm/log2-td.c +935 -0
  54. data/ext/crlibm/log2-td.h +821 -0
  55. data/ext/crlibm/maple/atan.mpl +359 -0
  56. data/ext/crlibm/maple/common-procedures.mpl +997 -0
  57. data/ext/crlibm/maple/csh.mpl +446 -0
  58. data/ext/crlibm/maple/double-extended.mpl +151 -0
  59. data/ext/crlibm/maple/exp-td.mpl +195 -0
  60. data/ext/crlibm/maple/log-de.mpl +243 -0
  61. data/ext/crlibm/maple/log-td.mpl +316 -0
  62. data/ext/crlibm/maple/log10-td.mpl +345 -0
  63. data/ext/crlibm/maple/log2-td.mpl +334 -0
  64. data/ext/crlibm/maple/trigo.mpl +728 -0
  65. data/ext/crlibm/maple/triple-double.mpl +58 -0
  66. data/ext/crlibm/missing +198 -0
  67. data/ext/crlibm/mkinstalldirs +40 -0
  68. data/ext/crlibm/rem_pio2_accurate.c +219 -0
  69. data/ext/crlibm/rem_pio2_accurate.h +53 -0
  70. data/ext/crlibm/scs_lib/AUTHORS +3 -0
  71. data/ext/crlibm/scs_lib/COPYING +504 -0
  72. data/ext/crlibm/scs_lib/ChangeLog +16 -0
  73. data/ext/crlibm/scs_lib/INSTALL +215 -0
  74. data/ext/crlibm/scs_lib/Makefile.am +18 -0
  75. data/ext/crlibm/scs_lib/Makefile.in +328 -0
  76. data/ext/crlibm/scs_lib/NEWS +0 -0
  77. data/ext/crlibm/scs_lib/README +9 -0
  78. data/ext/crlibm/scs_lib/TODO +4 -0
  79. data/ext/crlibm/scs_lib/addition_scs.c +623 -0
  80. data/ext/crlibm/scs_lib/config.guess +1461 -0
  81. data/ext/crlibm/scs_lib/config.sub +1566 -0
  82. data/ext/crlibm/scs_lib/configure +6226 -0
  83. data/ext/crlibm/scs_lib/division_scs.c +110 -0
  84. data/ext/crlibm/scs_lib/double2scs.c +174 -0
  85. data/ext/crlibm/scs_lib/install-sh +269 -0
  86. data/ext/crlibm/scs_lib/missing +198 -0
  87. data/ext/crlibm/scs_lib/mkinstalldirs +40 -0
  88. data/ext/crlibm/scs_lib/multiplication_scs.c +456 -0
  89. data/ext/crlibm/scs_lib/poly_fct.c +112 -0
  90. data/ext/crlibm/scs_lib/print_scs.c +73 -0
  91. data/ext/crlibm/scs_lib/rand_scs.c +63 -0
  92. data/ext/crlibm/scs_lib/scs.h +353 -0
  93. data/ext/crlibm/scs_lib/scs2double.c +391 -0
  94. data/ext/crlibm/scs_lib/scs2mpf.c +58 -0
  95. data/ext/crlibm/scs_lib/scs2mpfr.c +61 -0
  96. data/ext/crlibm/scs_lib/scs_private.c +23 -0
  97. data/ext/crlibm/scs_lib/scs_private.h +133 -0
  98. data/ext/crlibm/scs_lib/tests/tbx_timing.h +102 -0
  99. data/ext/crlibm/scs_lib/wrapper_scs.h +486 -0
  100. data/ext/crlibm/scs_lib/zero_scs.c +52 -0
  101. data/ext/crlibm/stamp-h.in +1 -0
  102. data/ext/crlibm/tests/Makefile.am +43 -0
  103. data/ext/crlibm/tests/Makefile.in +396 -0
  104. data/ext/crlibm/tests/blind_test.c +148 -0
  105. data/ext/crlibm/tests/generate_test_vectors.c +258 -0
  106. data/ext/crlibm/tests/soak_test.c +334 -0
  107. data/ext/crlibm/tests/test_common.c +627 -0
  108. data/ext/crlibm/tests/test_common.h +28 -0
  109. data/ext/crlibm/tests/test_perf.c +570 -0
  110. data/ext/crlibm/tests/test_val.c +249 -0
  111. data/ext/crlibm/trigo_accurate.c +500 -0
  112. data/ext/crlibm/trigo_accurate.h +331 -0
  113. data/ext/crlibm/trigo_fast.c +1219 -0
  114. data/ext/crlibm/trigo_fast.h +639 -0
  115. data/ext/crlibm/triple-double.h +878 -0
  116. data/ext/extconf.rb +31 -0
  117. data/ext/fpu.c +107 -0
  118. data/ext/jamis-mod.rb +591 -0
  119. data/lib/fpu.rb +287 -0
  120. data/lib/interval.rb +1170 -0
  121. data/lib/intervals.rb +212 -0
  122. data/lib/struct_float.rb +133 -0
  123. data/test/data_atan.txt +360 -0
  124. data/test/data_cos.txt +346 -0
  125. data/test/data_cosh.txt +3322 -0
  126. data/test/data_exp.txt +3322 -0
  127. data/test/data_log.txt +141 -0
  128. data/test/data_sin.txt +140 -0
  129. data/test/data_sinh.txt +3322 -0
  130. data/test/data_tan.txt +342 -0
  131. metadata +186 -0
@@ -0,0 +1,878 @@
1
+ /*
2
+ * triple_double.h
3
+ *
4
+ * This file contains useful tools and data for triple double data representation.
5
+ *
6
+ */
7
+
8
+ #ifndef TRIPLE_DOUBLE_H
9
+ #define TRIPLE_DOUBLE_H 1
10
+
11
+ #include "scs_lib/scs.h"
12
+ #include "scs_lib/scs_private.h"
13
+ /* undef all the variables that might have been defined in
14
+ scs_lib/scs_private.h */
15
+ #undef VERSION
16
+ #undef PACKAGE
17
+ #undef HAVE_GMP_H
18
+ #undef HAVE_MPFR_H
19
+ #undef HAVE_MATHLIB_H
20
+ /* then include the proper definitions */
21
+ #include "crlibm_config.h"
22
+
23
+ #ifdef HAVE_INTTYPES_H
24
+ #include <inttypes.h>
25
+ #endif
26
+
27
+
28
+ /* Renormalize3
29
+
30
+ Procedure for renormalizing a triple double number, i.e.
31
+ computing exactly an equivalent sum of three non-overlapping
32
+ double numbers
33
+
34
+
35
+ Arguments: a triple double number ah, am, al
36
+
37
+ Results: a triple double number resh, resm, resl
38
+
39
+ Preconditions: abs(ah) > abs(am) > abs(al)
40
+ ah and am are overlapping not more than 51 bits
41
+ am and al are overlapping not more than 51 bits
42
+
43
+ Guarantees: abs(resh) > abs(resm) > abs(resl)
44
+ resh and resm are non-overlapping
45
+ resm and resl are non-overlapping
46
+ resm = round-to-nearest(resm + resl)
47
+
48
+ Details: resh, resm and resl are considered to be pointers
49
+
50
+ */
51
+ #define Renormalize3(resh, resm, resl, ah, am, al) \
52
+ { \
53
+ double _t1h, _t1l, _t2l; \
54
+ \
55
+ Add12(_t1h, _t1l, (am), (al)); \
56
+ Add12((*(resh)), _t2l, (ah), (_t1h)); \
57
+ Add12((*(resm)), (*(resl)), _t2l, _t1l); \
58
+ }
59
+
60
+
61
+ /* Mul23
62
+
63
+ Procedure for multiplying two double double numbers resulting
64
+ in a triple double number
65
+
66
+
67
+ Arguments: two double double numbers:
68
+ ah, al and
69
+ bh, bl
70
+
71
+ Results: a triple double number resh, resm, resl
72
+
73
+ Preconditions: abs(ah) > abs(al)
74
+ ah and al do not overlap
75
+ ah = round-to-nearest(ah + al)
76
+ abs(bh) > abs(bl)
77
+ bh and bl do not overlap
78
+ bh = round-to-nearest(bh + bl)
79
+
80
+ Guarantees: resm and resl are non-overlapping
81
+ resm = round-to-nearest(resm + resl)
82
+ abs(resm) <= 2^(-49) * abs(resh)
83
+ resh+resm+resl = (ah+al) * (bh+bl) * (1 + eps)
84
+ where
85
+ abs(eps) <= 2^(-149)
86
+
87
+ Details: resh, resm and resl are considered to be pointers
88
+ */
89
+ #define Mul23(resh, resm, resl, ah, al, bh, bl) \
90
+ { \
91
+ double _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10; \
92
+ \
93
+ Mul12((resh),&_t1,(ah),(bh)); \
94
+ Mul12(&_t2,&_t3,(ah),(bl)); \
95
+ Mul12(&_t4,&_t5,(al),(bh)); \
96
+ _t6 = (al) * (bl); \
97
+ Add22Cond(&_t7,&_t8,_t2,_t3,_t4,_t5); \
98
+ Add12(_t9,_t10,_t1,_t6); \
99
+ Add22Cond((resm),(resl),_t7,_t8,_t9,_t10); \
100
+ }
101
+
102
+ /* Mul233
103
+
104
+ Procedure for multiplying a double double number by
105
+ a triple double number resulting in a triple double number
106
+
107
+
108
+ Arguments: a double double number ah, al
109
+ a triple double number bh, bm, bl
110
+
111
+ Results: a triple double number resh, resm, resl
112
+
113
+ Preconditions: abs(ah) > abs(al)
114
+ ah and al do not overlap
115
+ ah = round-to-nearest(ah + al)
116
+ abs(bm) <= 2^(-b_o) * abs(bh)
117
+ abs(bl) <= 2^(-b_u) * abs(bm)
118
+ where
119
+ b_o >= 2
120
+ b_u >= 1
121
+
122
+ Guarantees: resm and resl are non-overlapping
123
+ resm = round-to-nearest(resm + resl)
124
+ abs(resm) <= 2^(\gamma) * abs(resh)
125
+ where
126
+ \gamma >= min(48,b_o-4,b_o+b_u-4)
127
+ resh+resm+resl=(ah+al) * (bh+bm+bl) * (1+eps)
128
+ where
129
+ abs(eps) <=
130
+ (2^(-99-b_o) + 2^(-99-b_o-b_u) + 2^(-152)) /
131
+ (1 - 2^(-53) - 2^(-b_o+1) - 2^(-b_o-b_u+1))
132
+
133
+ Details: resh, resm and resl are considered to be pointers
134
+ */
135
+ #define Mul233(resh, resm, resl, ah, al, bh, bm, bl) \
136
+ { \
137
+ double _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10; \
138
+ double _t11, _t12, _t13, _t14, _t15, _t16, _t17, _t18; \
139
+ \
140
+ Mul12((resh),&_t1,(ah),(bh)); \
141
+ Mul12(&_t2,&_t3,(ah),(bm)); \
142
+ Mul12(&_t4,&_t5,(ah),(bl)); \
143
+ Mul12(&_t6,&_t7,(al),(bh)); \
144
+ Mul12(&_t8,&_t9,(al),(bm)); \
145
+ _t10 = (al) * (bl); \
146
+ Add22Cond(&_t11,&_t12,_t2,_t3,_t4,_t5); \
147
+ Add22Cond(&_t13,&_t14,_t6,_t7,_t8,_t9); \
148
+ Add22Cond(&_t15,&_t16,_t11,_t12,_t13,_t14); \
149
+ Add12Cond(_t17,_t18,_t1,_t10); \
150
+ Add22Cond((resm),(resl),_t17,_t18,_t15,_t16); \
151
+ }
152
+
153
+
154
+
155
+
156
+ /* Add33
157
+
158
+ Procedure for adding two triple double numbers resulting
159
+ in a triple double number
160
+
161
+
162
+ Arguments: two triple double numbers:
163
+ ah, am, al and
164
+ bh, bm, bl
165
+
166
+ Results: a triple double number resh, resm, resl
167
+
168
+ Preconditions: abs(bh) <= 0.75 * abs(ah) (i)
169
+ abs(am) <= 2^(-a_o) * abs(ah)
170
+ abs(al) <= 2^(-a_u) * abs(am)
171
+ abs(bm) <= 2^(-b_o) * abs(bh)
172
+ abs(bl) <= 2^(-b_u) * abs(bm)
173
+ where
174
+ b_o >= a_o >= 4
175
+ b_u >= a_u >= 4
176
+
177
+ Condition (i) may not be respected if
178
+ one can assume in this case that ah=am=al
179
+
180
+ Guarantees: resm and resl are non-overlapping
181
+ resm = round-to-nearest(resm + resl)
182
+ abs(resm) <= 2^(-min(a_o,b_o) + 5) * abs(resh)
183
+ resh+resm+resl = (ah+am+al + bh+bm+bl) * (1+eps)
184
+ where
185
+ abs(eps) <= 2^(-min(a_o+a_u,b_o+b_u)-47) + 2^(-min(a_o,a_u)-98)
186
+
187
+ Details: resh, resm and resl are considered to be pointers
188
+ */
189
+ #define Add33(resh, resm, resl, ah, am, al, bh, bm, bl) \
190
+ { \
191
+ double _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8; \
192
+ \
193
+ Add12((*(resh)),_t1,(ah),(bh)); \
194
+ Add12Cond(_t2,_t3,(am),(bm)); \
195
+ _t6 = (al) + (bl); \
196
+ Add12Cond(_t7,_t4,_t1,_t2); \
197
+ _t5 = _t3 + _t4; \
198
+ _t8 = _t5 + _t6; \
199
+ Add12Cond((*(resm)),(*(resl)),_t7,_t8); \
200
+ }
201
+
202
+
203
+
204
+ /* Add233
205
+
206
+ Procedure for adding a double double number to a triple
207
+ double number resulting in a triple double number
208
+
209
+
210
+ Arguments: a double double number ah, al
211
+ a triple double number bh, bm, bl
212
+
213
+ Results: a triple double number resh, resm, resl
214
+
215
+ Preconditions: abs(ah) > abs(al)
216
+ ah and al do not overlap
217
+ ah = round-to-nearest(ah + al)
218
+ abs(bh) <= 2^(-2) * abs(ah)
219
+ abs(bm) <= 2^(-b_o) * abs(bh)
220
+ abs(bl) <= 2^(-b_u) * abs(bm)
221
+ where
222
+ b_o >= 2
223
+ b_u >= 1
224
+
225
+ Guarantees: resm and resl are non-overlapping
226
+ resm = round-to-nearest(resm + resl)
227
+ abs(resm) <= 2^(\gamma) * abs(resh)
228
+ where
229
+ \gamma >= min(45,b_o-4,b_o+b_u-2)
230
+ resh+resm+resl=((ah+al) + (bh+bm+bl)) * (1+eps)
231
+ where
232
+ abs(eps) <=
233
+ <= 2^(-b_o-b_u-52) + 2^(-b_o-104) + 2^(-153)
234
+
235
+ Details: resh, resm and resl are considered to be pointers
236
+ */
237
+ #define Add233(resh, resm, resl, ah, al, bh, bm, bl) \
238
+ { \
239
+ double _t1, _t2, _t3, _t4, _t5, _t6, _t7; \
240
+ \
241
+ Add12((*(resh)),_t1,(ah),(bh)); \
242
+ Add12Cond(_t2,_t3,(al),(bm)); \
243
+ Add12Cond(_t4,_t5,_t1,_t2); \
244
+ _t6 = _t3 + (bl); \
245
+ _t7 = _t6 + _t5; \
246
+ Add12Cond((*(resm)),(*(resl)),_t4,_t7); \
247
+ }
248
+
249
+ /* Add233Cond
250
+
251
+ Procedure for adding a double double number to a triple
252
+ double number resulting in a triple double number
253
+
254
+
255
+ Arguments: a double double number ah, al
256
+ a triple double number bh, bm, bl
257
+
258
+ Results: a triple double number resh, resm, resl
259
+
260
+ Preconditions: abs(ah) > abs(al)
261
+ ah and al do not overlap
262
+ ah = round-to-nearest(ah + al)
263
+ abs(bm) <= 2^(-b_o) * abs(bh)
264
+ abs(bl) <= 2^(-b_u) * abs(bm)
265
+ where
266
+ b_o >= 2
267
+ b_u >= 1
268
+
269
+ Guarantees: resm and resl are non-overlapping
270
+ resm = round-to-nearest(resm + resl)
271
+ abs(resm) <= 2^(\gamma) * abs(resh)
272
+ where
273
+ \gamma >= ????
274
+ resh+resm+resl=((ah+al) + (bh+bm+bl)) * (1+eps)
275
+ where
276
+ abs(eps) <=
277
+ <= ????
278
+
279
+ Details: resh, resm and resl are considered to be pointers
280
+ */
281
+ #define Add233Cond(resh, resm, resl, ah, al, bh, bm, bl) \
282
+ { \
283
+ double _t1, _t2, _t3, _t4, _t5, _t6, _t7; \
284
+ \
285
+ Add12Cond((*(resh)),_t1,(ah),(bh)); \
286
+ Add12Cond(_t2,_t3,(al),(bm)); \
287
+ Add12Cond(_t4,_t5,_t1,_t2); \
288
+ _t6 = _t3 + (bl); \
289
+ _t7 = _t6 + _t5; \
290
+ Add12Cond((*(resm)),(*(resl)),_t4,_t7); \
291
+ }
292
+
293
+
294
+
295
+
296
+ /* Mul33
297
+
298
+ Procedure for multiplying two triple double numbers resulting
299
+ in a triple double number
300
+
301
+
302
+ Arguments: two triple double numbers:
303
+ ah, am, al and
304
+ bh, bm, bl
305
+
306
+ Results: a triple double number resh, resm, resl
307
+
308
+ Preconditions: abs(am) <= 2^(-a_o) * abs(ah)
309
+ abs(al) <= 2^(-a_u) * abs(am)
310
+ abs(bm) <= 2^(-b_o) * abs(bh)
311
+ abs(bl) <= 2^(-b_u) * abs(bm)
312
+ where
313
+ b_o >= a_o >= 4
314
+ b_u >= a_u >= 4
315
+
316
+
317
+ Guarantees: resm and resl are non-overlapping
318
+ resm = round-to-nearest(resm + resl)
319
+ abs(resm) <= 2^(???) * abs(resh)
320
+ resh+resm+resl = (ah+am+al + bh+bm+bl) * (1+eps)
321
+ where
322
+ abs(eps) <= 2^???
323
+
324
+ Details: resh, resm and resl are considered to be pointers
325
+ */
326
+ #define Mul33(resh, resm, resl, ah, am, al, bh, bm, bl) \
327
+ { \
328
+ double _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9; \
329
+ double _t10, _t11, _t12, _t13, _t14, _t15, _t16, _t17; \
330
+ double _t18, _t19, _t20, _t21, _t22, _t23, _t24, _t25; \
331
+ double _t26, _t27, _t28, _t29, _t30; \
332
+ \
333
+ Mul12((resh),&_t1,(ah),(bh)); \
334
+ Mul12(&_t2, &_t3, (ah), (bm)); \
335
+ Mul12(&_t4, &_t5, (am), (bh)); \
336
+ Mul12(&_t6, &_t7, (am), (bm)); \
337
+ Mul12(&_t8, &_t9, (ah), (bl)); \
338
+ Mul12(&_t10, &_t11, (al), (bh)); \
339
+ Mul12(&_t12, &_t13, (am), (bl)); \
340
+ Mul12(&_t14, &_t15, (al), (bm)); \
341
+ _t16 = (al) * (bl); \
342
+ Add12Cond(_t27,_t28,_t1,_t16); \
343
+ Add22Cond(&_t17,&_t18,_t2,_t3,_t4,_t5); \
344
+ Add22Cond(&_t19,&_t20,_t8,_t9,_t10,_t11); \
345
+ Add22Cond(&_t21,&_t22,_t12,_t13,_t14,_t15); \
346
+ Add22Cond(&_t23,&_t24,_t17,_t18,_t6,_t7); \
347
+ Add22Cond(&_t25,&_t26,_t19,_t20,_t21,_t22); \
348
+ Add22Cond(&_t29,&_t30,_t23,_t24,_t25,_t26); \
349
+ Add22Cond((resm),(resl),_t27,_t28,_t29,_t30); \
350
+ }
351
+
352
+
353
+ /* Mul133
354
+
355
+ Procedure for multiplying double by a triple double number resulting
356
+ in a triple double number
357
+
358
+
359
+ Arguments: a double a
360
+ a triple double bh, bm, bl
361
+
362
+ Results: a triple double number resh, resm, resl
363
+
364
+ Preconditions: abs(bm) <= 2^(-b_o) * abs(bh)
365
+ abs(bl) <= 2^(-b_u) * abs(bm)
366
+ where
367
+ b_o >= 2
368
+ b_u >= 2
369
+
370
+
371
+ Guarantees: // TO DO
372
+
373
+
374
+ resh+resm+resl = (ah+am+al + bh+bm+bl) * (1+eps)
375
+ where
376
+ abs(eps) <= 2^(-b_o-b_u-49) + 2^(-b_o-101) + 2^-156
377
+
378
+ Details: resh, resm and resl are considered to be pointers
379
+ */
380
+ #define Mul133(resh, resm, resl, a, bh, bm, bl) \
381
+ { \
382
+ double _t2, _t3, _t4, _t5, _t7, _t8; \
383
+ \
384
+ Mul12((resh),&_t2,(a),(bh)); \
385
+ Mul12(&_t3,&_t4,(a),(bm)); \
386
+ _t5 = (a) * (bl); \
387
+ Add12Cond((*(resm)),_t7,_t2,_t3); \
388
+ _t8 = _t4 + _t5; \
389
+ *(resl) = _t7 + _t8; \
390
+ }
391
+
392
+
393
+ /* ReturnRoundToNearest3
394
+
395
+ Procedure for rounding a triple to a double number
396
+ in round-to-nearest-ties-to-even mode.
397
+
398
+
399
+ Arguments: a triple double number xh, xm, xl
400
+
401
+ Results: a double number xprime
402
+ returned by a return-statement
403
+
404
+ Preconditions: xh, xm and xl are non-overlapping
405
+ xm = RN(xm +math xl)
406
+ xh != 0, xm != 0
407
+ xl = 0 iff xm != +/- 0.5 * ulp(xh) (0.25 if xh = 2^e)
408
+
409
+ Guarantees: xprime = RN(xh + xm + xl)
410
+
411
+ Sideeffects: returns, i.e. leaves the function
412
+
413
+ */
414
+ #define ReturnRoundToNearest3(xh,xm,xl) \
415
+ { \
416
+ double _t1, _t2, _t3, _t4, _t5, _t6; \
417
+ db_number _xp, _xn; \
418
+ \
419
+ _xp.d = (xh); \
420
+ _xn.i[HI] = _xp.i[HI]; \
421
+ _xn.i[LO] = _xp.i[LO]; \
422
+ _xn.l--; \
423
+ _t1 = _xn.d; \
424
+ _xp.l++; \
425
+ _t4 = _xp.d; \
426
+ _t2 = (xh) - _t1; \
427
+ _t3 = _t2 * -0.5; \
428
+ _t5 = _t4 - (xh); \
429
+ _t6 = _t5 * 0.5; \
430
+ if (((xm) != _t3) && ((xm) != _t6)) return ((xh) + (xm)); \
431
+ if ((xm) * (xl) > 0.0) { \
432
+ if ((xh) * (xl) > 0.0) \
433
+ return _t4; \
434
+ else \
435
+ return _t1; \
436
+ } else return (xh); \
437
+ }
438
+
439
+ /* ReturnRoundUpwards3
440
+
441
+ Procedure for rounding a triple to a double number
442
+ in round-upwards mode.
443
+
444
+
445
+ Arguments: a triple double number xh, xm, xl
446
+
447
+ Results: a double number xprime
448
+ returned by a return-statement
449
+
450
+ Preconditions: xh, xm and xl are non-overlapping
451
+ xm = RN(xm +math xl)
452
+ xh != 0, xm != 0
453
+
454
+ Exact algebraic images have already
455
+ been filtered out.
456
+
457
+ Guarantees: xprime = RU(xh + xm + xl)
458
+
459
+ Sideeffects: returns, i.e. leaves the function
460
+
461
+ */
462
+ #define ReturnRoundUpwards3(xh,xm,xl) \
463
+ { \
464
+ double _t1, _t2, _t3; \
465
+ db_number _tdb; \
466
+ \
467
+ Add12(_t1,_t2,(xh),(xm)); \
468
+ _t3 = _t2 + (xl); \
469
+ if (_t3 > 0.0) { \
470
+ if (_t1 > 0.0) { \
471
+ _tdb.d = _t1; \
472
+ _tdb.l++; \
473
+ return _tdb.d; \
474
+ } else { \
475
+ _tdb.d = _t1; \
476
+ _tdb.l--; \
477
+ return _tdb.d; \
478
+ } \
479
+ } else return _t1; \
480
+ }
481
+
482
+
483
+ /* ReturnRoundDownwards3
484
+
485
+ Procedure for rounding a triple to a double number
486
+ in round-downwards mode.
487
+
488
+
489
+ Arguments: a triple double number xh, xm, xl
490
+
491
+ Results: a double number xprime
492
+ returned by a return-statement
493
+
494
+ Preconditions: xh, xm and xl are non-overlapping
495
+ xm = RN(xm +math xl)
496
+ xh != 0, xm != 0
497
+
498
+ Exact algebraic images have already
499
+ been filtered out.
500
+
501
+ Guarantees: xprime = RD(xh + xm + xl)
502
+
503
+ Sideeffects: returns, i.e. leaves the function
504
+
505
+ */
506
+ #define ReturnRoundDownwards3(xh,xm,xl) \
507
+ { \
508
+ double _t1, _t2, _t3; \
509
+ db_number _tdb; \
510
+ \
511
+ Add12(_t1,_t2,(xh),(xm)); \
512
+ _t3 = _t2 + (xl); \
513
+ if (_t3 < 0.0) { \
514
+ if (_t1 > 0.0) { \
515
+ _tdb.d = _t1; \
516
+ _tdb.l--; \
517
+ return _tdb.d; \
518
+ } else { \
519
+ _tdb.d = _t1; \
520
+ _tdb.l++; \
521
+ return _tdb.d; \
522
+ } \
523
+ } else return _t1; \
524
+ }
525
+
526
+
527
+ /* ReturnRoundTowardsZero3
528
+
529
+ Procedure for rounding a triple to a double number
530
+ in round-towards-zero mode.
531
+
532
+
533
+ Arguments: a triple double number xh, xm, xl
534
+
535
+ Results: a double number xprime
536
+ returned by a return-statement
537
+
538
+ Preconditions: xh, xm and xl are non-overlapping
539
+ xm = RN(xm +math xl)
540
+ xh != 0, xm != 0
541
+
542
+ Exact algebraic images have already
543
+ been filtered out.
544
+
545
+ Guarantees: xprime = RZ(xh + xm + xl)
546
+
547
+ Sideeffects: returns, i.e. leaves the function
548
+
549
+ */
550
+ #define ReturnRoundTowardsZero3(xh,xm,xl) \
551
+ { \
552
+ double _t1, _t2, _t3; \
553
+ db_number _tdb; \
554
+ \
555
+ Add12(_t1,_t2,(xh),(xm)); \
556
+ _t3 = _t2 + (xl); \
557
+ if (_t1 > 0.0) { \
558
+ if (_t3 < 0.0) { \
559
+ _tdb.d = _t1; \
560
+ _tdb.l--; \
561
+ return _tdb.d; \
562
+ } else return _t1; \
563
+ } else { \
564
+ if (_t3 > 0.0) { \
565
+ _tdb.d = _t1; \
566
+ _tdb.l--; \
567
+ return _tdb.d; \
568
+ } else return _t1; \
569
+ } \
570
+ }
571
+
572
+
573
+ /* ReturnRoundUpwards3Unfiltered
574
+
575
+ Procedure for rounding a triple to a double number
576
+ in round-upwards mode.
577
+
578
+
579
+ Arguments: a triple double number xh, xm, xl
580
+ a double constant wca representing 2^k
581
+ where 2^-k is Lefevre's worst case accuracy
582
+
583
+ Results: a double number xprime
584
+ returned by a return-statement
585
+
586
+ Preconditions: xh, xm and xl are non-overlapping
587
+ xm = RN(xm +math xl)
588
+ xh != 0, xm != 0
589
+
590
+ Guarantees: xprime = RU(xh + xm + xl)
591
+
592
+ Sideeffects: returns, i.e. leaves the function
593
+
594
+ */
595
+ #define ReturnRoundUpwards3Unfiltered(xh,xm,xl,wca) \
596
+ { \
597
+ double _t1, _t2, _t3; \
598
+ db_number _tdb, _tdb2; \
599
+ \
600
+ Add12(_t1,_t2,(xh),(xm)); \
601
+ _t3 = _t2 + (xl); \
602
+ if (_t3 > 0.0) { \
603
+ _tdb2.d = wca * _t3; \
604
+ _tdb.d = _t1; \
605
+ if ((_tdb2.i[HI] & 0x7ff00000) < (_tdb.i[HI] & 0x7ff00000)) \
606
+ return _t1; \
607
+ if (_t1 > 0.0) { \
608
+ _tdb.l++; \
609
+ return _tdb.d; \
610
+ } else { \
611
+ _tdb.l--; \
612
+ return _tdb.d; \
613
+ } \
614
+ } else return _t1; \
615
+ }
616
+
617
+
618
+
619
+ /* ReturnRoundDownwards3Unfiltered
620
+
621
+ Procedure for rounding a triple to a double number
622
+ in round-downwards mode.
623
+
624
+
625
+ Arguments: a triple double number xh, xm, xl
626
+ a double constant wca representing 2^k
627
+ where 2^-k is Lefevre's worst case accuracy
628
+
629
+ Results: a double number xprime
630
+ returned by a return-statement
631
+
632
+ Preconditions: xh, xm and xl are non-overlapping
633
+ xm = RN(xm +math xl)
634
+ xh != 0, xm != 0
635
+
636
+ Guarantees: xprime = RD(xh + xm + xl)
637
+
638
+ Sideeffects: returns, i.e. leaves the function
639
+
640
+ */
641
+ #define ReturnRoundDownwards3Unfiltered(xh,xm,xl,wca) \
642
+ { \
643
+ double _t1, _t2, _t3; \
644
+ db_number _tdb, _tdb2; \
645
+ \
646
+ Add12(_t1,_t2,(xh),(xm)); \
647
+ _t3 = _t2 + (xl); \
648
+ if (_t3 < 0.0) { \
649
+ _tdb2.d = wca * _t3; \
650
+ _tdb.d = _t1; \
651
+ if ((_tdb2.i[HI] & 0x7ff00000) < (_tdb.i[HI] & 0x7ff00000)) \
652
+ return _t1; \
653
+ if (_t1 > 0.0) { \
654
+ _tdb.l--; \
655
+ return _tdb.d; \
656
+ } else { \
657
+ _tdb.l++; \
658
+ return _tdb.d; \
659
+ } \
660
+ } else return _t1; \
661
+ }
662
+
663
+ /* ReturnRoundTowardsZero3Unfiltered
664
+
665
+ Procedure for rounding a triple to a double number
666
+ in round-towards-zero mode.
667
+
668
+
669
+ Arguments: a triple double number xh, xm, xl
670
+ a double constant wca representing 2^k
671
+ where 2^-k is Lefevre's worst case accuracy
672
+
673
+ Results: a double number xprime
674
+ returned by a return-statement
675
+
676
+ Preconditions: xh, xm and xl are non-overlapping
677
+ xm = RN(xm +math xl)
678
+ xh != 0, xm != 0
679
+
680
+ Guarantees: xprime = RZ(xh + xm + xl)
681
+
682
+ Sideeffects: returns, i.e. leaves the function
683
+
684
+ */
685
+ #define ReturnRoundTowardsZero3Unfiltered(xh,xm,xl,wca) \
686
+ { \
687
+ if ((xh) > 0) \
688
+ ReturnRoundDownwards3Unfiltered((xh),(xm),(xl),(wca)) \
689
+ else \
690
+ ReturnRoundUpwards3Unfiltered((xh),(xm),(xl),(wca)) \
691
+ }
692
+
693
+ /* RoundToNearest3
694
+
695
+ Procedure for rounding a triple to a double number
696
+ in round-to-nearest-ties-to-even mode.
697
+
698
+
699
+ Arguments: a triple double number xh, xm, xl
700
+
701
+ Results: a double number xprime
702
+ returned by a return-statement
703
+
704
+ Preconditions: xh, xm and xl are non-overlapping
705
+ xm = RN(xm +math xl)
706
+ xh != 0, xm != 0
707
+ xl = 0 iff xm != +/- 0.5 * ulp(xh) (0.25 if xh = 2^e)
708
+
709
+ Guarantees: xprime = RN(xh + xm + xl)
710
+
711
+ Details: res is considered to be a pointer
712
+
713
+ */
714
+ #define RoundToNearest3(res,xh,xm,xl) \
715
+ { \
716
+ double _t1, _t2, _t3, _t4, _t5, _t6; \
717
+ db_number _xp, _xn; \
718
+ \
719
+ _xp.d = (xh); \
720
+ _xn.i[HI] = _xp.i[HI]; \
721
+ _xn.i[LO] = _xp.i[LO]; \
722
+ _xn.l--; \
723
+ _t1 = _xn.d; \
724
+ _xp.l++; \
725
+ _t4 = _xp.d; \
726
+ _t2 = (xh) - _t1; \
727
+ _t3 = _t2 * -0.5; \
728
+ _t5 = _t4 - (xh); \
729
+ _t6 = _t5 * 0.5; \
730
+ if (((xm) != _t3) && ((xm) != _t6)) \
731
+ (*(res)) = ((xh) + (xm)); \
732
+ else { \
733
+ if ((xm) * (xl) > 0.0) { \
734
+ if ((xh) * (xl) > 0.0) \
735
+ (*(res)) = _t4; \
736
+ else \
737
+ (*(res)) = _t1; \
738
+ } else (*(res)) = (xh); \
739
+ } \
740
+ }
741
+
742
+ /* RoundUpwards3
743
+
744
+ Procedure for rounding a triple to a double number
745
+ in round-upwards mode.
746
+
747
+
748
+ Arguments: a triple double number xh, xm, xl
749
+
750
+ Results: a double number xprime
751
+ returned by a return-statement
752
+
753
+ Preconditions: xh, xm and xl are non-overlapping
754
+ xm = RN(xm +math xl)
755
+ xh != 0, xm != 0
756
+
757
+ Exact algebraic images have already
758
+ been filtered out.
759
+
760
+ Guarantees: xprime = RU(xh + xm + xl)
761
+
762
+ Details: res is considered to be a pointer
763
+
764
+ */
765
+ #define RoundUpwards3(res,xh,xm,xl) \
766
+ { \
767
+ double _t1, _t2, _t3; \
768
+ db_number _tdb; \
769
+ \
770
+ Add12(_t1,_t2,(xh),(xm)); \
771
+ _t3 = _t2 + (xl); \
772
+ if (_t3 > 0.0) { \
773
+ if (_t1 > 0.0) { \
774
+ _tdb.d = _t1; \
775
+ _tdb.l++; \
776
+ (*(res)) = _tdb.d; \
777
+ } else { \
778
+ _tdb.d = _t1; \
779
+ _tdb.l--; \
780
+ (*(res)) = _tdb.d; \
781
+ } \
782
+ } else (*(res)) = _t1; \
783
+ }
784
+
785
+
786
+ /* RoundDownwards3
787
+
788
+ Procedure for rounding a triple to a double number
789
+ in round-downwards mode.
790
+
791
+
792
+ Arguments: a triple double number xh, xm, xl
793
+
794
+ Results: a double number xprime
795
+ returned by a return-statement
796
+
797
+ Preconditions: xh, xm and xl are non-overlapping
798
+ xm = RN(xm +math xl)
799
+ xh != 0, xm != 0
800
+
801
+ Exact algebraic images have already
802
+ been filtered out.
803
+
804
+ Guarantees: xprime = RD(xh + xm + xl)
805
+
806
+ Details: res is considered to be a pointer
807
+
808
+ */
809
+ #define RoundDownwards3(res,xh,xm,xl) \
810
+ { \
811
+ double _t1, _t2, _t3; \
812
+ db_number _tdb; \
813
+ \
814
+ Add12(_t1,_t2,(xh),(xm)); \
815
+ _t3 = _t2 + (xl); \
816
+ if (_t3 < 0.0) { \
817
+ if (_t1 > 0.0) { \
818
+ _tdb.d = _t1; \
819
+ _tdb.l--; \
820
+ (*(res)) = _tdb.d; \
821
+ } else { \
822
+ _tdb.d = _t1; \
823
+ _tdb.l++; \
824
+ (*(res)) = _tdb.d; \
825
+ } \
826
+ } else (*(res)) = _t1; \
827
+ }
828
+
829
+
830
+ /* RoundTowardsZero3
831
+
832
+ Procedure for rounding a triple to a double number
833
+ in round-towards-zero mode.
834
+
835
+
836
+ Arguments: a triple double number xh, xm, xl
837
+
838
+ Results: a double number xprime
839
+ returned by a return-statement
840
+
841
+ Preconditions: xh, xm and xl are non-overlapping
842
+ xm = RN(xm +math xl)
843
+ xh != 0, xm != 0
844
+
845
+ Exact algebraic images have already
846
+ been filtered out.
847
+
848
+ Guarantees: xprime = RZ(xh + xm + xl)
849
+
850
+ Details: res is considered to be a pointer
851
+
852
+ */
853
+ #define RoundTowardsZero3(res,xh,xm,xl) \
854
+ { \
855
+ double _t1, _t2, _t3; \
856
+ db_number _tdb; \
857
+ \
858
+ Add12(_t1,_t2,(xh),(xm)); \
859
+ _t3 = _t2 + (xl); \
860
+ if (_t1 > 0.0) { \
861
+ if (_t3 < 0.0) { \
862
+ _tdb.d = _t1; \
863
+ _tdb.l--; \
864
+ (*(res)) = _tdb.d; \
865
+ } else (*(res)) = _t1; \
866
+ } else { \
867
+ if (_t3 > 0.0) { \
868
+ _tdb.d = _t1; \
869
+ _tdb.l--; \
870
+ (*(res)) = _tdb.d; \
871
+ } else (*(res)) = _t1; \
872
+ } \
873
+ }
874
+
875
+
876
+
877
+
878
+ #endif /*TRIPLE_DOUBLE_H*/