]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // (C) Copyright John Maddock 2006. |
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 | #include "test_igamma.hpp" | |
8 | ||
9 | // | |
10 | // DESCRIPTION: | |
11 | // ~~~~~~~~~~~~ | |
12 | // | |
13 | // This file tests the incomplete gamma functions tgamma, | |
14 | // tgamma_lower, gamma_p and gamma_q. 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"; | |
44 | } | |
45 | else | |
46 | { | |
47 | largest_type = "long double"; | |
48 | } | |
49 | #else | |
50 | largest_type = "(long\\s+)?double"; | |
51 | #endif | |
52 | // | |
53 | // Linux: | |
54 | // | |
55 | // These should not really be needed, but on *some* Linux | |
56 | // versions these error rates are quite large and appear to | |
57 | // be related to the accuracy of powl and expl. On Itanium | |
58 | // or Xeon machines the error rates are much lower than this. | |
59 | // Worst cases appear to be AMD64 machines. | |
60 | // | |
61 | add_expected_result( | |
62 | "[^|]*", // compiler | |
63 | "[^|]*", // stdlib | |
64 | "linux", // platform | |
65 | largest_type, // test type(s) | |
66 | "[^|]*medium[^|]*", // test data group | |
67 | "[^|]*", 1300, 200); // test function | |
68 | add_expected_result( | |
69 | "[^|]*", // compiler | |
70 | "[^|]*", // stdlib | |
71 | ".*Solaris.*", // platform | |
72 | "real_concept", // test type(s) | |
73 | "[^|]*medium[^|]*", // test data group | |
74 | "[^|]*", 1000, 200); // test function | |
75 | add_expected_result( | |
76 | "[^|]*", // compiler | |
77 | "[^|]*", // stdlib | |
78 | "linux", // platform | |
79 | largest_type, // test type(s) | |
80 | "[^|]*integer[^|]*", // test data group | |
81 | "[^|]*", 1300, 200); // test function | |
82 | add_expected_result( | |
83 | "[^|]*", // compiler | |
84 | "[^|]*", // stdlib | |
85 | "linux", // platform | |
86 | "real_concept", // test type(s) | |
87 | "[^|]*medium[^|]*", // test data group | |
88 | "[^|]*", 1300, 200); // test function | |
89 | add_expected_result( | |
90 | "[^|]*", // compiler | |
91 | "[^|]*", // stdlib | |
92 | "linux", // platform | |
93 | "real_concept", // test type(s) | |
94 | "[^|]*integer[^|]*", // test data group | |
95 | "[^|]*", 600, 200); // test function | |
96 | ||
97 | // | |
98 | // Mac OS X: | |
99 | // It's not clear why these should be required, but see notes above | |
100 | // about Linux. | |
101 | // | |
102 | add_expected_result( | |
103 | "[^|]*", // compiler | |
104 | "[^|]*", // stdlib | |
105 | "Mac OS", // platform | |
106 | largest_type, // test type(s) | |
107 | "[^|]*medium[^|]*", // test data group | |
108 | "[^|]*", 5000, 1000); // test function | |
109 | add_expected_result( | |
110 | "[^|]*", // compiler | |
111 | "[^|]*", // stdlib | |
112 | "Mac OS", // platform | |
113 | largest_type, // test type(s) | |
114 | "[^|]*small[^|]*", // test data group | |
115 | "[^|]*", 80, 40); // test function | |
116 | add_expected_result( | |
117 | "[^|]*", // compiler | |
118 | "[^|]*", // stdlib | |
119 | "Mac OS", // platform | |
120 | largest_type, // test type(s) | |
121 | "[^|]*integer[^|]*", // test data group | |
122 | "[^|]*", 2000, 300); // test function | |
123 | add_expected_result( | |
124 | "[^|]*", // compiler | |
125 | "[^|]*", // stdlib | |
126 | "Mac OS", // platform | |
127 | "real_concept", // test type(s) | |
128 | "[^|]*medium[^|]*", // test data group | |
129 | "[^|]*", 5000, 1000); // test function | |
130 | add_expected_result( | |
131 | "[^|]*", // compiler | |
132 | "[^|]*", // stdlib | |
133 | "Mac OS", // platform | |
134 | "real_concept", // test type(s) | |
135 | "[^|]*small[^|]*", // test data group | |
136 | "[^|]*", 75, 15); // test function | |
137 | add_expected_result( | |
138 | "[^|]*", // compiler | |
139 | "[^|]*", // stdlib | |
140 | "Mac OS", // platform | |
141 | "real_concept", // test type(s) | |
142 | "[^|]*integer[^|]*", // test data group | |
143 | "[^|]*", 2000, 300); // test function | |
144 | // | |
145 | // HP-UX: | |
146 | // | |
147 | add_expected_result( | |
148 | "[^|]*", // compiler | |
149 | "[^|]*", // stdlib | |
150 | "HP-UX", // platform | |
151 | largest_type, // test type(s) | |
152 | "[^|]*medium[^|]*", // test data group | |
153 | "[^|]*", 500, 50); // test function | |
154 | add_expected_result( | |
155 | "[^|]*", // compiler | |
156 | "[^|]*", // stdlib | |
157 | "HP-UX", // platform | |
158 | "real_concept", // test type(s) | |
159 | "[^|]*medium[^|]*", // test data group | |
160 | "[^|]*", 500, 100); // test function | |
161 | // | |
162 | // Sun OS: | |
163 | // | |
164 | add_expected_result( | |
165 | "[^|]*", // compiler | |
166 | "[^|]*", // stdlib | |
167 | "Sun.*", // platform | |
168 | largest_type, // test type(s) | |
169 | "[^|]*medium[^|]*", // test data group | |
170 | "[^|]*", 500, 100); // test function | |
171 | add_expected_result( | |
172 | "[^|]*", // compiler | |
173 | "[^|]*", // stdlib | |
174 | "Sun.*", // platform | |
175 | largest_type, // test type(s) | |
176 | "[^|]*integer[^|]*", // test data group | |
177 | "[^|]*", 100, 30); // test function | |
178 | add_expected_result( | |
179 | "[^|]*", // compiler | |
180 | "[^|]*", // stdlib | |
181 | "Sun.*", // platform | |
182 | "real_concept", // test type(s) | |
183 | "[^|]*medium[^|]*", // test data group | |
184 | "[^|]*", 500, 100); // test function | |
185 | add_expected_result( | |
186 | "[^|]*", // compiler | |
187 | "[^|]*", // stdlib | |
188 | "Sun.*", // platform | |
189 | "real_concept", // test type(s) | |
190 | "[^|]*integer[^|]*", // test data group | |
191 | "[^|]*", 100, 30); // test function | |
192 | ||
193 | // | |
194 | // Mac OS X: | |
195 | // | |
196 | add_expected_result( | |
197 | "[^|]*", // compiler | |
198 | "[^|]*", // stdlib | |
199 | "Mac OS", // platform | |
200 | largest_type, // test type(s) | |
201 | "[^|]*medium[^|]*", // test data group | |
202 | "[^|]*", 100, 50); // test function | |
203 | ||
204 | // | |
205 | // Minw: | |
206 | // | |
207 | add_expected_result( | |
208 | "GNU[^|]*", // compiler | |
209 | "[^|]*", // stdlib | |
210 | "Win32[^|]*", // platform | |
211 | "real_concept", // test type(s) | |
212 | "[^|]*medium[^|]*", // test data group | |
213 | "[^|]*", 1300, 200); // test function | |
214 | add_expected_result( | |
215 | "GNU[^|]*", // compiler | |
216 | "[^|]*", // stdlib | |
217 | "Win32[^|]*", // platform | |
218 | largest_type, // test type(s) | |
219 | "[^|]*medium[^|]*", // test data group | |
220 | "[^|]*", 700, 200); // test function | |
221 | add_expected_result( | |
222 | "GNU[^|]*", // compiler | |
223 | "[^|]*", // stdlib | |
224 | "Win32[^|]*", // platform | |
225 | largest_type, // test type(s) | |
226 | "[^|]*small[^|]*", // test data group | |
227 | "[^|]*", 100, 50); // test function | |
228 | add_expected_result( | |
229 | "GNU[^|]*", // compiler | |
230 | "[^|]*", // stdlib | |
231 | "Win32[^|]*", // platform | |
232 | largest_type, // test type(s) | |
233 | "[^|]*integer[^|]*", // test data group | |
234 | ".*", 120, 50); // test function | |
235 | add_expected_result( | |
236 | "GNU[^|]*", // compiler | |
237 | "[^|]*", // stdlib | |
238 | "Win32[^|]*", // platform | |
239 | "real_concept", // test type(s) | |
240 | "[^|]*integer[^|]*", // test data group | |
241 | ".*", 100, 50); // test function | |
1e59de90 TL |
242 | // |
243 | // Cygwin: | |
244 | // | |
245 | add_expected_result( | |
246 | "GNU[^|]*", // compiler | |
247 | "[^|]*", // stdlib | |
248 | "Cygwin*", // platform | |
249 | "real_concept", // test type(s) | |
250 | "[^|]*medium[^|]*", // test data group | |
251 | "[^|]*", 1300, 200); // test function | |
252 | add_expected_result( | |
253 | "GNU[^|]*", // compiler | |
254 | "[^|]*", // stdlib | |
255 | "Cygwin*", // platform | |
256 | largest_type, // test type(s) | |
257 | "[^|]*medium[^|]*", // test data group | |
258 | "[^|]*", 700, 200); // test function | |
259 | add_expected_result( | |
260 | "GNU[^|]*", // compiler | |
261 | "[^|]*", // stdlib | |
262 | "Cygwin*", // platform | |
263 | largest_type, // test type(s) | |
264 | "[^|]*small[^|]*", // test data group | |
265 | "[^|]*", 100, 50); // test function | |
266 | add_expected_result( | |
267 | "GNU[^|]*", // compiler | |
268 | "[^|]*", // stdlib | |
269 | "Cygwin*", // platform | |
270 | largest_type, // test type(s) | |
271 | "[^|]*integer[^|]*", // test data group | |
272 | ".*", 120, 50); // test function | |
273 | add_expected_result( | |
274 | "GNU[^|]*", // compiler | |
275 | "[^|]*", // stdlib | |
276 | "Cygwin*", // platform | |
277 | "real_concept", // test type(s) | |
278 | "[^|]*integer[^|]*", // test data group | |
279 | ".*", 100, 50); // test function | |
7c673cae FG |
280 | |
281 | // | |
282 | // Large exponent range causes more extreme test cases to be evaluated: | |
283 | // | |
284 | if(std::numeric_limits<long double>::max_exponent > std::numeric_limits<double>::max_exponent) | |
285 | { | |
286 | add_expected_result( | |
287 | "[^|]*", // compiler | |
288 | "[^|]*", // stdlib | |
289 | "[^|]*", // platform | |
290 | largest_type, // test type(s) | |
291 | "[^|]*large[^|]*", // test data group | |
292 | ".*", 40000, 3000); // test function | |
293 | } | |
294 | ||
295 | ||
296 | // | |
297 | // Catch all cases come last: | |
298 | // | |
299 | add_expected_result( | |
300 | "[^|]*", // compiler | |
301 | "[^|]*", // stdlib | |
302 | "[^|]*", // platform | |
303 | largest_type, // test type(s) | |
304 | "[^|]*medium[^|]*", // test data group | |
305 | "[^|]*", 50, 20); // test function | |
306 | add_expected_result( | |
307 | "[^|]*", // compiler | |
308 | "[^|]*", // stdlib | |
309 | "[^|]*", // platform | |
310 | largest_type, // test type(s) | |
311 | "[^|]*small[^|]*", // test data group | |
312 | "[^|]*", 20, 10); // test function | |
313 | add_expected_result( | |
314 | "[^|]*", // compiler | |
315 | "[^|]*", // stdlib | |
316 | "[^|]*", // platform | |
317 | largest_type, // test type(s) | |
318 | "[^|]*large[^|]*", // test data group | |
319 | "gamma_q", 500, 50); // test function | |
320 | add_expected_result( | |
321 | "[^|]*", // compiler | |
322 | "[^|]*", // stdlib | |
323 | "Cygwin", // platform | |
324 | largest_type, // test type(s) | |
325 | "[^|]*large[^|]*", // test data group | |
326 | "gamma_p", 700, 50); // test function | |
327 | add_expected_result( | |
328 | "[^|]*", // compiler | |
329 | "[^|]*", // stdlib | |
330 | "[^|]*", // platform | |
331 | largest_type, // test type(s) | |
332 | "[^|]*large[^|]*", // test data group | |
333 | "gamma_p", 350, 50); // test function | |
334 | add_expected_result( | |
335 | "[^|]*", // compiler | |
336 | "[^|]*", // stdlib | |
337 | "[^|]*", // platform | |
338 | largest_type, // test type(s) | |
339 | "[^|]*integer[^|]*", // test data group | |
340 | ".*", 20, 10); // test function | |
341 | add_expected_result( | |
342 | "[^|]*", // compiler | |
343 | "[^|]*", // stdlib | |
344 | "[^|]*", // platform | |
345 | "real_concept", // test type(s) | |
346 | "[^|]*medium[^|]*", // test data group | |
347 | "[^|]*", 1500, 400); // test function | |
348 | add_expected_result( | |
349 | "[^|]*", // compiler | |
350 | "[^|]*", // stdlib | |
351 | "[^|]*", // platform | |
352 | "real_concept", // test type(s) | |
353 | "[^|]*small[^|]*", // test data group | |
354 | ".*", 100, 20); // test function | |
355 | add_expected_result( | |
356 | "[^|]*", // compiler | |
357 | "[^|]*", // stdlib | |
358 | "[^|]*", // platform | |
359 | "real_concept", // test type(s) | |
360 | "[^|]*large[^|]*", // test data group | |
361 | ".*", 1000000, 100000); // test function | |
362 | add_expected_result( | |
363 | "[^|]*", // compiler | |
364 | "[^|]*", // stdlib | |
365 | "[^|]*", // platform | |
366 | "real_concept", // test type(s) | |
367 | "[^|]*integer[^|]*", // test data group | |
368 | ".*", 200, 40); // test function | |
369 | ||
370 | // | |
371 | // Finish off by printing out the compiler/stdlib/platform names, | |
372 | // we do this to make it easier to mark up expected error rates. | |
373 | // | |
374 | std::cout << "Tests run with " << BOOST_COMPILER << ", " | |
375 | << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl; | |
376 | } | |
377 | ||
378 | BOOST_AUTO_TEST_CASE( test_main ) | |
379 | { | |
380 | expected_results(); | |
381 | BOOST_MATH_CONTROL_FP; | |
382 | ||
383 | #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS | |
384 | test_spots(0.0F); | |
385 | #endif | |
386 | test_spots(0.0); | |
387 | #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | |
388 | test_spots(0.0L); | |
389 | #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS | |
390 | test_spots(boost::math::concepts::real_concept(0.1)); | |
391 | #endif | |
392 | #endif | |
393 | ||
394 | #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS | |
395 | test_gamma(0.1F, "float"); | |
396 | #endif | |
397 | test_gamma(0.1, "double"); | |
398 | #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | |
399 | test_gamma(0.1L, "long double"); | |
400 | #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS | |
20effc67 | 401 | #if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x582)) |
7c673cae FG |
402 | test_gamma(boost::math::concepts::real_concept(0.1), "real_concept"); |
403 | #endif | |
404 | #endif | |
405 | #else | |
406 | std::cout << "<note>The long double tests have been disabled on this platform " | |
407 | "either because the long double overloads of the usual math functions are " | |
408 | "not available at all, or because they are too inaccurate for these tests " | |
409 | "to pass.</note>" << std::endl; | |
410 | #endif | |
411 | ||
412 | } | |
413 | ||
414 | ||
415 |