Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / multiprecision / test / math / high_prec / test_gamma.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 "test_gamma.hpp"
7 #ifdef TEST_MPFR
8 #include <boost/multiprecision/mpfr.hpp>
9 #else
10 #include <boost/multiprecision/cpp_bin_float.hpp>
11 #endif
12
13 void expected_results()
14 {
15    //
16    // Define the max and mean errors expected for
17    // various compilers and platforms.
18    //
19    const char* largest_type;
20 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
21    if (boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
22    {
23       largest_type = "(long\\s+)?double";
24    }
25    else
26    {
27       largest_type = "long double";
28    }
29 #else
30    largest_type = "(long\\s+)?double";
31 #endif
32    add_expected_result(
33        ".*",                                          // compiler
34        ".*",                                          // stdlib
35        ".*",                                          // platform
36        ".*",                                          // test type(s)
37        ".*near 1.*",                                  // test data group
38        ".*lgamma.*", 100000000000LL, 100000000000LL); // test function
39    add_expected_result(
40        ".*",                          // compiler
41        ".*",                          // stdlib
42        ".*",                          // platform
43        ".*",                          // test type(s)
44        ".*near 0.*",                  // test data group
45        ".*lgamma.*", 300000, 100000); // test function
46    add_expected_result(
47        ".*",                 // compiler
48        ".*",                 // stdlib
49        ".*",                 // platform
50        ".*",                 // test type(s)
51        ".*",                 // test data group
52        ".*", 110000, 50000); // test function
53
54    //
55    // Finish off by printing out the compiler/stdlib/platform names,
56    // we do this to make it easier to mark up expected error rates.
57    //
58    std::cout << "Tests run with " << BOOST_COMPILER << ", "
59              << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
60 }
61
62 BOOST_AUTO_TEST_CASE(test_main)
63 {
64    expected_results();
65    BOOST_MATH_CONTROL_FP;
66
67 #ifdef TEST_MPFR
68    typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<450> > mp_type;
69    const char*                                                                            name = "number<mpfr_float_backend<450> >";
70 #else
71    typedef boost::multiprecision::number<boost::multiprecision::cpp_bin_float<450> > mp_type;
72    const char*                                                                       name = "number<cpp_bin_float<450> >";
73 #endif
74
75    test_gamma(mp_type(0), name);
76 }