This source file includes following definitions.
- test_function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 static void
18 test_function (void)
19 {
20 int i;
21 int j;
22 const DOUBLE TWO_MANT_DIG =
23
24
25
26 (DOUBLE) (1U << ((MANT_DIG - 1) / 5))
27 * (DOUBLE) (1U << ((MANT_DIG - 1 + 1) / 5))
28 * (DOUBLE) (1U << ((MANT_DIG - 1 + 2) / 5))
29 * (DOUBLE) (1U << ((MANT_DIG - 1 + 3) / 5))
30 * (DOUBLE) (1U << ((MANT_DIG - 1 + 4) / 5));
31
32
33 {
34 DOUBLE x;
35
36 for (i = -1, x = L_(0.5); i >= MIN_EXP; i--, x *= L_(0.5))
37 {
38 DOUBLE y;
39
40 y = EXPM1 (x);
41 #ifdef __MINGW32__
42 ASSERT (y >= x * (L_(1.0) - L_(1.0) / TWO_MANT_DIG));
43 #else
44 ASSERT (y >= x);
45 #endif
46 ASSERT (y < L_(1.5) * x);
47
48 y = EXPM1 (- x);
49 ASSERT (y >= - x);
50 ASSERT (y < - L_(0.5) * x);
51 }
52 }
53
54
55 {
56
57 const DOUBLE err_bound =
58 (sizeof (DOUBLE) > sizeof (double) ?
59 #if defined __i386__ && defined __FreeBSD__
60
61
62
63
64
65 L_(1024.0)
66 #else
67 L_(5.0)
68 #endif
69 : L_(5.0));
70
71 for (i = 0; i < SIZEOF (RANDOM); i++)
72 {
73 DOUBLE x = L_(2.0) * RANDOM[i];
74 DOUBLE y = EXPM1 (x);
75 DOUBLE z = EXPM1 (- x);
76 DOUBLE err = y + (1 + y) * z;
77 ASSERT (y >= L_(0.0));
78 ASSERT (z <= L_(0.0));
79 ASSERT (err > - err_bound / TWO_MANT_DIG
80 && err < err_bound / TWO_MANT_DIG);
81 }
82 }
83
84 {
85
86 const DOUBLE err_bound =
87 (sizeof (DOUBLE) > sizeof (double) ?
88 #if defined __i386__ && defined __FreeBSD__
89 L_(1536.0)
90 #else
91 L_(11.0)
92 #endif
93 : L_(9.0));
94
95 for (i = 0; i < SIZEOF (RANDOM) / 5; i++)
96 for (j = 0; j < SIZEOF (RANDOM) / 5; j++)
97 {
98 DOUBLE x = L_(2.0) * RANDOM[i] - L_(1.0);
99 DOUBLE y = L_(2.0) * RANDOM[j] - L_(1.0);
100 DOUBLE z = - x - y;
101
102 {
103 DOUBLE a = EXPM1 (x);
104 DOUBLE b = EXPM1 (y);
105 DOUBLE c = EXPM1 (z);
106 DOUBLE err = a + (1 + a) * (b + (1 + b) * c);
107 ASSERT (err > - err_bound / TWO_MANT_DIG
108 && err < err_bound / TWO_MANT_DIG);
109 }
110 }
111 }
112 }
113
114 volatile DOUBLE x;
115 DOUBLE y;