]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/test_gamma.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_gamma.hpp"
13 // This file tests the functions tgamma and lgamma, and the
14 // function tgamma1pm1. 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";
53 // G++ on Darwin: results are just slightly worse than we might hope for
54 // but still pretty good:
60 largest_type
, // test type(s)
61 "factorials", // test data group
62 "tgamma", 100, 15); // test function
69 "Win32.*", // platform
70 largest_type
, // test type(s)
71 "factorials", // test data group
72 "tgamma", 100, 15); // test function
76 "Win32.*", // platform
77 "real_concept", // test type(s)
78 "factorials", // test data group
79 "tgamma", 600, 200); // test function
83 "Win32.*", // platform
84 "real_concept", // test type(s)
85 "near.*", // test data group
86 "tgamma", 200, 100); // test function
88 // G++ on Linux, result vary a bit by processor type,
89 // on Itanium results are *much* better than listed here,
90 // but x86 appears to have much less accurate std::pow
91 // that throws off the results:
97 largest_type
, // test type(s)
98 "factorials", // test data group
99 "tgamma", 600, 200); // test function
104 largest_type
, // test type(s)
105 "factorials", // test data group
106 "lgamma", 30, 10); // test function
111 largest_type
, // test type(s)
112 "near (1|2|-10)", // test data group
113 "tgamma", 10, 5); // test function
118 largest_type
, // test type(s)
119 "near (1|2|-10)", // test data group
120 "lgamma", 50, 50); // test function
125 largest_type
, // test type(s)
126 "tgamma1pm1.*", // test data group
127 "tgamma1pm1", 50, 15); // test function
132 "real_concept", // test type(s)
133 "factorials", // test data group
134 "tgamma", 600, 100); // test function
139 "real_concept", // test type(s)
140 "near (0|-55)", // test data group
141 "(t|l)gamma", 300, 150); // test function
146 "real_concept", // test type(s)
147 "tgamma1pm1.*", // test data group
148 "tgamma1pm1", 40, 10); // test function
156 largest_type
, // test type(s)
157 "factorials", // test data group
158 "tgamma", 5, 4); // test function
163 largest_type
, // test type(s)
164 "near (0|-55)", // test data group
165 "tgamma", 10, 5); // test function
170 largest_type
, // test type(s)
171 "near (1|2|-10)", // test data group
172 "lgamma", 250, 200); // test function
177 "real_concept", // test type(s)
178 "factorials", // test data group
179 "lgamma", 50, 20); // test function
184 "real_concept", // test type(s)
185 "tgamma1pm1.*", // test data group
186 "tgamma1pm1", 200, 80); // test function
191 ".*Tru64.*", // compiler
194 "real_concept", // test type(s)
195 "factorials", // test data group
196 "lgamma", 50, 20); // test function
204 largest_type
, // test type(s)
205 "factorials", // test data group
206 "tgamma", 450, 100); // test function
210 ".*Solaris.*", // platform
211 "real_concept", // test type(s)
212 "factorials", // test data group
213 "tgamma", 450, 150); // test function
216 // Catch all cases come last:
222 largest_type
, // test type(s)
223 "factorials", // test data group
224 "tgamma", 4, 1); // test function
229 largest_type
, // test type(s)
230 "factorials", // test data group
231 "lgamma", 9, 1); // test function
236 largest_type
, // test type(s)
237 "near (0|-55)", // test data group
238 "(t|l)gamma", 200, 100); // test function
243 largest_type
, // test type(s)
244 "near (1|2|-10)", // test data group
245 "tgamma", 10, 5); // test function
250 largest_type
, // test type(s)
251 "near (1|2|-10)", // test data group
252 "lgamma", 14, 7); // test function
257 largest_type
, // test type(s)
258 "tgamma1pm1.*", // test data group
259 "tgamma1pm1", 30, 9); // test function
265 "real_concept", // test type(s)
266 "factorials", // test data group
267 "tgamma", 600, 100); // test function
272 "real_concept", // test type(s)
273 "factorials", // test data group
274 "lgamma", 200, 20); // test function
279 "real_concept", // test type(s)
280 "near.*", // test data group
281 "tgamma", 300, 100); // test function
286 "real_concept", // test type(s)
287 "near.*", // test data group
288 "lgamma", 40000000, 10000000); // test function
293 "real_concept", // test type(s)
294 "tgamma1pm1.*", // test data group
295 "tgamma1pm1", 20, 5); // test function
298 // Finish off by printing out the compiler/stdlib/platform names,
299 // we do this to make it easier to mark up expected error rates.
301 std::cout
<< "Tests run with " << BOOST_COMPILER
<< ", "
302 << BOOST_STDLIB
<< ", " << BOOST_PLATFORM
<< std::endl
;
305 BOOST_AUTO_TEST_CASE( test_main
)
308 BOOST_MATH_CONTROL_FP
;
310 #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
311 test_spots(0.0F
, "float");
313 test_spots(0.0, "double");
314 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
315 test_spots(0.0L, "long double");
316 test_spots(boost::math::concepts::real_concept(0.1), "real_concept");
319 #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
320 test_gamma(0.1F
, "float");
322 test_gamma(0.1, "double");
323 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
324 test_gamma(0.1L, "long double");
325 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
326 #if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x582))
327 test_gamma(boost::math::concepts::real_concept(0.1), "real_concept");
331 std::cout
<< "<note>The long double tests have been disabled on this platform "
332 "either because the long double overloads of the usual math functions are "
333 "not available at all, or because they are too inaccurate for these tests "
334 "to pass.</note>" << std::endl
;