]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/test_bessel_j_prime.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / math / test / test_bessel_j_prime.cpp
1 // Copyright (c) 2013 Anton Bikineev
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_prime.hpp"
9
10 //
11 // DESCRIPTION:
12 // ~~~~~~~~~~~~
13 //
14 // This file tests the bessel functions derivatives. 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 Boost.Multiprecision at 50 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
146 ".*", 3000000, 2000000); // test function
147 add_expected_result(
148 ".*", // compiler
149 ".*", // stdlib
150 "Mac OS", // platform
151 largest_type, // test type(s)
152 "Bessel JN'.*", // test data group
153 ".*", 60000, 20000); // test function
154 add_expected_result(
155 ".*", // compiler
156 ".*", // stdlib
157 "Mac OS", // platform
158 largest_type, // test type(s)
159 "Bessel J':.*", // test data group
160 ".*", 60000, 20000); // test function
161
162
163
164 //
165 // Linux specific results:
166 //
167 // sin and cos appear to have only double precision for large
168 // arguments on some linux distros:
169 //
170 add_expected_result(
171 ".*", // compiler
172 ".*", // stdlib
173 "linux", // platform
174 largest_type, // test type(s)
175 ".*J':.*", // test data group
176 ".*", 60000, 30000); // test function
177
178
179 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
180 if((std::numeric_limits<double>::digits != std::numeric_limits<long double>::digits)
181 && (std::numeric_limits<long double>::digits < 90))
182 {
183 // some errors spill over into type double as well:
184 add_expected_result(
185 ".*", // compiler
186 ".*", // stdlib
187 ".*", // platform
188 "double", // test type(s)
189 ".*J0'.*Tricky.*", // test data group
190 ".*", 400000, 400000); // test function
191 add_expected_result(
192 ".*", // compiler
193 ".*", // stdlib
194 ".*", // platform
195 "double", // test type(s)
196 ".*J1'.*Tricky.*", // test data group
197 ".*", 5000, 5000); // test function
198 add_expected_result(
199 ".*", // compiler
200 ".*", // stdlib
201 ".*", // platform
202 "double", // test type(s)
203 ".*(JN'|j').*|.*Tricky.*", // test data group
204 ".*", 50, 50); // test function
205 add_expected_result(
206 ".*", // compiler
207 ".*", // stdlib
208 ".*", // platform
209 "double", // test type(s)
210 ".*", // test data group
211 ".*", 30, 30); // test function
212 //
213 // and we have a few cases with higher limits as well:
214 //
215 add_expected_result(
216 ".*", // compiler
217 ".*", // stdlib
218 ".*", // platform
219 largest_type, // test type(s)
220 ".*J0'.*Tricky.*", // test data group
221 ".*", 400000000, 400000000); // test function
222 add_expected_result(
223 ".*", // compiler
224 ".*", // stdlib
225 ".*", // platform
226 largest_type, // test type(s)
227 ".*J1'.*Tricky.*", // test data group
228 ".*", 5000000, 5000000); // test function
229 add_expected_result(
230 ".*", // compiler
231 ".*", // stdlib
232 ".*", // platform
233 largest_type, // test type(s)
234 ".*(JN'|j').*|.*Tricky.*", // test data group
235 ".*", 60000, 40000); // test function
236 }
237 #endif
238 add_expected_result(
239 ".*", // compiler
240 ".*", // stdlib
241 ".*", // platform
242 largest_type, // test type(s)
243 ".*J0'.*Tricky.*", // test data group
244 ".*", 400000000, 400000000); // test function
245 add_expected_result(
246 ".*", // compiler
247 ".*", // stdlib
248 ".*", // platform
249 largest_type, // test type(s)
250 ".*J1'.*Tricky.*", // test data group
251 ".*", 5000000, 5000000); // test function
252 add_expected_result(
253 ".*", // compiler
254 ".*", // stdlib
255 ".*", // platform
256 largest_type, // test type(s)
257 "Bessel j':.*|Bessel JN': Mathworld.*|.*Tricky.*", // test data group
258 ".*", 1500, 700); // test function
259 add_expected_result(
260 ".*", // compiler
261 ".*", // stdlib
262 ".*", // platform
263 largest_type, // test type(s)
264 ".*", // test data group
265 ".*", 40, 20); // test function
266 //
267 // One set of float tests has inexact input values, so there is a slight error:
268 //
269 add_expected_result(
270 ".*", // compiler
271 ".*", // stdlib
272 ".*", // platform
273 "float", // test type(s)
274 "Bessel J': Mathworld Data", // test data group
275 ".*", 30, 20); // test function
276 //
277 // Finish off by printing out the compiler/stdlib/platform names,
278 // we do this to make it easier to mark up expected error rates.
279 //
280 std::cout << "Tests run with " << BOOST_COMPILER << ", "
281 << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
282 }
283
284 BOOST_AUTO_TEST_CASE( test_main )
285 {
286 #ifdef TEST_GSL
287 gsl_set_error_handler_off();
288 #endif
289 expected_results();
290 BOOST_MATH_CONTROL_FP;
291
292 test_bessel_prime(0.1F, "float");
293 test_bessel_prime(0.1, "double");
294 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
295 test_bessel_prime(0.1L, "long double");
296 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
297 test_bessel_prime(boost::math::concepts::real_concept(0.1), "real_concept");
298 #endif
299 #else
300 std::cout << "<note>The long double tests have been disabled on this platform "
301 "either because the long double overloads of the usual math functions are "
302 "not available at all, or because they are too inaccurate for these tests "
303 "to pass.</note>" << std::endl;
304 #endif
305 }
306
307
308
309