]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/test_bessel_k.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / math / test / test_bessel_k.cpp
1 // Copyright John Maddock 2006, 2007
2 // Copyright Paul A. Bristow 2007
3
4 // Use, modification and distribution are subject to the
5 // Boost Software License, Version 1.0. (See accompanying file
6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7
8 #include <pch_light.hpp>
9
10 #ifdef _MSC_VER
11 # pragma warning(disable : 4756) // overflow in constant arithmetic
12 // Constants are too big for float case, but this doesn't matter for test.
13 #endif
14
15 #include "test_bessel_k.hpp"
16
17 //
18 // DESCRIPTION:
19 // ~~~~~~~~~~~~
20 //
21 // This file tests the bessel K function. 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.
27 //
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
37 // test.
38 //
39
40 void expected_results()
41 {
42 //
43 // Define the max and mean errors expected for
44 // various compilers and platforms.
45 //
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<> >())
49 {
50 largest_type = "(long\\s+)?double|real_concept";
51 }
52 else
53 {
54 largest_type = "long double|real_concept";
55 }
56 #else
57 largest_type = "(long\\s+)?double|real_concept";
58 #endif
59 //
60 // On MacOS X cyl_bessel_k has much higher error levels than
61 // expected: given that the implementation is basically
62 // just a continued fraction evaluation combined with
63 // exponentiation, we conclude that exp and pow are less
64 // accurate on this platform, especially when the result
65 // is outside the range of a double.
66 //
67 add_expected_result(
68 ".*", // compiler
69 ".*", // stdlib
70 "Mac OS", // platform
71 largest_type, // test type(s)
72 ".*", // test data group
73 ".*", 4000, 1300); // test function
74
75 add_expected_result(
76 "GNU.*", // compiler
77 ".*", // stdlib
78 "Win32.*", // platform
79 largest_type, // test type(s)
80 ".*large.*", // test data group
81 ".*", 250, 100); // test function
82 add_expected_result(
83 ".*", // compiler
84 ".*", // stdlib
85 ".*", // platform
86 largest_type, // test type(s)
87 ".*large.*", // test data group
88 ".*", 100, 50); // test function
89 add_expected_result(
90 ".*", // compiler
91 ".*", // stdlib
92 ".*", // platform
93 "real_concept", // test type(s)
94 ".*", // test data group
95 ".*", 90, 50); // test function
96 add_expected_result(
97 ".*", // compiler
98 ".*", // stdlib
99 ".*", // platform
100 largest_type, // test type(s)
101 ".*", // test data group
102 ".*", 35, 15); // test function
103 //
104 // Finish off by printing out the compiler/stdlib/platform names,
105 // we do this to make it easier to mark up expected error rates.
106 //
107 std::cout << "Tests run with " << BOOST_COMPILER << ", "
108 << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
109 }
110
111 BOOST_AUTO_TEST_CASE( test_main )
112 {
113 #ifdef TEST_GSL
114 gsl_set_error_handler_off();
115 #endif
116 expected_results();
117 BOOST_MATH_CONTROL_FP;
118
119 #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
120 test_bessel(0.1F, "float");
121 #endif
122 test_bessel(0.1, "double");
123 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
124 test_bessel(0.1L, "long double");
125 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
126 test_bessel(boost::math::concepts::real_concept(0.1), "real_concept");
127 #endif
128 #else
129 std::cout << "<note>The long double tests have been disabled on this platform "
130 "either because the long double overloads of the usual math functions are "
131 "not available at all, or because they are too inaccurate for these tests "
132 "to pass.</note>" << std::endl;
133 #endif
134 }
135
136
137
138