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,324 @@
1
+ /*
2
+ * Correctly rounded arctangent
3
+ *
4
+ * Author : Nicolas Gast (Ecole Normale Superieure), Florent de Dinechin
5
+ *
6
+ * This file is part of the crlibm library developed by the Arenaire
7
+ * project at Ecole Normale Superieure de Lyon
8
+ *
9
+ * This program is free software; you can redistribute it and/or modify
10
+ * it under the terms of the GNU Lesser General Public License as published by
11
+ * the Free Software Foundation; either version 2 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU Lesser General Public License
20
+ * along with this program; if not, write to the Free Software
21
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
+ */
23
+
24
+ #include <stdio.h>
25
+ #include <stdlib.h>
26
+ #include "crlibm.h"
27
+ #include "crlibm_private.h"
28
+ #include "atan_fast.h"
29
+
30
+
31
+ static void atan_quick(double *atanhi,double *atanlo, int *index_of_e, double x) {
32
+
33
+ double tmphi,tmplo, x0hi,x0lo;
34
+ double q,Xred2,x2;
35
+ double Xredhi,Xredlo;
36
+ double xmBihi, xmBilo, tmphi2, tmplo2, atanlolo;
37
+
38
+ int i;
39
+
40
+ if (x > MIN_REDUCTION_NEEDED) /* test if reduction is necessary : */
41
+ {
42
+ /*
43
+ * 1) Argument reduction :
44
+ *
45
+ * tan(x) = tan( b(i) ) + tan ( (x-b(i)) / (1+x*b(i)))
46
+ *
47
+ * 6.3
48
+ * we choose 62 b(i) so that (x-b(i)) / (1+x*b(i)) < 2^
49
+ */
50
+
51
+
52
+
53
+ if (x > arctan_table[61][B].d) {
54
+ i=61;
55
+ Add12( xmBihi , xmBilo , x , -arctan_table[61][B].d);
56
+ }
57
+ else
58
+ {
59
+ /* compute i so that a[i] < x < a[i+1] */
60
+ i=31;
61
+ if (x < arctan_table[i][A].d) i-= 16;
62
+ else i+=16;
63
+ if (x < arctan_table[i][A].d) i-= 8;
64
+ else i+= 8;
65
+ if (x < arctan_table[i][A].d) i-= 4;
66
+ else i+= 4;
67
+ if (x < arctan_table[i][A].d) i-= 2;
68
+ else i+= 2;
69
+ if (x < arctan_table[i][A].d) i-= 1;
70
+ else i+= 1;
71
+ if (x < arctan_table[i][A].d) i-= 1;
72
+ xmBihi = x-arctan_table[i][B].d;
73
+ xmBilo = 0.0;
74
+ }
75
+
76
+ /* we now compute Xred = ( x-b[i] ) / ( 1 + x*b[i] )
77
+ *
78
+ * def : x0 := 1+x*b[i]
79
+ *
80
+ * 1st we compute an approximation of y = 1/x0
81
+ * then we compute a better approx x' = y*(2-x0*y)
82
+ * we can proove that :
83
+ * if y = 1/x0*(1+e)
84
+ * then x' = 1/x0 * (1-e^2)
85
+ *
86
+ */
87
+
88
+ Mul12(&tmphi,&tmplo, x, arctan_table[i][B].d);
89
+
90
+ if (x > 1)
91
+ Add22(&x0hi,&x0lo,tmphi,tmplo, 1.0,0.0);
92
+ else {Add22( &x0hi , &x0lo , 1.0,0.0,tmphi,tmplo);}
93
+
94
+ Div22( &Xredhi, &Xredlo, xmBihi , xmBilo , x0hi,x0lo);
95
+
96
+ /* Polynomial evaluation :
97
+ *
98
+ * 1rt compute Q(x^2) = (1 - x^2/3 + ...)
99
+ * then P(x) = x * Q(x^2)
100
+ *
101
+ */
102
+
103
+ Xred2 = Xredhi*Xredhi;
104
+
105
+ q = Xred2*(coef_poly[3]+Xred2*
106
+ (coef_poly[2]+Xred2*
107
+ (coef_poly[1]+Xred2*
108
+ coef_poly[0]))) ;
109
+
110
+ /* reconstruction : atan(x) = atan(b[i]) + atan(x) */
111
+ atanlolo = (Xredlo + arctan_table[i][ATAN_BLO].d);
112
+ atanlolo += Xredhi*q;
113
+ Add12( tmphi2, tmplo2, arctan_table[i][ATAN_BHI].d, Xredhi);
114
+ Add12( *atanhi, *atanlo, tmphi2, (tmplo2+atanlolo));
115
+
116
+ if (i<10)
117
+ *index_of_e = 0;
118
+ else
119
+ *index_of_e = 1;
120
+ }
121
+ else
122
+ // no reduction needed
123
+ {
124
+ /* Polynomial evaluation :
125
+ *
126
+ * 1rt compute Q(x^2) = (1 - x^2/3 + ...)
127
+ * then P(x) = x * Q(x^2)
128
+ *
129
+ */
130
+
131
+ x2 = x*x;
132
+ q = x2*(coef_poly[3]+x2*
133
+ (coef_poly[2]+x2*
134
+ (coef_poly[1]+x2*
135
+ coef_poly[0]))) ;
136
+ Add12(*atanhi,*atanlo, x , x*q);
137
+
138
+ *index_of_e = 2;
139
+ }
140
+
141
+ }
142
+
143
+ /*************************************************************
144
+ *************************************************************
145
+ * ROUNDED TO NEAREST *
146
+ *************************************************************
147
+ *************************************************************/
148
+
149
+
150
+ extern double atan_rn(double x) {
151
+
152
+ double atanhi,atanlo;
153
+ int index_of_e;
154
+ double sign;
155
+ db_number x_db;
156
+ int absxhi;
157
+
158
+ x_db.d = x;
159
+ absxhi = x_db.i[HI] & 0x7fffffff;
160
+
161
+ if(x_db.i[HI] & 0x80000000){
162
+ x_db.i[HI] = absxhi;
163
+ sign =-1;
164
+ }
165
+ else
166
+ sign=1;
167
+
168
+ /* Filter cases */
169
+ if ( absxhi >= 0x43500000) /* x >= 2^54 */
170
+ {
171
+ if ((absxhi > 0x7ff00000) || ((absxhi == 0x7ff00000) && (x_db.i[LO] != 0)))
172
+ return x+x; /* NaN */
173
+ else
174
+ return sign*HALFPI.d; /* atan(+/-infty) = +/- Pi/2 */
175
+ }
176
+ if ( absxhi < 0x3E400000 )
177
+ return x; /* x<2^-27 then atan(x) =~ x */
178
+
179
+ atan_quick(&atanhi, &atanlo,&index_of_e , x_db.d);
180
+
181
+ if (atanhi == (atanhi + (atanlo*rncst[index_of_e])))
182
+ return sign*atanhi;
183
+ else
184
+ {
185
+ /* more accuracy is needed , lauch accurate phase */
186
+ return sign*scs_atan_rn(x_db.d);
187
+ }
188
+ }
189
+
190
+ /*************************************************************
191
+ *************************************************************
192
+ * ROUNDED TOWARD -INFINITY *
193
+ *************************************************************
194
+ *************************************************************/
195
+ extern double atan_rd(double x) {
196
+ double atanhi,atanlo;
197
+ int index_of_e;
198
+ double maxepsilon;
199
+ db_number x_db;
200
+ int absxhi;
201
+ int sign;
202
+
203
+ x_db.d = x;
204
+ absxhi = x_db.i[HI] & 0x7FFFFFFF;
205
+
206
+ if(x_db.i[HI] & 0x80000000){
207
+ x_db.i[HI] = absxhi;
208
+ sign =-1;
209
+ }
210
+ else
211
+ sign=1;
212
+
213
+ /* Filter cases */
214
+ if ( absxhi >= 0x43500000) /* x >= 2^54 */
215
+ {
216
+ if ((absxhi > 0x7ff00000) || ((absxhi == 0x7ff00000) && (x_db.i[LO] != 0)))
217
+ return x+x; /* NaN */
218
+ else{
219
+ if (sign>0)
220
+ return HALFPI.d;
221
+ else
222
+ return -HALFPI_TO_PLUS_INFINITY.d; /* atan(x) = Pi/2 */
223
+ }
224
+ }
225
+ else
226
+ if ( absxhi < 0x3E400000 )
227
+ {if (sign>0)
228
+ {if(x==0)
229
+ return x;
230
+ else
231
+ x_db.l--;
232
+ return x_db.d;
233
+ }
234
+ else
235
+ return x;
236
+ }
237
+
238
+ atan_quick(&atanhi, &atanlo,&index_of_e, x_db.d);
239
+ maxepsilon = epsilon[index_of_e];
240
+ atanhi = sign*atanhi;
241
+ atanlo = sign*atanlo;
242
+
243
+ /* Rounding test to - infinity */
244
+
245
+ TEST_AND_RETURN_RD(atanhi, atanlo, maxepsilon);
246
+
247
+ /* if the previous block didn't return a value, launch accurate phase */
248
+ return scs_atan_rd(sign*x_db.d);
249
+ }
250
+
251
+ /*************************************************************
252
+ *************************************************************
253
+ * ROUNDED TOWARD +INFINITY *
254
+ *************************************************************
255
+ *************************************************************/
256
+
257
+ extern double atan_ru(double x) {
258
+ double atanhi,atanlo;
259
+ int index_of_e;
260
+ int sign;
261
+ double maxepsilon;
262
+ db_number x_db;
263
+ int absxhi;
264
+
265
+ x_db.d = x;
266
+ absxhi = x_db.i[HI] & 0x7FFFFFFF;
267
+
268
+ if (x_db.i[HI] & 0x80000000){
269
+ sign = -1;
270
+ x_db.i[HI] = absxhi;
271
+ }
272
+ else
273
+ sign = 1;
274
+
275
+
276
+ /* Filter cases */
277
+ if ( absxhi >= 0x43500000) /* x >= 2^54 */
278
+ {
279
+ if ((absxhi > 0x7ff00000) || ((absxhi == 0x7ff00000) && (x_db.i[LO] != 0)))
280
+ return x+x; /* NaN */
281
+ else
282
+ {
283
+ if (sign>0)
284
+ return HALFPI_TO_PLUS_INFINITY.d;
285
+ else
286
+ return -HALFPI.d; /* atan(x) = Pi/2 */
287
+ }
288
+ }
289
+
290
+ if ( absxhi < 0x3E400000 ){
291
+ if(x==0)
292
+ return x;
293
+
294
+ if (sign<0) {
295
+ x_db.l--;
296
+ return -x_db.d;
297
+ }
298
+ else
299
+ return x;
300
+ } /* x<2^-27 then atan(x) =~ x */
301
+
302
+ atan_quick(&atanhi, &atanlo, &index_of_e, x_db.d);
303
+ maxepsilon = epsilon[index_of_e];
304
+ atanhi = sign*atanhi;
305
+ atanlo = sign*atanlo;
306
+
307
+ TEST_AND_RETURN_RU(atanhi, atanlo, maxepsilon);
308
+
309
+ /* if the previous block didn't return a value, launch accurate phase */
310
+ return scs_atan_ru(x);
311
+ }
312
+
313
+ /*************************************************************
314
+ *************************************************************
315
+ * ROUNDED TOWARD ZERO *
316
+ *************************************************************
317
+ *************************************************************/
318
+
319
+ extern double atan_rz(double x) {
320
+ if (x>0)
321
+ return atan_rd(x);
322
+ else
323
+ return atan_ru(x);
324
+ }