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,249 @@
1
+ #include <stdio.h>
2
+ #include <stdlib.h>
3
+ #include <string.h>
4
+ #include <math.h>
5
+ #include "crlibm.h"
6
+ #include "crlibm_private.h"
7
+ #include "test_common.h"
8
+
9
+ #ifdef HAVE_MATHLIB_H
10
+ #include <MathLib.h>
11
+ #endif
12
+
13
+ #ifdef HAVE_MPFR_H
14
+ #include <gmp.h>
15
+ #include <mpfr.h>
16
+ #endif
17
+
18
+ /*
19
+ * TODO: migrate to the getopt() function.
20
+ *
21
+ */
22
+
23
+ static void usage(char *fct_name){
24
+ /*fprintf (stderr, "\n%s: single-value test for crlibm and other mathematical libraries\n", fct_name);*/
25
+ fprintf (stderr, "\nUsage: %s [-x] function (RN|RU|RD|RZ) value1 [value2]\n", fct_name);
26
+ fprintf (stderr, " function : name of function to test \n");
27
+ fprintf (stderr, " (RN|RU|RD|RZ) : rounding mode \n");
28
+ fprintf (stderr, " value1 : double precision input number (in hexadecimal if option -x is given) \n");
29
+ fprintf (stderr, " value2 : optional double precision input number (in hexadecimal if option -x is given) \n");
30
+ exit (1);
31
+ }
32
+
33
+
34
+
35
+ int main (int argc, char *argv[])
36
+ {
37
+ char* option;
38
+ char* function_name;
39
+ char* rounding_mode;
40
+ double worstcase;
41
+ int nbarg;
42
+
43
+ db_number input, input2, res_crlibm, res_libm;
44
+ #ifdef HAVE_MPFR_H
45
+ db_number res_mpfr;
46
+ mp_rnd_t mpfr_rnd_mode;
47
+ mpfr_t mp_res, mp_input,mp_input2;
48
+ #endif
49
+ #ifdef HAVE_MATHLIB_H
50
+ db_number res_ibm;
51
+ #endif
52
+ #ifdef HAVE_LIBMCR_H
53
+ db_number res_libmcr;
54
+ #endif
55
+
56
+ /* The random number generator (unused here) */
57
+ double (*randfun) () = NULL;
58
+ /* The function we test */
59
+ double (*testfun_crlibm)() = NULL;
60
+ /* The function we trust */
61
+ int (*testfun_mpfr) () = NULL;
62
+ /* The function to show off against for accuracy */
63
+ double (*testfun_libm) () = NULL;
64
+ /* The function to show off against for performance */
65
+ double (*testfun_libultim) () = NULL;
66
+ /* The last to join the family */
67
+ double (*testfun_libmcr) () = NULL;
68
+
69
+ nbarg=1;
70
+
71
+ function_name = NULL;
72
+ rounding_mode = NULL;
73
+
74
+ if (argc != 4 && argc!=5 && argc!=6) usage(argv[0]);
75
+ if(argc == 4) {
76
+ function_name = argv[1];
77
+ rounding_mode = argv[2];
78
+ sscanf(argv[3],"%le", &input.d);
79
+ }
80
+ if(argc == 5) {
81
+ option = argv[1];
82
+ if(strcmp (option, "-x") == 0){
83
+ function_name = argv[2];
84
+ rounding_mode = argv[3];
85
+ sscanf(argv[4],"%llx", &input.l);
86
+ }else {
87
+ function_name = argv[1];
88
+ rounding_mode = argv[2];
89
+ sscanf(argv[3],"%le", &input.d);
90
+ sscanf(argv[4],"%le", &input2.d);
91
+ nbarg=2;
92
+ }
93
+ }
94
+ if(argc == 6) {
95
+ option = argv[1];
96
+ if(strcmp (option, "-x") != 0) usage(argv[0]);
97
+ function_name = argv[2];
98
+ rounding_mode = argv[3];
99
+ sscanf(argv[4],"%llx", &input.l);
100
+ sscanf(argv[5],"%llx", &input2.l);
101
+ nbarg=2;
102
+ }
103
+
104
+ if ((strcmp (function_name, "pow") == 0)&&(nbarg==1)){
105
+ fprintf(stderr,"Wrong number of argument");
106
+ usage(argv[0]);
107
+ }else {
108
+ if ((strcmp (function_name, "pow") != 0)&& (nbarg == 2)){
109
+ fprintf(stderr,"Wrong number of argument");
110
+ usage(argv[0]);
111
+ }
112
+ }
113
+
114
+ crlibm_init();
115
+ #ifdef HAVE_MATHLIB_H
116
+ Init_Lib(); /* we don't save the state, no need here */
117
+ #endif
118
+
119
+ test_init(/* pointers to returned value */
120
+ &randfun, /* unused */
121
+ &randfun, /* unused */
122
+ &testfun_crlibm,
123
+ &testfun_mpfr,
124
+ &testfun_libultim,
125
+ &testfun_libmcr,
126
+ &testfun_libm,
127
+ &worstcase,
128
+ /* arguments */
129
+ function_name,
130
+ rounding_mode ) ;
131
+
132
+
133
+
134
+ #ifdef HAVE_MPFR_H /* stop here if MPFR not present */
135
+ mpfr_init2(mp_res, 153);
136
+ mpfr_init2(mp_input, 53);
137
+ mpfr_init2(mp_input2, 53);
138
+ if (strcmp(rounding_mode,"RU")==0) mpfr_rnd_mode = GMP_RNDU;
139
+ else if (strcmp(rounding_mode,"RD")==0) mpfr_rnd_mode = GMP_RNDD;
140
+ else if (strcmp(rounding_mode,"RZ")==0) mpfr_rnd_mode = GMP_RNDZ;
141
+ else {
142
+ mpfr_rnd_mode = GMP_RNDN;
143
+ rounding_mode="RN" ;
144
+ }
145
+ #endif
146
+
147
+
148
+
149
+ printf("Input1 : %.50e %08x %08x\n", input.d, input.i[HI], input.i[LO] );
150
+ if (nbarg==2)
151
+ printf("Input2 : %.50e %08x %08x\n", input2.d, input2.i[HI], input2.i[LO] );
152
+
153
+ printf("cr_libm : ");
154
+ fflush(stdout); /* To help debugging */
155
+ if(testfun_crlibm != NULL) {
156
+ if (nbarg==1) res_crlibm.d = testfun_crlibm(input.d);
157
+ if (nbarg==2) res_crlibm.d = testfun_crlibm(input.d, input2.d);
158
+
159
+ printf("%.50e %08x %08x\n",
160
+ res_crlibm.d,
161
+ res_crlibm.i[HI],
162
+ res_crlibm.i[LO] );
163
+ }else
164
+ printf("Not available\n");
165
+ fflush(stdout);
166
+
167
+ #ifdef HAVE_MPFR_H
168
+ printf("mpfr_libm : ");
169
+ fflush(stdout);
170
+ if(testfun_mpfr != NULL){
171
+ mpfr_set_d(mp_input, input.d, GMP_RNDN);
172
+
173
+ if (nbarg==1) testfun_mpfr(mp_res, mp_input, mpfr_rnd_mode);
174
+ if (nbarg==2) {
175
+ mpfr_set_d(mp_input2, input2.d, GMP_RNDN);
176
+ testfun_mpfr(mp_res, mp_input, mp_input2, mpfr_rnd_mode);
177
+ }
178
+
179
+ res_mpfr.d = mpfr_get_d(mp_res, mpfr_rnd_mode);
180
+ printf("%.50e %08x %08x \n",
181
+ res_mpfr.d,
182
+ res_mpfr.i[HI],
183
+ res_mpfr.i[LO] );
184
+ }else
185
+ printf("Not available\n");
186
+ fflush(stdout);
187
+ #endif
188
+
189
+
190
+
191
+ #ifdef HAVE_MATHLIB_H
192
+ printf("libultim : ");
193
+ fflush(stdout);
194
+ if(testfun_libultim != NULL) {
195
+ if (nbarg==1) res_ibm.d = testfun_libultim(input.d);
196
+ if (nbarg==2) res_ibm.d = testfun_libultim(input.d, input2.d);
197
+ printf("%.50e %08x %08x \n",
198
+ res_ibm.d,
199
+ res_ibm.i[HI],
200
+ res_ibm.i[LO] );
201
+ }else
202
+ printf("Not available\n");
203
+ fflush(stdout);
204
+ #endif
205
+
206
+ #ifdef HAVE_LIBMCR_H
207
+ printf("libmcr : ");
208
+ fflush(stdout);
209
+ if(testfun_libmcr != NULL) {
210
+ if (nbarg==1) res_libmcr.d = testfun_libmcr(input.d);
211
+ if (nbarg==2) res_libmcr.d = testfun_libmcr(input.d, input2.d);
212
+ printf("%.50e %08x %08x \n",
213
+ res_libmcr.d,
214
+ res_libmcr.i[HI],
215
+ res_libmcr.i[LO] );
216
+ }else
217
+ printf("Not available\n");
218
+ fflush(stdout);
219
+ #endif
220
+
221
+
222
+
223
+ /* Last in the list because it segfaults more often than the
224
+ others. */
225
+ printf("System libm: ");
226
+ fflush(stdout);
227
+ if(testfun_libm != NULL) {
228
+ if (nbarg==1) res_libm.d = testfun_libm(input.d);
229
+ if (nbarg==2) res_libm.d = testfun_libm(input.d, input2.d);
230
+ printf("%.50e %08x %08x \n",
231
+ res_libm.d,
232
+ res_libm.i[HI],
233
+ res_libm.i[LO]) ;
234
+ }else
235
+ printf("Not available\n");
236
+ fflush(stdout);
237
+
238
+ /* release memory */
239
+ #ifdef HAVE_MPFR_H
240
+ mpfr_clear(mp_input2);
241
+ mpfr_clear(mp_input);
242
+ mpfr_clear(mp_res);
243
+ #endif
244
+
245
+ return 0;
246
+ }
247
+
248
+
249
+