Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / multiprecision / test / math / test_bessel_j.cpp
1 ///////////////////////////////////////////////////////////////
2 //  Copyright Christopher Kormanyos 2002 - 2011.
3 //  Copyright 2011 John Maddock. Distributed under the Boost
4 //  Software License, Version 1.0. (See accompanying file
5 //  LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
6 //
7 // This work is based on an earlier work:
8 // "Algorithm 910: A Portable C++ Multiple-Precision System for Special-Function Calculations",
9 // in ACM TOMS, {VOL 37, ISSUE 4, (February 2011)} (C) ACM, 2011. http://doi.acm.org/10.1145/1916461.1916469
10
11 #include "setup.hpp"
12 #include "table_type.hpp"
13
14 #include <boost/math/special_functions/math_fwd.hpp>
15 #include "libs/math/test/test_bessel_j.hpp"
16
17 void expected_results()
18 {
19    //
20    // Define the max and mean errors expected for
21    // various compilers and platforms.
22    //
23
24    add_expected_result(
25        ".*",                             // compiler
26        ".*",                             // stdlib
27        ".*",                             // platform
28        ".*mpfr_float_backend<18>.*",     // test type(s)
29        ".*J0.*Tricky.*",                 // test data group
30        ".*", 10000000000L, 5000000000L); // test function
31    add_expected_result(
32        ".*",                        // compiler
33        ".*",                        // stdlib
34        ".*",                        // platform
35        ".*",                        // test type(s)
36        ".*J0.*Tricky.*",            // test data group
37        ".*", 400000000, 400000000); // test function
38    add_expected_result(
39        ".*",                           // compiler
40        ".*",                           // stdlib
41        ".*",                           // platform
42        ".*mpfr_float_backend<18>.*",   // test type(s)
43        ".*J1.*Tricky.*",               // test data group
44        ".*", 1000000000L, 500000000L); // test function
45    add_expected_result(
46        ".*",                     // compiler
47        ".*",                     // stdlib
48        ".*",                     // platform
49        ".*",                     // test type(s)
50        ".*J1.*Tricky.*",         // test data group
51        ".*", 10000000, 5000000); // test function
52    add_expected_result(
53        ".*",                  // compiler
54        ".*",                  // stdlib
55        ".*",                  // platform
56        ".*cpp_bin_float.*",   // test type(s)
57        ".*JN.*Integer.*",     // test data group
58        ".*", 500000, 150000); // test function
59    add_expected_result(
60        ".*",                // compiler
61        ".*",                // stdlib
62        ".*",                // platform
63        ".*",                // test type(s)
64        ".*JN.*Integer.*",   // test data group
65        ".*", 50000, 15000); // test function
66    add_expected_result(
67        ".*",                         // compiler
68        ".*",                         // stdlib
69        ".*",                         // platform
70        ".*mpfr_float_backend<18>.*", // test type(s)
71        ".*(JN|j).*|.*Tricky.*",      // test data group
72        ".*", 70000, 7000);           // test function
73    add_expected_result(
74        ".*",                    // compiler
75        ".*",                    // stdlib
76        ".*",                    // platform
77        ".*cpp_bin_float.*",     // test type(s)
78        ".*(JN|j).*|.*Tricky.*", // test data group
79        ".*", 500000, 200000);   // test function
80    add_expected_result(
81        ".*",                    // compiler
82        ".*",                    // stdlib
83        ".*",                    // platform
84        ".*",                    // test type(s)
85        ".*(JN|j).*|.*Tricky.*", // test data group
86        ".*", 7000, 3000);       // test function
87    add_expected_result(
88        ".*",          // compiler
89        ".*",          // stdlib
90        ".*",          // platform
91        ".*",          // test type(s)
92        ".*",          // test data group
93        ".*", 40, 20); // test function
94    //
95    // Finish off by printing out the compiler/stdlib/platform names,
96    // we do this to make it easier to mark up expected error rates.
97    //
98    std::cout << "Tests run with " << BOOST_COMPILER << ", "
99              << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
100 }
101
102 template <class T>
103 void test(T t, const char* p)
104 {
105    test_bessel(t, p);
106 }
107
108 BOOST_AUTO_TEST_CASE(test_main)
109 {
110    using namespace boost::multiprecision;
111    expected_results();
112    //
113    // Test at:
114    // 18 decimal digits: tests 80-bit long double approximations
115    // 30 decimal digits: tests 128-bit long double approximations
116    // 35 decimal digits: tests arbitrary precision code
117    //
118    ALL_TESTS
119 }