]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/math/test/test_igamma_inv.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / math / test / test_igamma_inv.cpp
CommitLineData
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_inv.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_inv and gamma_q_inv. There are three sets of tests:
22// 1) Spot tests which compare our results with selected values
23// computed using the online special function calculator at
24// functions.wolfram.com,
25// 2) Accuracy tests use values generated with NTL::RR at
26// 1000-bit precision and our generic versions of these functions.
27// 3) Round trip sanity checks, use the test data for the forward
28// functions, and verify that we can get (approximately) back
29// where we started.
30//
31// Note that when this file is first run on a new platform many of
32// these tests will fail: the default accuracy is 1 epsilon which
33// is too tight for most platforms. In this situation you will
34// need to cast a human eye over the error rates reported and make
35// a judgement as to whether they are acceptable. Either way please
36// report the results to the Boost mailing list. Acceptable rates of
37// error are marked up below as a series of regular expressions that
38// identify the compiler/stdlib/platform/data-type/test-data/test-function
39// along with the maximum expected peek and RMS mean errors for that
40// test.
41//
42
43void expected_results()
44{
45 //
46 // Define the max and mean errors expected for
47 // various compilers and platforms.
48 //
49 const char* largest_type;
50#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
51 if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
52 {
53 largest_type = "(long\\s+)?double";
54 }
55 else
56 {
57 largest_type = "long double";
58 }
59#else
60 largest_type = "(long\\s+)?double";
61#endif
62 //
63 // Large exponent range causes more extreme test cases to be evaluated:
64 //
65 if(std::numeric_limits<long double>::max_exponent > std::numeric_limits<double>::max_exponent)
66 {
67 add_expected_result(
68 "[^|]*", // compiler
69 "[^|]*", // stdlib
70 "[^|]*", // platform
71 largest_type, // test type(s)
72 "[^|]*small[^|]*", // test data group
73 "[^|]*", 200000, 10000); // test function
74 add_expected_result(
75 "[^|]*", // compiler
76 "[^|]*", // stdlib
77 "[^|]*", // platform
78 "real_concept", // test type(s)
79 "[^|]*small[^|]*", // test data group
92f5a8d4 80 "[^|]*", 98000, 12000); // test function
7c673cae
FG
81 }
82 //
83 // These high error rates are seen on on some Linux
84 // architectures:
85 //
86 add_expected_result(
87 "[^|]*", // compiler
88 "[^|]*", // stdlib
89 "linux.*", // platform
90 largest_type, // test type(s)
91 "[^|]*medium[^|]*", // test data group
92 "[^|]*", 350, 5); // test function
93 add_expected_result(
94 "[^|]*", // compiler
95 "[^|]*", // stdlib
96 "linux.*", // platform
97 largest_type, // test type(s)
98 "[^|]*large[^|]*", // test data group
99 "[^|]*", 150, 5); // test function
100
101
102 //
103 // Catch all cases come last:
104 //
105 add_expected_result(
106 "[^|]*", // compiler
107 "[^|]*", // stdlib
108 "[^|]*", // platform
109 largest_type, // test type(s)
110 "[^|]*medium[^|]*", // test data group
111 "[^|]*", 20, 5); // test function
112 add_expected_result(
113 "[^|]*", // compiler
114 "[^|]*", // stdlib
115 "[^|]*", // platform
116 largest_type, // test type(s)
117 "[^|]*large[^|]*", // test data group
118 "[^|]*", 5, 2); // test function
119 add_expected_result(
120 "[^|]*", // compiler
121 "[^|]*", // stdlib
122 "[^|]*", // platform
123 largest_type, // test type(s)
124 "[^|]*small[^|]*", // test data group
125 "[^|]*", 2100, 500); // test function
126 add_expected_result(
127 "[^|]*", // compiler
128 "[^|]*", // stdlib
129 "[^|]*", // platform
130 "float|double", // test type(s)
131 "[^|]*small[^|]*", // test data group
132 "gamma_p_inv", 500, 60); // test function
133 add_expected_result(
134 "[^|]*", // compiler
135 "[^|]*", // stdlib
136 "[^|]*", // platform
137 "float|double", // test type(s)
138 "[^|]*", // test data group
139 "gamma_q_inv", 350, 60); // test function
140 add_expected_result(
141 "[^|]*", // compiler
142 "[^|]*", // stdlib
143 "[^|]*", // platform
144 "float|double", // test type(s)
145 "[^|]*", // test data group
146 "[^|]*", 4, 2); // test function
147 add_expected_result(
148 "[^|]*", // compiler
149 "[^|]*", // stdlib
150 "[^|]*", // platform
151 "real_concept", // test type(s)
152 "[^|]*medium[^|]*", // test data group
153 "[^|]*", 20, 5); // test function
154 add_expected_result(
155 "[^|]*", // compiler
156 "[^|]*", // stdlib
157 "[^|]*", // platform
158 "real_concept", // test type(s)
159 "[^|]*large[^|]*", // test data group
160 "[^|]*", 1000, 500); // test function
161 add_expected_result(
162 "[^|]*", // compiler
163 "[^|]*", // stdlib
164 "[^|]*", // platform
165 "real_concept", // test type(s)
166 "[^|]*small[^|]*", // test data group
167 "[^|]*", 3700, 500); // test function
168
169 //
170 // Finish off by printing out the compiler/stdlib/platform names,
171 // we do this to make it easier to mark up expected error rates.
172 //
173 std::cout << "Tests run with " << BOOST_COMPILER << ", "
174 << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
175}
176
177BOOST_AUTO_TEST_CASE( test_main )
178{
179 expected_results();
180 BOOST_MATH_CONTROL_FP;
181
182#ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
183#ifdef TEST_FLOAT
184 test_spots(0.0F, "float");
185#endif
186#endif
187#ifdef TEST_DOUBLE
188 test_spots(0.0, "double");
189#endif
190#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
191#ifdef TEST_LDOUBLE
192 test_spots(0.0L, "long double");
193#endif
20effc67 194#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x582))
7c673cae
FG
195#ifdef TEST_REAL_CONCEPT
196 test_spots(boost::math::concepts::real_concept(0.1), "real_concept");
197#endif
198#endif
199#endif
200
201#ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
202#ifdef TEST_FLOAT
203 test_gamma(0.1F, "float");
204#endif
205#endif
206#ifdef TEST_DOUBLE
207 test_gamma(0.1, "double");
208#endif
209#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
210#ifdef TEST_LDOUBLE
211 test_gamma(0.1L, "long double");
212#endif
213#ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
20effc67 214#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x582))
7c673cae
FG
215#ifdef TEST_REAL_CONCEPT
216 test_gamma(boost::math::concepts::real_concept(0.1), "real_concept");
217#endif
218#endif
219#endif
220#else
221 std::cout << "<note>The long double tests have been disabled on this platform "
222 "either because the long double overloads of the usual math functions are "
223 "not available at all, or because they are too inaccurate for these tests "
224 "to pass.</note>" << std::endl;
225#endif
226
227}
228
229
230