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,627 @@
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_MPFR_H
10
+ #include <gmp.h>
11
+ #include <mpfr.h>
12
+ #endif
13
+
14
+ #ifdef HAVE_MATHLIB_H
15
+ #include <MathLib.h>
16
+ #endif
17
+
18
+ #ifdef HAVE_LIBMCR_H
19
+ #include <libmcr.h>
20
+ #endif
21
+
22
+
23
+ /* A variable equal to zero, stored here so that the compiler doesn't
24
+ know its value in the other functions, which allows to prevent some
25
+ optimizations */
26
+
27
+
28
+ #define RN 1
29
+ #define RU 2
30
+ #define RD 3
31
+ #define RZ 4
32
+
33
+ double zero ;
34
+
35
+ /* Here come the various random number generators. They all use the
36
+ rand() function.
37
+
38
+ We may have two rand functions for each function under
39
+ test. The first is for the soaktest, the second for testing the
40
+ performance under what is supposed the main domain of use the function.
41
+
42
+ Typical examples:
43
+
44
+ log has identical functions for soaktest and performance: random
45
+ positive numbers. This means that negative numbers are not tested
46
+ by soaktest, though.
47
+
48
+ sin soaktests on all the floats, but tests for perf on a small
49
+ interval around zero, shamelessely chosen as the one on which crlibm
50
+ is the fastest.
51
+ */
52
+
53
+
54
+ /**/
55
+
56
+
57
+ /* Return 'sizeof(int)' random bits */
58
+ int rand_int(){
59
+ int val;
60
+ int i;
61
+ val = (random() & 0x000000ff);
62
+ for(i=0; i<(sizeof(int)); i++){
63
+ val = val << 8;
64
+ val += (random() & 0x000000ff ); /* we keep only 8 bits */
65
+ }
66
+ return val;
67
+ }
68
+
69
+
70
+
71
+
72
+ /* Return a completely random double */
73
+
74
+ double rand_generic(){
75
+ db_number result;
76
+
77
+ result.i[LO]=rand_int();
78
+ result.i[HI]=rand_int();
79
+
80
+ return result.d;
81
+ }
82
+
83
+
84
+ /* Return a random double between 0 and 1, with a normal law on the
85
+ exponent */
86
+
87
+ double rand_double(){
88
+ db_number result;
89
+ int e;
90
+ /*first the low bits of the mantissa*/
91
+ result.i[LO]=rand_int();
92
+ /* then the high bits of the mantissa, and the sign bit */
93
+ result.i[HI]= rand_int() & 0x000fffff;
94
+ /* Now set the exponent (negative value) */
95
+ e = rand() & 0x000003ff;
96
+ if (e>0) e-=1;
97
+ result.i[HI] += e<<20;
98
+ return (result.d);
99
+ }
100
+
101
+
102
+ /* Return a random double between 1 and 2, with a normal law on the
103
+ mantissa and a constant exponent */
104
+
105
+ double rand_double_normal(){
106
+ db_number result;
107
+ int e;
108
+ /*first the low bits of the mantissa*/
109
+ result.i[LO]=rand_int();
110
+ /* then the high bits of the mantissa, and the sign bit */
111
+ result.i[HI]= rand_int() & 0x000fffff;
112
+ /* Now set the exponent */
113
+ e = 1023;
114
+ result.i[HI] += e<<20;
115
+ return (result.d);
116
+ }
117
+
118
+
119
+
120
+ /* For exp we will test perf on numbers with a random sign, a random mantissa, and
121
+ a random exponent between -9 and 9. And we soaktest on all the doubles */
122
+
123
+ #define rand_for_exp_soaktest rand_generic
124
+
125
+ double rand_for_exp_perf(){
126
+ db_number result;
127
+ int e;
128
+
129
+ /*first the low bits of the mantissa*/
130
+ result.i[LO]=rand_int();
131
+ /* then the high bits of the mantissa, and the sign bit */
132
+ result.i[HI]= rand_int() & 0x800fffff;
133
+ /* Now set the exponent between -9 and 9, enough to cover the useful range */
134
+ e = (int) ( (rand_double_normal()-1) * 18 );
135
+ result.i[HI] += (1023 + e -9)<<20;
136
+ return result.d;
137
+ }
138
+
139
+
140
+ /* a number in the range which never produces over/underflow for the
141
+ exp function. I don't trust the randomness of this function */
142
+ double rand_for_exp_normal(){
143
+ return((750+710)*(rand_double_normal()-1)-750);
144
+ }
145
+
146
+
147
+
148
+
149
+
150
+ #define rand_for_csh_perf rand_for_exp_perf
151
+ /* I wish we could soaktest using rand_generic, but current MPFR is
152
+ very slow for small and large arguments (up to a few minutes per
153
+ call !). To check regularly, this is bound to improve. */
154
+
155
+ #define rand_for_csh_soaktest rand_for_exp_perf
156
+
157
+ /* For log we only test the positive numbers*/
158
+ double rand_for_log(){
159
+ db_number result;
160
+
161
+ /*first the low bits of the mantissa*/
162
+ result.i[LO]=rand_int();
163
+ /* then the high bits of the mantissa, and the sign bit */
164
+ result.i[HI]= rand_int() & 0x7fffffff;
165
+ /* printf("x = %1.5e\n", result.d);*/
166
+ return result.d;
167
+ }
168
+
169
+
170
+ /* For trigonometric functions it is difficult to tell what the test function should be */
171
+
172
+ double rand_for_trig_perf(){
173
+ db_number result;
174
+ int e;
175
+ /*first the low bits of the mantissa*/
176
+ result.i[LO]=rand_int();
177
+ /* then the high bits of the mantissa, and the sign bit */
178
+ result.i[HI]= rand_int() & 0x800fffff;
179
+ /* Now set the exponent between -20 and 40 */
180
+ e = (int) ( (rand_double_normal()-1) * 60 );
181
+ result.i[HI] += (1023 + e -20)<<20;
182
+ return result.d;
183
+
184
+ }
185
+
186
+ #if 0
187
+ #define rand_for_trig_soaktest rand_generic
188
+ #else
189
+ #define rand_for_trig_soaktest rand_for_trig_perf
190
+ #endif
191
+
192
+ double rand_for_atan_perf(){
193
+ db_number result;
194
+ int e;
195
+ /*first the low bits of the mantissa*/
196
+ result.i[LO]=rand_int();
197
+ /* then the high bits of the mantissa, and the sign bit */
198
+ result.i[HI]= rand_int() & 0x800fffff;
199
+ /* Now set the exponent between -20 and 50, enough to cover the useful range */
200
+ e = (int) ( (rand_double_normal()-1) * 70 );
201
+ result.i[HI] += (1023 + e -20)<<20;
202
+ return result.d;
203
+
204
+ }
205
+
206
+ double rand_for_atan_soaktest(){
207
+ db_number result;
208
+ int e;
209
+
210
+ /*first the low bits of the mantissa*/
211
+ result.i[LO]=rand_int();
212
+ /* then the high bits of the mantissa, and the sign bit */
213
+ result.i[HI]= rand_int() & 0x800fffff;
214
+ /* Now set the exponent between -20 and 50, enough to cover the useful range */
215
+ e = (int) ( (rand_double_normal()-1) * 70 );
216
+ result.i[HI] += (1023 + e -20)<<20;
217
+ return result.d;
218
+
219
+ }
220
+
221
+ /* For pow we need to test the whole range of floating point numbers
222
+ * However these definition should be slightly modified (keep x^y fp).
223
+ */
224
+ #define rand_for_pow_soaktest rand_for_exp_perf
225
+
226
+ double rand_for_pow_perf(){
227
+ db_number result;
228
+ int e;
229
+
230
+ /*first the low bits of the mantissa*/
231
+ result.i[LO]=rand_int();
232
+ /* then the high bits of the mantissa, and the sign bit */
233
+ result.i[HI]= rand_int() & 0x800fffff;
234
+ /* Now set the exponent between -7 and 7,
235
+ enough to cover the useful range (does not overflow) */
236
+ e = (int) ( (rand_double_normal()-1) * 14 );
237
+ result.i[HI] += (1023 + e -7)<<20;
238
+ return result.d;
239
+ }
240
+
241
+
242
+
243
+
244
+ void test_rand() {
245
+ int i;
246
+ double min=1e300, max=0.0;
247
+ db_number input;
248
+ for(i=0; i< 1000; i++){
249
+ input.d = rand_for_exp_perf();
250
+ if (input.d<min) min=input.d;
251
+ if (input.d>max) max=input.d;
252
+ printf("%1.5ex \t%.8x %.8x\t%1.5e \t%1.5e\n", input.d, input.i[HI], input.i[LO],min,max );
253
+ }
254
+ }
255
+
256
+
257
+
258
+
259
+
260
+ /* general init function */
261
+
262
+
263
+ void test_init(/* pointers to returned value */
264
+ double (**randfun_perf)(),
265
+ double (**randfun_soaktest)(),
266
+ double (**testfun_crlibm)(),
267
+ int (**testfun_mpfr) (),
268
+ double (**testfun_libultim) (),
269
+ double (**testfun_libmcr) (),
270
+ double (**testfun_libm) (),
271
+ double* worst_case,
272
+ /* arguments */
273
+ char *func_name,
274
+ char *rnd_mode) {
275
+
276
+ int crlibm_rnd_mode;
277
+
278
+ /* We have added the rounding mode designation used in libmcr's test files */
279
+ if ((strcmp(rnd_mode,"RU")==0) || (strcmp(rnd_mode,"P")==0)) crlibm_rnd_mode = RU;
280
+ else if ((strcmp(rnd_mode,"RD")==0) || (strcmp(rnd_mode,"M")==0)) crlibm_rnd_mode = RD;
281
+ else if ((strcmp(rnd_mode,"RZ")==0) || (strcmp(rnd_mode,"Z")==0)) crlibm_rnd_mode = RZ;
282
+ else if ((strcmp(rnd_mode,"RN")==0) || (strcmp(rnd_mode,"N")==0)) crlibm_rnd_mode = RN;
283
+ else {
284
+ fprintf(stderr, "Unknown rounding mode: %s, exiting\n", rnd_mode);
285
+ exit(EXIT_FAILURE);
286
+ }
287
+
288
+
289
+ *randfun_perf = rand_generic; /* the default random function */
290
+ *randfun_soaktest = rand_generic; /* the default random function */
291
+ *testfun_mpfr = NULL;
292
+ *testfun_libm = NULL;
293
+ *worst_case=0.;
294
+
295
+ if (strcmp (func_name, "exp") == 0)
296
+ {
297
+ *randfun_perf = rand_for_exp_perf;
298
+ *randfun_soaktest = rand_for_exp_soaktest;
299
+ *worst_case= .75417527749959590085206221024712557043923055744016892276704311370849609375e-9;
300
+ *testfun_libm = exp;
301
+ switch(crlibm_rnd_mode){
302
+ case RU:
303
+ *testfun_crlibm = exp_ru; break;
304
+ case RD:
305
+ *testfun_crlibm = exp_rd; break;
306
+ case RZ:
307
+ *testfun_crlibm = exp_rz; break;
308
+ default:
309
+ *testfun_crlibm = exp_rn;
310
+ }
311
+ #ifdef HAVE_MATHLIB_H
312
+ *testfun_libultim = uexp;
313
+ #endif
314
+ #ifdef HAVE_LIBMCR_H
315
+ *testfun_libmcr = __libmcr_exp;
316
+ #endif
317
+ #ifdef HAVE_MPFR_H
318
+ *testfun_mpfr = mpfr_exp;
319
+ #endif
320
+ }
321
+
322
+
323
+ else if (strcmp (func_name, "log") == 0)
324
+ {
325
+ *randfun_perf = rand_for_log;
326
+ *randfun_soaktest = rand_for_log;
327
+ *worst_case=0.4009793462309855760053830468258630076242931610568335144339734234840014178511334897967240437927437320e-115;
328
+ *testfun_libm = log;
329
+ switch(crlibm_rnd_mode){
330
+ case RU:
331
+ *testfun_crlibm = log_ru; break;
332
+ case RD:
333
+ *testfun_crlibm = log_rd; break;
334
+ case RZ:
335
+ *testfun_crlibm = log_rz; break;
336
+ default:
337
+ *testfun_crlibm = log_rn;
338
+ }
339
+ #ifdef HAVE_MATHLIB_H
340
+ *testfun_libultim = ulog;
341
+ #endif
342
+ #ifdef HAVE_LIBMCR_H
343
+ *testfun_libmcr = __libmcr_log;
344
+ #endif
345
+ #ifdef HAVE_MPFR_H
346
+ *testfun_mpfr = mpfr_log;
347
+ #endif
348
+ }
349
+
350
+ else if (strcmp (func_name, "log2") == 0)
351
+ {
352
+ *randfun_perf = rand_for_log;
353
+ *randfun_soaktest = rand_for_log;
354
+ *worst_case=1.23; /* TODO: I dont know the worst case now */
355
+ *testfun_libm = log2;
356
+ switch(crlibm_rnd_mode){
357
+ case RU:
358
+ *testfun_crlibm = log2_ru; break;
359
+ case RD:
360
+ *testfun_crlibm = log2_rd; break;
361
+ case RZ:
362
+ *testfun_crlibm = log2_rz; break;
363
+ default:
364
+ *testfun_crlibm = log2_rn;
365
+ }
366
+ #ifdef HAVE_MATHLIB_H
367
+ *testfun_libultim = ulog2;
368
+ #endif
369
+ #ifdef HAVE_LIBMCR_H
370
+ *testfun_libmcr = __libmcr_log2;
371
+ #endif
372
+ #ifdef HAVE_MPFR_H
373
+ *testfun_mpfr = mpfr_log2;
374
+ #endif
375
+ }
376
+
377
+ else if (strcmp (func_name, "log10") == 0)
378
+ {
379
+ *randfun_perf = rand_for_log;
380
+ *randfun_soaktest = rand_for_log;
381
+ *worst_case = 2.60575359533670695497442621444820894404798523211076e+129;
382
+ *testfun_libm = log10;
383
+ switch(crlibm_rnd_mode){
384
+ case RU:
385
+ *testfun_crlibm = log10_ru; break;
386
+ case RD:
387
+ *testfun_crlibm = log10_rd; break;
388
+ case RZ:
389
+ *testfun_crlibm = log10_rz; break;
390
+ default:
391
+ *testfun_crlibm = log10_rn;
392
+ }
393
+ #ifdef HAVE_MATHLIB_H
394
+ *testfun_libultim = ulog10;
395
+ #endif
396
+ #ifdef HAVE_LIBMCR_H
397
+ *testfun_libmcr = __libmcr_log10;
398
+ #endif
399
+ #ifdef HAVE_MPFR_H
400
+ *testfun_mpfr = mpfr_log10;
401
+ #endif
402
+ }
403
+
404
+ else if (strcmp (func_name, "sin") == 0)
405
+ {
406
+ *randfun_perf = rand_for_trig_perf;
407
+ *randfun_soaktest = rand_for_trig_soaktest;
408
+ *worst_case= 9.24898516520941904595076721307123079895973205566406e-01;
409
+ *testfun_libm = sin;
410
+ switch(crlibm_rnd_mode){
411
+ case RU:
412
+ *testfun_crlibm = sin_ru; break;
413
+ case RD:
414
+ *testfun_crlibm = sin_rd; break;
415
+ case RZ:
416
+ *testfun_crlibm = sin_rz; break;
417
+ default:
418
+ *testfun_crlibm = sin_rn;
419
+ }
420
+ #ifdef HAVE_MATHLIB_H
421
+ *testfun_libultim = usin;
422
+ #endif
423
+ #ifdef HAVE_LIBMCR_H
424
+ *testfun_libmcr = __libmcr_sin;
425
+ #endif
426
+ #ifdef HAVE_MPFR_H
427
+ *testfun_mpfr = mpfr_sin;
428
+ #endif
429
+ }
430
+
431
+ else if (strcmp (func_name, "cos") == 0)
432
+ {
433
+ *randfun_perf = rand_for_trig_perf;
434
+ *randfun_soaktest = rand_for_trig_soaktest;
435
+ *worst_case= 8.87406081479789610177988379291491582989692687988281e-01;
436
+ *testfun_libm = cos;
437
+ switch(crlibm_rnd_mode){
438
+ case RU:
439
+ *testfun_crlibm = cos_ru; break;
440
+ case RD:
441
+ *testfun_crlibm = cos_rd; break;
442
+ case RZ:
443
+ *testfun_crlibm = cos_rz; break;
444
+ default:
445
+ *testfun_crlibm = cos_rn;
446
+ }
447
+ #ifdef HAVE_MATHLIB_H
448
+ *testfun_libultim = ucos;
449
+ #endif
450
+ #ifdef HAVE_LIBMCR_H
451
+ *testfun_libmcr = __libmcr_cos;
452
+ #endif
453
+ #ifdef HAVE_MPFR_H
454
+ *testfun_mpfr = mpfr_cos;
455
+ #endif
456
+ }
457
+
458
+ else if (strcmp (func_name, "tan") == 0)
459
+ {
460
+ *randfun_perf = rand_for_trig_perf;
461
+ *randfun_soaktest = rand_for_trig_soaktest;
462
+ *worst_case= 1.18008664944477814628953638020902872085571289062500e-01;
463
+ *testfun_libm = tan;
464
+ switch(crlibm_rnd_mode){
465
+ case RU:
466
+ *testfun_crlibm = tan_ru; break;
467
+ case RD:
468
+ *testfun_crlibm = tan_rd; break;
469
+ case RZ:
470
+ *testfun_crlibm = tan_rz; break;
471
+ default:
472
+ *testfun_crlibm = tan_rn;
473
+ }
474
+ #ifdef HAVE_MATHLIB_H
475
+ *testfun_libultim = utan;
476
+ #endif
477
+ #ifdef HAVE_LIBMCR_H
478
+ *testfun_libmcr = __libmcr_tan;
479
+ #endif
480
+ #ifdef HAVE_MPFR_H
481
+ *testfun_mpfr = mpfr_tan;
482
+ #endif
483
+ }
484
+
485
+ #if 0 /* No cotan in the standard math.h ? */
486
+ else if (strcmp (func_name, "cotan") == 0)
487
+ {
488
+ *randfun_perf = rand_for_trig_perf;
489
+ *randfun_soaktest = rand_for_trig_soaktest;
490
+ *worst_case= 1.18008664944477814628953638020902872085571289062500e-01;
491
+ *testfun_libm = cotan;
492
+ switch(crlibm_rnd_mode){
493
+ case RU:
494
+ *testfun_crlibm = cotan_ru; break;
495
+ case RD:
496
+ *testfun_crlibm = cotan_rd; break;
497
+ case RZ:
498
+ *testfun_crlibm = cotan_rz; break;
499
+ default:
500
+ *testfun_crlibm = cotan_rn;
501
+ }
502
+ #ifdef HAVE_MATHLIB_H
503
+ *testfun_libultim = ucotan;
504
+ #endif
505
+ #ifdef HAVE_MPFR_H
506
+ *testfun_mpfr = mpfr_cotan;
507
+ #endif
508
+ }
509
+ #endif /* no cotan */
510
+
511
+ else if (strcmp (func_name, "atan") == 0)
512
+ {
513
+ *randfun_perf = rand_for_atan_perf;
514
+ *randfun_soaktest = rand_for_atan_soaktest;
515
+ *worst_case= 9.54714164331460501955461950274184346199035644531250e-02;
516
+ *testfun_libm = atan;
517
+ switch(crlibm_rnd_mode){
518
+ case RU:
519
+ *testfun_crlibm = atan_ru; break;
520
+ case RD:
521
+ *testfun_crlibm = atan_rd; break;
522
+ case RZ:
523
+ *testfun_crlibm = atan_rz; break;
524
+ default:
525
+ *testfun_crlibm = atan_rn ;
526
+ }
527
+ #ifdef HAVE_MATHLIB_H
528
+ *testfun_libultim = uatan;
529
+ #endif
530
+ #ifdef HAVE_LIBMCR_H
531
+ *testfun_libmcr = __libmcr_atan;
532
+ #endif
533
+ #ifdef HAVE_MPFR_H
534
+ *testfun_mpfr = mpfr_atan;
535
+ #endif
536
+ }
537
+
538
+
539
+
540
+ else if (strcmp (func_name, "cosh") == 0)
541
+ {
542
+ *randfun_perf = rand_for_csh_perf;
543
+ *randfun_soaktest = rand_for_csh_soaktest;
544
+ *worst_case= 3.76323248339103422210882854415103793144226074218750e+00;
545
+ *testfun_libm = cosh;
546
+ switch(crlibm_rnd_mode){
547
+ case RU:
548
+ *testfun_crlibm = cosh_ru; break;
549
+ case RD:
550
+ *testfun_crlibm = cosh_rd; break;
551
+ case RZ:
552
+ *testfun_crlibm = cosh_rz; break;
553
+ default:
554
+ *testfun_crlibm = cosh_rn;
555
+ }
556
+ #ifdef HAVE_MATHLIB_H
557
+ /* No hyperbolic function in Ziv library */
558
+ *testfun_libultim = NULL;
559
+ #endif
560
+ #ifdef HAVE_MPFR_H
561
+ *testfun_mpfr = mpfr_cosh;
562
+ #endif
563
+ }
564
+
565
+ else if (strcmp (func_name, "sinh") == 0)
566
+ {
567
+ *randfun_perf = rand_for_csh_perf;
568
+ *randfun_soaktest = rand_for_csh_soaktest;
569
+ *worst_case= 5.81191276791475441854117889306508004665374755859375;
570
+ *testfun_libm = sinh;
571
+ switch(crlibm_rnd_mode){
572
+ case RU:
573
+ *testfun_crlibm = sinh_ru; break;
574
+ case RD:
575
+ *testfun_crlibm = sinh_rd; break;
576
+ case RZ:
577
+ *testfun_crlibm = sinh_rz; break;
578
+ default:
579
+ *testfun_crlibm = sinh_rn;
580
+ }
581
+ #ifdef HAVE_MATHLIB_H
582
+ /* No hyperbolic function in Ziv library */
583
+ *testfun_libultim = NULL;
584
+ #endif
585
+ #ifdef HAVE_MPFR_H
586
+ *testfun_mpfr = mpfr_sinh;
587
+ #endif
588
+ }
589
+
590
+ else if (strcmp (func_name, "pow") == 0)
591
+ {
592
+ *randfun_perf = rand_for_pow_perf;
593
+ *randfun_soaktest = rand_for_pow_soaktest;
594
+ *worst_case= 1;
595
+ *testfun_libm = pow;
596
+ switch(crlibm_rnd_mode){
597
+ case RU:
598
+ *testfun_crlibm = NULL; break;
599
+ case RD:
600
+ *testfun_crlibm = NULL; break;
601
+ case RZ:
602
+ *testfun_crlibm = NULL; break;
603
+ default:
604
+ /* *testfun_crlibm = pow_rn;*/
605
+ *testfun_crlibm = NULL;
606
+
607
+ }
608
+ #ifdef HAVE_MATHLIB_H
609
+ *testfun_libultim = upow;
610
+ #endif
611
+ #ifdef HAVE_LIBMCR_H
612
+ *testfun_libmcr = __libmcr_pow;
613
+ #endif
614
+ #ifdef HAVE_MPFR_H
615
+ *testfun_mpfr = mpfr_pow;
616
+ #endif
617
+ }
618
+
619
+
620
+
621
+ else
622
+ {
623
+ fprintf (stderr, "Unknown function: %s\n", func_name);
624
+ exit (1);
625
+ }
626
+ }
627
+
@@ -0,0 +1,28 @@
1
+ extern double zero;
2
+
3
+ void test_init(/* pointers to returned value */
4
+ double (**randfun_perf)(),
5
+ double (**randfun_soaktest)(),
6
+ double (**testfun_crlibm)(),
7
+ int (**testfun_mpfr) (),
8
+ double (**testfun_libultim) (),
9
+ double (**testfun_libmcr) (),
10
+ double (**testfun_libm) (),
11
+ double* worst_case,
12
+ /* arguments */
13
+ char *func_name,
14
+ char *rnd_mode);
15
+ /*
16
+ int rand_int(void);
17
+
18
+ double rand_generic(void);
19
+
20
+ double rand_double(void);
21
+
22
+ double rand_for_exp(void);
23
+
24
+ double rand_for_log(void);
25
+
26
+ double rand_for_exp_normal(void);
27
+
28
+ */