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