]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/test_igamma.cpp
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)
6 #include <pch_light.hpp>
7 #include "test_igamma.hpp"
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.
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
33 void expected_results()
36 // Define the max and mean errors expected for
37 // various compilers and platforms.
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
<> >())
43 largest_type
= "(long\\s+)?double";
47 largest_type
= "long double";
50 largest_type
= "(long\\s+)?double";
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.
65 largest_type
, // test type(s)
66 "[^|]*medium[^|]*", // test data group
67 "[^|]*", 1300, 200); // test function
71 ".*Solaris.*", // platform
72 "real_concept", // test type(s)
73 "[^|]*medium[^|]*", // test data group
74 "[^|]*", 1000, 200); // test function
79 largest_type
, // test type(s)
80 "[^|]*integer[^|]*", // test data group
81 "[^|]*", 1300, 200); // test function
86 "real_concept", // test type(s)
87 "[^|]*medium[^|]*", // test data group
88 "[^|]*", 1300, 200); // test function
93 "real_concept", // test type(s)
94 "[^|]*integer[^|]*", // test data group
95 "[^|]*", 600, 200); // test function
99 // It's not clear why these should be required, but see notes above
105 "Mac OS", // platform
106 largest_type
, // test type(s)
107 "[^|]*medium[^|]*", // test data group
108 "[^|]*", 5000, 1000); // test function
112 "Mac OS", // platform
113 largest_type
, // test type(s)
114 "[^|]*small[^|]*", // test data group
115 "[^|]*", 80, 40); // test function
119 "Mac OS", // platform
120 largest_type
, // test type(s)
121 "[^|]*integer[^|]*", // test data group
122 "[^|]*", 2000, 300); // test function
126 "Mac OS", // platform
127 "real_concept", // test type(s)
128 "[^|]*medium[^|]*", // test data group
129 "[^|]*", 5000, 1000); // test function
133 "Mac OS", // platform
134 "real_concept", // test type(s)
135 "[^|]*small[^|]*", // test data group
136 "[^|]*", 75, 15); // test function
140 "Mac OS", // platform
141 "real_concept", // test type(s)
142 "[^|]*integer[^|]*", // test data group
143 "[^|]*", 2000, 300); // test function
151 largest_type
, // test type(s)
152 "[^|]*medium[^|]*", // test data group
153 "[^|]*", 500, 50); // test function
158 "real_concept", // test type(s)
159 "[^|]*medium[^|]*", // test data group
160 "[^|]*", 500, 100); // test function
168 largest_type
, // test type(s)
169 "[^|]*medium[^|]*", // test data group
170 "[^|]*", 500, 100); // test function
175 largest_type
, // test type(s)
176 "[^|]*integer[^|]*", // test data group
177 "[^|]*", 100, 30); // test function
182 "real_concept", // test type(s)
183 "[^|]*medium[^|]*", // test data group
184 "[^|]*", 500, 100); // test function
189 "real_concept", // test type(s)
190 "[^|]*integer[^|]*", // test data group
191 "[^|]*", 100, 30); // test function
199 "Mac OS", // platform
200 largest_type
, // test type(s)
201 "[^|]*medium[^|]*", // test data group
202 "[^|]*", 100, 50); // test function
208 "GNU[^|]*", // compiler
210 "Win32[^|]*", // platform
211 "real_concept", // test type(s)
212 "[^|]*medium[^|]*", // test data group
213 "[^|]*", 1300, 200); // test function
215 "GNU[^|]*", // compiler
217 "Win32[^|]*", // platform
218 largest_type
, // test type(s)
219 "[^|]*medium[^|]*", // test data group
220 "[^|]*", 700, 200); // test function
222 "GNU[^|]*", // compiler
224 "Win32[^|]*", // platform
225 largest_type
, // test type(s)
226 "[^|]*small[^|]*", // test data group
227 "[^|]*", 100, 50); // test function
229 "GNU[^|]*", // compiler
231 "Win32[^|]*", // platform
232 largest_type
, // test type(s)
233 "[^|]*integer[^|]*", // test data group
234 ".*", 120, 50); // test function
236 "GNU[^|]*", // compiler
238 "Win32[^|]*", // platform
239 "real_concept", // test type(s)
240 "[^|]*integer[^|]*", // test data group
241 ".*", 100, 50); // test function
246 "GNU[^|]*", // compiler
248 "Cygwin*", // platform
249 "real_concept", // test type(s)
250 "[^|]*medium[^|]*", // test data group
251 "[^|]*", 1300, 200); // test function
253 "GNU[^|]*", // compiler
255 "Cygwin*", // platform
256 largest_type
, // test type(s)
257 "[^|]*medium[^|]*", // test data group
258 "[^|]*", 700, 200); // test function
260 "GNU[^|]*", // compiler
262 "Cygwin*", // platform
263 largest_type
, // test type(s)
264 "[^|]*small[^|]*", // test data group
265 "[^|]*", 100, 50); // test function
267 "GNU[^|]*", // compiler
269 "Cygwin*", // platform
270 largest_type
, // test type(s)
271 "[^|]*integer[^|]*", // test data group
272 ".*", 120, 50); // test function
274 "GNU[^|]*", // compiler
276 "Cygwin*", // platform
277 "real_concept", // test type(s)
278 "[^|]*integer[^|]*", // test data group
279 ".*", 100, 50); // test function
282 // Large exponent range causes more extreme test cases to be evaluated:
284 if(std::numeric_limits
<long double>::max_exponent
> std::numeric_limits
<double>::max_exponent
)
290 largest_type
, // test type(s)
291 "[^|]*large[^|]*", // test data group
292 ".*", 40000, 3000); // test function
297 // Catch all cases come last:
303 largest_type
, // test type(s)
304 "[^|]*medium[^|]*", // test data group
305 "[^|]*", 50, 20); // test function
310 largest_type
, // test type(s)
311 "[^|]*small[^|]*", // test data group
312 "[^|]*", 20, 10); // test function
317 largest_type
, // test type(s)
318 "[^|]*large[^|]*", // test data group
319 "gamma_q", 500, 50); // test function
323 "Cygwin", // platform
324 largest_type
, // test type(s)
325 "[^|]*large[^|]*", // test data group
326 "gamma_p", 700, 50); // test function
331 largest_type
, // test type(s)
332 "[^|]*large[^|]*", // test data group
333 "gamma_p", 350, 50); // test function
338 largest_type
, // test type(s)
339 "[^|]*integer[^|]*", // test data group
340 ".*", 20, 10); // test function
345 "real_concept", // test type(s)
346 "[^|]*medium[^|]*", // test data group
347 "[^|]*", 1500, 400); // test function
352 "real_concept", // test type(s)
353 "[^|]*small[^|]*", // test data group
354 ".*", 100, 20); // test function
359 "real_concept", // test type(s)
360 "[^|]*large[^|]*", // test data group
361 ".*", 1000000, 100000); // test function
366 "real_concept", // test type(s)
367 "[^|]*integer[^|]*", // test data group
368 ".*", 200, 40); // test function
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.
374 std::cout
<< "Tests run with " << BOOST_COMPILER
<< ", "
375 << BOOST_STDLIB
<< ", " << BOOST_PLATFORM
<< std::endl
;
378 BOOST_AUTO_TEST_CASE( test_main
)
381 BOOST_MATH_CONTROL_FP
;
383 #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
387 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
389 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
390 test_spots(boost::math::concepts::real_concept(0.1));
394 #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
395 test_gamma(0.1F
, "float");
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
401 #if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x582))
402 test_gamma(boost::math::concepts::real_concept(0.1), "real_concept");
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
;