]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/test_igamma_inva.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / math / test / test_igamma_inva.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)
5
6 #include <pch_light.hpp>
7 #include "test_igamma_inva.hpp"
8
9 #if !defined(TEST_FLOAT) && !defined(TEST_DOUBLE) && !defined(TEST_LDOUBLE) && !defined(TEST_REAL_CONCEPT)
10 # define TEST_FLOAT
11 # define TEST_DOUBLE
12 # define TEST_LDOUBLE
13 # define TEST_REAL_CONCEPT
14 #endif
15
16 //
17 // DESCRIPTION:
18 // ~~~~~~~~~~~~
19 //
20 // This file tests the incomplete gamma function inverses
21 // gamma_p_inva and gamma_q_inva. There are two sets of tests:
22 // 2) TODO: Accuracy tests use values generated with NTL::RR at
23 // 1000-bit precision and our generic versions of these functions.
24 // 3) Round trip sanity checks, use the test data for the forward
25 // functions, and verify that we can get (approximately) back
26 // where we started.
27 //
28 // Note that when this file is first run on a new platform many of
29 // these tests will fail: the default accuracy is 1 epsilon which
30 // is too tight for most platforms. In this situation you will
31 // need to cast a human eye over the error rates reported and make
32 // a judgement as to whether they are acceptable. Either way please
33 // report the results to the Boost mailing list. Acceptable rates of
34 // error are marked up below as a series of regular expressions that
35 // identify the compiler/stdlib/platform/data-type/test-data/test-function
36 // along with the maximum expected peek and RMS mean errors for that
37 // test.
38 //
39
40 void expected_results()
41 {
42 //
43 // Define the max and mean errors expected for
44 // various compilers and platforms.
45 //
46 const char* largest_type;
47 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
48 if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
49 {
50 largest_type = "(long\\s+)?double";
51 }
52 else
53 {
54 largest_type = "long double";
55 }
56 #else
57 largest_type = "(long\\s+)?double";
58 #endif
59 //
60 // Linux:
61 //
62 add_expected_result(
63 "[^|]*", // compiler
64 "[^|]*", // stdlib
65 "linux", // platform
66 largest_type, // test type(s)
67 "[^|]*", // test data group
68 "[^|]*", 800, 200); // test function
69
70 //
71 // Catch all cases come last:
72 //
73 add_expected_result(
74 "[^|]*", // compiler
75 "[^|]*", // stdlib
76 "[^|]*", // platform
77 "real_concept", // test type(s)
78 "[^|]*", // test data group
79 "[^|]*", 3000, 1000); // test function
80 add_expected_result(
81 "[^|]*", // compiler
82 "[^|]*", // stdlib
83 "[^|]*", // platform
84 largest_type, // test type(s)
85 "[^|]*", // test data group
86 "[^|]*", 300, 100); // test function
87 // this one has to come last in case double *is* the widest
88 // float type:
89 add_expected_result(
90 "[^|]*", // compiler
91 "[^|]*", // stdlib
92 "[^|]*", // platform
93 "float|double", // test type(s)
94 "[^|]*", // test data group
95 "[^|]*", 10, 5); // test function
96 //
97 // Finish off by printing out the compiler/stdlib/platform names,
98 // we do this to make it easier to mark up expected error rates.
99 //
100 std::cout << "Tests run with " << BOOST_COMPILER << ", "
101 << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
102 }
103
104 BOOST_AUTO_TEST_CASE( test_main )
105 {
106 expected_results();
107 BOOST_MATH_CONTROL_FP;
108
109 #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
110 #ifdef TEST_FLOAT
111 test_gamma(0.1F, "float");
112 #endif
113 #endif
114 #ifdef TEST_DOUBLE
115 test_gamma(0.1, "double");
116 #endif
117 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
118 #ifdef TEST_LDOUBLE
119 test_gamma(0.1L, "long double");
120 #endif
121 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
122 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
123 #ifdef TEST_REAL_CONCEPT
124 test_gamma(boost::math::concepts::real_concept(0.1), "real_concept");
125 #endif
126 #endif
127 #endif
128 #else
129 std::cout << "<note>The long double tests have been disabled on this platform "
130 "either because the long double overloads of the usual math functions are "
131 "not available at all, or because they are too inaccurate for these tests "
132 "to pass.</note>" << std::endl;
133 #endif
134
135 }
136
137
138
139