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_inv.hpp"
9 #if !defined(TEST_FLOAT) && !defined(TEST_DOUBLE) && !defined(TEST_LDOUBLE) && !defined(TEST_REAL_CONCEPT)
13 # define TEST_REAL_CONCEPT
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
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
43 void expected_results()
46 // Define the max and mean errors expected for
47 // various compilers and platforms.
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<> >())
53 largest_type = "(long\\s+)?double";
57 largest_type = "long double";
60 largest_type = "(long\\s+)?double";
63 // Large exponent range causes more extreme test cases to be evaluated:
65 if(std::numeric_limits<long double>::max_exponent > std::numeric_limits<double>::max_exponent)
71 largest_type, // test type(s)
72 "[^|]*small[^|]*", // test data group
73 "[^|]*", 200000, 10000); // test function
78 "real_concept", // test type(s)
79 "[^|]*small[^|]*", // test data group
80 "[^|]*", 98000, 12000); // test function
83 // These high error rates are seen on on some Linux
89 "linux.*", // platform
90 largest_type, // test type(s)
91 "[^|]*medium[^|]*", // test data group
92 "[^|]*", 350, 5); // test function
96 "linux.*", // platform
97 largest_type, // test type(s)
98 "[^|]*large[^|]*", // test data group
99 "[^|]*", 150, 5); // test function
103 // Catch all cases come last:
109 largest_type, // test type(s)
110 "[^|]*medium[^|]*", // test data group
111 "[^|]*", 20, 5); // test function
116 largest_type, // test type(s)
117 "[^|]*large[^|]*", // test data group
118 "[^|]*", 5, 2); // test function
123 largest_type, // test type(s)
124 "[^|]*small[^|]*", // test data group
125 "[^|]*", 2100, 500); // test function
130 "float|double", // test type(s)
131 "[^|]*small[^|]*", // test data group
132 "gamma_p_inv", 500, 60); // test function
137 "float|double", // test type(s)
138 "[^|]*", // test data group
139 "gamma_q_inv", 350, 60); // test function
144 "float|double", // test type(s)
145 "[^|]*", // test data group
146 "[^|]*", 4, 2); // test function
151 "real_concept", // test type(s)
152 "[^|]*medium[^|]*", // test data group
153 "[^|]*", 20, 5); // test function
158 "real_concept", // test type(s)
159 "[^|]*large[^|]*", // test data group
160 "[^|]*", 1000, 500); // test function
165 "real_concept", // test type(s)
166 "[^|]*small[^|]*", // test data group
167 "[^|]*", 3700, 500); // test function
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.
173 std::cout << "Tests run with " << BOOST_COMPILER << ", "
174 << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
177 BOOST_AUTO_TEST_CASE( test_main )
180 BOOST_MATH_CONTROL_FP;
182 #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
184 test_spots(0.0F, "float");
188 test_spots(0.0, "double");
190 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
192 test_spots(0.0L, "long double");
194 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
195 #ifdef TEST_REAL_CONCEPT
196 test_spots(boost::math::concepts::real_concept(0.1), "real_concept");
201 #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
203 test_gamma(0.1F, "float");
207 test_gamma(0.1, "double");
209 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
211 test_gamma(0.1L, "long double");
213 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
214 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
215 #ifdef TEST_REAL_CONCEPT
216 test_gamma(boost::math::concepts::real_concept(0.1), "real_concept");
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;