]>
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_y.hpp" | |
9 | ||
10 | // | |
11 | // DESCRIPTION: | |
12 | // ~~~~~~~~~~~~ | |
13 | // | |
14 | // This file tests the bessel Y function. 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 | // | |
54 | // HP-UX and Solaris rates are very slightly higher: | |
55 | // | |
56 | add_expected_result( | |
57 | ".*", // compiler | |
58 | ".*", // stdlib | |
59 | "HP-UX|Sun Solaris", // platform | |
60 | largest_type, // test type(s) | |
61 | ".*(Y[nv]|y).*Random.*", // test data group | |
62 | ".*", 30000, 30000); // test function | |
63 | add_expected_result( | |
64 | ".*", // compiler | |
65 | ".*", // stdlib | |
66 | "HP-UX|Sun Solaris", // platform | |
67 | largest_type, // test type(s) | |
68 | ".*Y[01Nv].*", // test data group | |
69 | ".*", 1300, 500); // test function | |
70 | // | |
71 | // Tru64: | |
72 | // | |
73 | add_expected_result( | |
74 | ".*Tru64.*", // compiler | |
75 | ".*", // stdlib | |
76 | ".*", // platform | |
77 | largest_type, // test type(s) | |
78 | ".*(Y[nv]|y).*Random.*", // test data group | |
79 | ".*", 30000, 30000); // test function | |
80 | add_expected_result( | |
81 | ".*Tru64.*", // compiler | |
82 | ".*", // stdlib | |
83 | ".*", // platform | |
84 | largest_type, // test type(s) | |
85 | ".*Y[01Nv].*", // test data group | |
86 | ".*", 400, 200); // test function | |
87 | ||
88 | // | |
89 | // Mac OS X rates are very slightly higher: | |
90 | // | |
91 | add_expected_result( | |
92 | ".*", // compiler | |
93 | ".*", // stdlib | |
94 | "Mac OS", // platform | |
95 | largest_type, // test type(s) | |
96 | ".*(Y[nv1]).*", // test data group | |
97 | ".*", 600000, 100000); // test function | |
98 | add_expected_result( | |
99 | ".*", // compiler | |
100 | ".*", // stdlib | |
101 | "Mac OS", // platform | |
102 | "long double|real_concept", // test type(s) | |
103 | ".*Y[0].*", // test data group | |
104 | ".*", 1200, 1000); // test function | |
105 | ||
106 | // | |
107 | // Linux: | |
108 | // | |
109 | add_expected_result( | |
110 | ".*", // compiler | |
111 | ".*", // stdlib | |
112 | "linux", // platform | |
113 | largest_type, // test type(s) | |
114 | ".*Yv.*Random.*", // test data group | |
115 | ".*", 200000, 200000); // test function | |
116 | add_expected_result( | |
117 | ".*", // compiler | |
118 | ".*", // stdlib | |
119 | "linux", // platform | |
120 | largest_type, // test type(s) | |
121 | ".*Y[01v].*", // test data group | |
122 | ".*", 2000, 1000); // test function | |
123 | add_expected_result( | |
124 | ".*", // compiler | |
125 | ".*", // stdlib | |
126 | "linux", // platform | |
127 | largest_type, // test type(s) | |
128 | ".*Yn.*", // test data group | |
129 | ".*", 30000, 30000); // test function | |
130 | // | |
131 | // MinGW: | |
132 | // | |
133 | add_expected_result( | |
134 | "GNU.*", // compiler | |
135 | ".*", // stdlib | |
136 | "Win32.*", // platform | |
137 | largest_type, // test type(s) | |
138 | ".*Yv.*Random.*", // test data group | |
139 | ".*", 200000, 200000); // test function | |
140 | add_expected_result( | |
141 | "GNU.*", // compiler | |
142 | ".*", // stdlib | |
143 | "Win32.*", // platform | |
144 | largest_type, // test type(s) | |
145 | ".*Y[01v].*", // test data group | |
146 | ".*", 2000, 1000); // test function | |
147 | add_expected_result( | |
148 | "GNU.*", // compiler | |
149 | ".*", // stdlib | |
150 | "Win32.*", // platform | |
151 | largest_type, // test type(s) | |
152 | ".*Yn.*", // test data group | |
153 | ".*", 30000, 30000); // test function | |
154 | // | |
1e59de90 TL |
155 | // Cygwin: |
156 | // | |
157 | add_expected_result( | |
158 | "GNU.*", // compiler | |
159 | ".*", // stdlib | |
160 | "Cygwin*", // platform | |
161 | largest_type, // test type(s) | |
162 | ".*Yv.*Random.*", // test data group | |
163 | ".*", 400000, 300000); // test function | |
164 | add_expected_result( | |
165 | "GNU.*", // compiler | |
166 | ".*", // stdlib | |
167 | "Cygwin*", // platform | |
168 | largest_type, // test type(s) | |
169 | ".*Y[01v].*", // test data group | |
170 | ".*", 2000, 1000); // test function | |
171 | add_expected_result( | |
172 | "GNU.*", // compiler | |
173 | ".*", // stdlib | |
174 | "Cygwin*", // platform | |
175 | largest_type, // test type(s) | |
176 | ".*Yn.*", // test data group | |
177 | ".*", 30000, 30000); // test function | |
178 | // | |
7c673cae FG |
179 | // Solaris version of long double has it's own error rates, |
180 | // again just a touch higher than msvc's 64-bit double: | |
181 | // | |
182 | add_expected_result( | |
183 | "GNU.*", // compiler | |
184 | ".*", // stdlib | |
185 | "Sun.*", // platform | |
186 | largest_type, // test type(s) | |
187 | "Y[0N].*Mathworld.*", // test data group | |
188 | ".*", 2000, 2000); // test function | |
189 | ||
190 | #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | |
191 | if((std::numeric_limits<double>::digits != std::numeric_limits<long double>::digits) | |
192 | && (std::numeric_limits<long double>::digits < 90)) | |
193 | { | |
194 | // some errors spill over into type double as well: | |
195 | add_expected_result( | |
196 | ".*", // compiler | |
197 | ".*", // stdlib | |
198 | ".*", // platform | |
199 | "double", // test type(s) | |
200 | ".*Y[Nn].*", // test data group | |
201 | ".*", 20, 20); // test function | |
202 | add_expected_result( | |
203 | ".*", // compiler | |
204 | ".*", // stdlib | |
205 | ".*", // platform | |
206 | "double", // test type(s) | |
207 | ".*Yv.*", // test data group | |
208 | ".*", 80, 70); // test function | |
209 | } | |
1e59de90 TL |
210 | else if (std::numeric_limits<long double>::digits >= 90) |
211 | { | |
212 | add_expected_result( | |
213 | ".*", // compiler | |
214 | ".*", // stdlib | |
215 | ".*", // platform | |
216 | "double", // test type(s) | |
217 | ".*Yv.*Mathworld.*", // test data group | |
218 | ".*", 20, 5); // test function | |
219 | } | |
7c673cae FG |
220 | #endif |
221 | // | |
222 | // defaults are based on MSVC-8 on Win32: | |
223 | // | |
224 | add_expected_result( | |
225 | ".*", // compiler | |
226 | ".*", // stdlib | |
227 | ".*", // platform | |
228 | "real_concept", // test type(s) | |
229 | ".*(Y[nv]|y).*Random.*", // test data group | |
230 | ".*", 2000, 2000); // test function | |
231 | add_expected_result( | |
232 | ".*", // compiler | |
233 | ".*", // stdlib | |
234 | ".*", // platform | |
235 | largest_type, // test type(s) | |
236 | ".*(Y[nv]|y).*Random.*", // test data group | |
237 | ".*", 1500, 1000); // test function | |
238 | // | |
239 | // Fallback for sun has to go after the general cases above: | |
240 | // | |
241 | add_expected_result( | |
242 | "GNU.*", // compiler | |
243 | ".*", // stdlib | |
244 | "Sun.*", // platform | |
245 | largest_type, // test type(s) | |
246 | "Y[0N].*", // test data group | |
247 | ".*", 200, 200); // test function | |
248 | // | |
249 | // General fallback: | |
250 | // | |
251 | add_expected_result( | |
252 | ".*", // compiler | |
253 | ".*", // stdlib | |
254 | ".*", // platform | |
255 | largest_type, // test type(s) | |
256 | ".*", // test data group | |
257 | ".*", 80, 40); // test function | |
258 | // | |
259 | // One set of float tests has inexact input values, so there is a slight error: | |
260 | // | |
261 | add_expected_result( | |
262 | ".*", // compiler | |
263 | ".*", // stdlib | |
264 | ".*", // platform | |
265 | "float", // test type(s) | |
266 | "Yv: Mathworld Data", // test data group | |
267 | ".*", 20, 20); // test function | |
268 | // | |
269 | // Finish off by printing out the compiler/stdlib/platform names, | |
270 | // we do this to make it easier to mark up expected error rates. | |
271 | // | |
272 | std::cout << "Tests run with " << BOOST_COMPILER << ", " | |
273 | << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl; | |
274 | } | |
275 | ||
276 | BOOST_AUTO_TEST_CASE( test_main ) | |
277 | { | |
278 | #ifdef TEST_GSL | |
279 | gsl_set_error_handler_off(); | |
280 | #endif | |
281 | expected_results(); | |
282 | BOOST_MATH_CONTROL_FP; | |
283 | ||
284 | #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS | |
285 | test_bessel(0.1F, "float"); | |
286 | #endif | |
287 | test_bessel(0.1, "double"); | |
288 | #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | |
289 | test_bessel(0.1L, "long double"); | |
290 | #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS | |
291 | test_bessel(boost::math::concepts::real_concept(0.1), "real_concept"); | |
292 | #endif | |
293 | #else | |
294 | std::cout << "<note>The long double tests have been disabled on this platform " | |
295 | "either because the long double overloads of the usual math functions are " | |
296 | "not available at all, or because they are too inaccurate for these tests " | |
297 | "to pass.</note>" << std::endl; | |
298 | #endif | |
299 | } | |
300 | ||
301 | ||
302 | ||
303 |