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_ibeta.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 beta functions beta,
21 // betac, ibeta and ibetac. There are two sets of tests, spot
22 // tests which compare our results with selected values computed
23 // using the online special function calculator at
24 // functions.wolfram.com, while the bulk of the accuracy tests
25 // use values generated with NTL::RR at 1000-bit precision
26 // and our generic versions of these functions.
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
40 void expected_results()
43 // Define the max and mean errors expected for
44 // various compilers and platforms.
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<> >())
50 largest_type = "(long\\s+)?double";
54 largest_type = "long double";
57 largest_type = "(long\\s+)?double";
60 // Darwin: just one special case for real_concept:
66 "real_concept", // test type(s)
67 "(?i).*large.*", // test data group
68 ".*", 400000, 50000); // test function
71 // Linux - results depend quite a bit on the
72 // processor type, and how good the std::pow
73 // function is for that processor.
79 largest_type, // test type(s)
80 "(?i).*small.*", // test data group
81 ".*", 350, 100); // test function
86 largest_type, // test type(s)
87 "(?i).*medium.*", // test data group
88 ".*", 300, 80); // test function
90 // Deficiencies in pow function really kick in here for
91 // large arguments. Note also that the tests here get
92 // *very* extreme due to the increased exponent range
93 // of 80-bit long doubles. Also effect Mac OS.
98 "linux|Mac OS", // platform
99 largest_type, // test type(s)
100 "(?i).*large.*", // test data group
101 ".*", 200000, 10000); // test function
102 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
106 "linux|Mac OS|Sun.*", // platform
107 "double", // test type(s)
108 "(?i).*large.*", // test data group
109 ".*", 40, 20); // test function
114 "linux|Mac OS", // platform
115 "real_concept", // test type(s)
116 "(?i).*medium.*", // test data group
117 ".*", 350, 100); // test function
122 // Large value tests include some with *very* extreme
123 // results, thanks to the large exponent range of
124 // 128-bit long doubles.
130 largest_type, // test type(s)
131 "(?i).*large.*", // test data group
132 ".*", 200000, 10000); // test function
137 ".*Tru64.*", // compiler
140 largest_type, // test type(s)
141 "(?i).*large.*", // test data group
142 ".*", 130000, 10000); // test function
150 largest_type, // test type(s)
151 "(?i).*large.*", // test data group
152 ".*", 130000, 10000); // test function
157 largest_type, // test type(s)
158 "(?i).*small.*", // test data group
159 ".*", 130, 30); // test function
164 largest_type, // test type(s)
165 "(?i).*medium.*", // test data group
166 ".*", 200, 40); // test function
171 "real_concept", // test type(s)
172 "(?i).*medium.*", // test data group
173 ".*", 200, 40); // test function
178 "real_concept", // test type(s)
179 "(?i).*small.*", // test data group
180 ".*", 130, 30); // test function
185 "GNU[^|]*", // compiler
187 "Win32[^|]*", // platform
188 "real_concept", // test type(s)
189 "(?i).*medium.*", // test data group
190 ".*", 400, 50); // test function
194 "Win32.*", // platform
195 "double", // test type(s)
196 "(?i).*large.*", // test data group
197 ".*", 20, 10); // test function
201 "Win32.*", // platform
202 largest_type, // test type(s)
203 "(?i).*large.*", // test data group
204 ".*", 200000, 10000); // test function
206 #ifdef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
213 BOOST_PLATFORM, // platform
214 largest_type, // test type(s)
215 "(?i).*large.*", // test data group
216 ".*", 13000, 500); // test function
219 // Catch all cases come last:
225 largest_type, // test type(s)
226 "(?i).*small.*", // test data group
227 ".*", 90, 25); // test function
232 largest_type, // test type(s)
233 "(?i).*medium.*", // test data group
234 ".*", 350, 50); // test function
239 largest_type, // test type(s)
240 "(?i).*large.*", // test data group
241 ".*", 5000, 500); // test function
247 "real_concept", // test type(s)
248 "(?i).*small.*", // test data group
249 ".*", 90, 25); // test function
254 "real_concept", // test type(s)
255 "(?i).*medium.*", // test data group
256 ".*", 200, 50); // test function
261 "real_concept", // test type(s)
262 "(?i).*large.*", // test data group
263 ".*", 200000, 50000); // test function
265 // catch all default is 2eps for all types:
270 "[^|]*", // test type(s)
271 "[^|]*", // test data group
272 ".*", 2, 2); // test function
274 // Finish off by printing out the compiler/stdlib/platform names,
275 // we do this to make it easier to mark up expected error rates.
277 std::cout << "Tests run with " << BOOST_COMPILER << ", "
278 << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
281 BOOST_AUTO_TEST_CASE( test_main )
284 BOOST_MATH_CONTROL_FP;
286 gsl_set_error_handler_off();
294 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
298 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
299 #ifdef TEST_REAL_CONCEPT
300 test_spots(boost::math::concepts::real_concept(0.1));
306 test_beta(0.1F, "float");
309 test_beta(0.1, "double");
311 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
313 test_beta(0.1L, "long double");
315 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
316 #ifdef TEST_REAL_CONCEPT
317 test_beta(boost::math::concepts::real_concept(0.1), "real_concept");
321 std::cout << "<note>The long double tests have been disabled on this platform "
322 "either because the long double overloads of the usual math functions are "
323 "not available at all, or because they are too inaccurate for these tests "
324 "to pass.</note>" << std::cout;