]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // (C) Copyright John Maddock 2007. |
2 | // Use, modification and distribution are subject to the | |
3 | // Boost Software License, Version 1.0. (See accompanying file | |
4 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
5 | ||
6 | #include <pch_light.hpp> | |
7 | ||
8 | #include "test_bessel_j.hpp" | |
9 | ||
10 | // | |
11 | // DESCRIPTION: | |
12 | // ~~~~~~~~~~~~ | |
13 | // | |
14 | // This file tests the bessel functions. There are two sets of tests, spot | |
15 | // tests which compare our results with selected values computed | |
16 | // using the online special function calculator at | |
17 | // functions.wolfram.com, while the bulk of the accuracy tests | |
18 | // use values generated with NTL::RR at 1000-bit precision | |
19 | // and our generic versions of these functions. | |
20 | // | |
21 | // Note that when this file is first run on a new platform many of | |
22 | // these tests will fail: the default accuracy is 1 epsilon which | |
23 | // is too tight for most platforms. In this situation you will | |
24 | // need to cast a human eye over the error rates reported and make | |
25 | // a judgement as to whether they are acceptable. Either way please | |
26 | // report the results to the Boost mailing list. Acceptable rates of | |
27 | // error are marked up below as a series of regular expressions that | |
28 | // identify the compiler/stdlib/platform/data-type/test-data/test-function | |
29 | // along with the maximum expected peek and RMS mean errors for that | |
30 | // test. | |
31 | // | |
32 | ||
33 | void expected_results() | |
34 | { | |
35 | // | |
36 | // Define the max and mean errors expected for | |
37 | // various compilers and platforms. | |
38 | // | |
39 | const char* largest_type; | |
40 | #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | |
41 | if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >()) | |
42 | { | |
43 | largest_type = "(long\\s+)?double|real_concept"; | |
44 | } | |
45 | else | |
46 | { | |
47 | largest_type = "long double|real_concept"; | |
48 | } | |
49 | #else | |
50 | largest_type = "(long\\s+)?double"; | |
51 | #endif | |
52 | // | |
53 | // HP-UX specific rates: | |
54 | // | |
55 | // Error rate for double precision are limited by the accuracy of | |
56 | // the approximations use, which bracket rather than preserve the root. | |
57 | // | |
58 | add_expected_result( | |
59 | ".*", // compiler | |
60 | ".*", // stdlib | |
61 | "HP-UX", // platform | |
62 | largest_type, // test type(s) | |
63 | ".*J0.*Tricky.*", // test data group | |
64 | ".*", 80000000000LL, 80000000000LL); // test function | |
65 | add_expected_result( | |
66 | ".*", // compiler | |
67 | ".*", // stdlib | |
68 | "HP-UX", // platform | |
69 | largest_type, // test type(s) | |
70 | ".*J1.*Tricky.*", // test data group | |
71 | ".*", 3000000, 2000000); // test function | |
72 | add_expected_result( | |
73 | ".*", // compiler | |
74 | ".*", // stdlib | |
75 | "HP-UX", // platform | |
76 | "double", // test type(s) | |
77 | ".*Tricky.*", // test data group | |
78 | ".*", 100000, 100000); // test function | |
79 | add_expected_result( | |
80 | ".*", // compiler | |
81 | ".*", // stdlib | |
82 | "HP-UX", // platform | |
83 | largest_type, // test type(s) | |
84 | ".*J.*Tricky.*", // test data group | |
85 | ".*", 3000, 500); // test function | |
86 | // | |
87 | // HP Tru64: | |
88 | // | |
89 | add_expected_result( | |
90 | ".*Tru64.*", // compiler | |
91 | ".*", // stdlib | |
92 | ".*", // platform | |
93 | "double", // test type(s) | |
94 | ".*Tricky.*", // test data group | |
95 | ".*", 100000, 100000); // test function | |
96 | add_expected_result( | |
97 | ".*Tru64.*", // compiler | |
98 | ".*", // stdlib | |
99 | ".*", // platform | |
100 | largest_type, // test type(s) | |
101 | ".*Tricky large.*", // test data group | |
102 | ".*", 3000, 1000); // test function | |
103 | // | |
104 | // Solaris specific rates: | |
105 | // | |
106 | // Error rate for double precision are limited by the accuracy of | |
107 | // the approximations use, which bracket rather than preserve the root. | |
108 | // | |
109 | add_expected_result( | |
110 | ".*", // compiler | |
111 | ".*", // stdlib | |
112 | "Sun Solaris", // platform | |
113 | largest_type, // test type(s) | |
114 | "Bessel J: Random Data.*Tricky.*", // test data group | |
115 | ".*", 3000, 500); // test function | |
116 | add_expected_result( | |
117 | ".*", // compiler | |
118 | ".*", // stdlib | |
119 | "Sun Solaris", // platform | |
120 | "double", // test type(s) | |
121 | ".*Tricky.*", // test data group | |
122 | ".*", 200000, 100000); // test function | |
123 | add_expected_result( | |
124 | ".*", // compiler | |
125 | ".*", // stdlib | |
126 | "Sun Solaris", // platform | |
127 | largest_type, // test type(s) | |
128 | ".*J.*tricky.*", // test data group | |
129 | ".*", 400000000, 200000000); // test function | |
130 | // | |
131 | // Mac OS X: | |
132 | // | |
133 | add_expected_result( | |
134 | ".*", // compiler | |
135 | ".*", // stdlib | |
136 | "Mac OS", // platform | |
137 | largest_type, // test type(s) | |
138 | ".*J0.*Tricky.*", // test data group | |
139 | ".*", 400000000, 400000000); // test function | |
140 | add_expected_result( | |
141 | ".*", // compiler | |
142 | ".*", // stdlib | |
143 | "Mac OS", // platform | |
144 | largest_type, // test type(s) | |
145 | ".*J1.*Tricky.*", // test data group | |
1e59de90 TL |
146 | #ifdef __aarch64__ |
147 | ".*", 4000000, 2000000); // test function | |
148 | #else | |
7c673cae | 149 | ".*", 3000000, 2000000); // test function |
1e59de90 | 150 | #endif |
7c673cae FG |
151 | add_expected_result( |
152 | ".*", // compiler | |
153 | ".*", // stdlib | |
154 | "Mac OS", // platform | |
155 | largest_type, // test type(s) | |
156 | "Bessel JN.*", // test data group | |
157 | ".*", 40000, 20000); // test function | |
158 | add_expected_result( | |
159 | ".*", // compiler | |
160 | ".*", // stdlib | |
161 | "Mac OS", // platform | |
162 | largest_type, // test type(s) | |
163 | "Bessel J:.*", // test data group | |
164 | ".*", 50000, 20000); // test function | |
165 | ||
166 | ||
167 | ||
168 | // | |
169 | // Linux specific results: | |
170 | // | |
171 | // sin and cos appear to have only double precision for large | |
172 | // arguments on some linux distros: | |
173 | // | |
174 | add_expected_result( | |
175 | ".*", // compiler | |
176 | ".*", // stdlib | |
177 | "linux", // platform | |
178 | largest_type, // test type(s) | |
179 | ".*J:.*", // test data group | |
180 | ".*", 40000, 30000); // test function | |
181 | ||
182 | ||
183 | #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | |
184 | if((std::numeric_limits<double>::digits != std::numeric_limits<long double>::digits) | |
185 | && (std::numeric_limits<long double>::digits < 90)) | |
186 | { | |
187 | // some errors spill over into type double as well: | |
188 | add_expected_result( | |
189 | ".*", // compiler | |
190 | ".*", // stdlib | |
191 | ".*", // platform | |
192 | "double", // test type(s) | |
193 | ".*J0.*Tricky.*", // test data group | |
194 | ".*", 400000, 400000); // test function | |
195 | add_expected_result( | |
196 | ".*", // compiler | |
197 | ".*", // stdlib | |
198 | ".*", // platform | |
199 | "double", // test type(s) | |
200 | ".*J1.*Tricky.*", // test data group | |
201 | ".*", 5000, 5000); // test function | |
202 | add_expected_result( | |
203 | ".*", // compiler | |
204 | ".*", // stdlib | |
205 | ".*", // platform | |
206 | "double", // test type(s) | |
207 | ".*(JN|j).*|.*Tricky.*", // test data group | |
208 | ".*", 50, 50); // test function | |
209 | add_expected_result( | |
210 | ".*", // compiler | |
211 | ".*", // stdlib | |
212 | ".*", // platform | |
213 | "double", // test type(s) | |
214 | ".*", // test data group | |
215 | ".*", 30, 30); // test function | |
216 | // | |
217 | // and we have a few cases with higher limits as well: | |
218 | // | |
219 | add_expected_result( | |
220 | ".*", // compiler | |
221 | ".*", // stdlib | |
222 | ".*", // platform | |
223 | largest_type, // test type(s) | |
224 | ".*J0.*Tricky.*", // test data group | |
225 | ".*", 400000000, 400000000); // test function | |
226 | add_expected_result( | |
227 | ".*", // compiler | |
228 | ".*", // stdlib | |
229 | ".*", // platform | |
230 | largest_type, // test type(s) | |
231 | ".*J1.*Tricky.*", // test data group | |
232 | ".*", 5000000, 5000000); // test function | |
233 | add_expected_result( | |
234 | ".*", // compiler | |
235 | ".*", // stdlib | |
236 | ".*", // platform | |
237 | largest_type, // test type(s) | |
238 | ".*(JN|j).*|.*Tricky.*", // test data group | |
239 | ".*", 33000, 20000); // test function | |
240 | } | |
1e59de90 TL |
241 | else if (std::numeric_limits<long double>::digits >= 90) |
242 | { | |
243 | add_expected_result( | |
244 | ".*", // compiler | |
245 | ".*", // stdlib | |
246 | ".*", // platform | |
247 | "double", // test type(s) | |
248 | ".*J0.*Tricky.*", // test data group | |
249 | ".*", 100000, 100000); // test function | |
250 | add_expected_result( | |
251 | ".*", // compiler | |
252 | ".*", // stdlib | |
253 | ".*", // platform | |
254 | "double", // test type(s) | |
255 | ".*J1.*Tricky.*", // test data group | |
256 | ".*", 70, 50); // test function | |
257 | add_expected_result( | |
258 | ".*", // compiler | |
259 | ".*", // stdlib | |
260 | ".*", // platform | |
261 | "double", // test type(s) | |
262 | ".*Mathworld.*", // test data group | |
263 | ".*", 20, 10); // test function | |
264 | } | |
7c673cae FG |
265 | #endif |
266 | add_expected_result( | |
267 | ".*", // compiler | |
268 | ".*", // stdlib | |
269 | ".*", // platform | |
270 | largest_type, // test type(s) | |
271 | ".*J0.*Tricky.*", // test data group | |
272 | ".*", 400000000, 400000000); // test function | |
273 | add_expected_result( | |
274 | ".*", // compiler | |
275 | ".*", // stdlib | |
276 | ".*", // platform | |
277 | largest_type, // test type(s) | |
278 | ".*J1.*Tricky.*", // test data group | |
279 | ".*", 5000000, 5000000); // test function | |
280 | add_expected_result( | |
281 | ".*", // compiler | |
282 | ".*", // stdlib | |
283 | ".*", // platform | |
284 | largest_type, // test type(s) | |
285 | "Bessel j:.*|Bessel JN: Mathworld.*|.*Tricky.*", // test data group | |
286 | ".*", 1500, 700); // test function | |
287 | add_expected_result( | |
288 | ".*", // compiler | |
289 | ".*", // stdlib | |
290 | ".*", // platform | |
291 | largest_type, // test type(s) | |
292 | ".*", // test data group | |
293 | ".*", 40, 20); // test function | |
294 | // | |
295 | // One set of float tests has inexact input values, so there is a slight error: | |
296 | // | |
297 | add_expected_result( | |
298 | ".*", // compiler | |
299 | ".*", // stdlib | |
300 | ".*", // platform | |
301 | "float", // test type(s) | |
302 | "Bessel J: Mathworld Data", // test data group | |
303 | ".*", 20, 20); // test function | |
304 | // | |
305 | // Finish off by printing out the compiler/stdlib/platform names, | |
306 | // we do this to make it easier to mark up expected error rates. | |
307 | // | |
308 | std::cout << "Tests run with " << BOOST_COMPILER << ", " | |
309 | << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl; | |
310 | } | |
311 | ||
312 | BOOST_AUTO_TEST_CASE( test_main ) | |
313 | { | |
314 | #ifdef TEST_GSL | |
315 | gsl_set_error_handler_off(); | |
316 | #endif | |
317 | expected_results(); | |
318 | BOOST_MATH_CONTROL_FP; | |
319 | ||
320 | test_bessel(0.1F, "float"); | |
321 | test_bessel(0.1, "double"); | |
322 | #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | |
323 | test_bessel(0.1L, "long double"); | |
324 | #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS | |
325 | test_bessel(boost::math::concepts::real_concept(0.1), "real_concept"); | |
326 | #endif | |
327 | #else | |
328 | std::cout << "<note>The long double tests have been disabled on this platform " | |
329 | "either because the long double overloads of the usual math functions are " | |
330 | "not available at all, or because they are too inaccurate for these tests " | |
331 | "to pass.</note>" << std::endl; | |
332 | #endif | |
333 | } | |
334 | ||
335 | ||
336 | ||
337 |