]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/test_bessel_k.cpp
1 // Copyright John Maddock 2006, 2007
2 // Copyright Paul A. Bristow 2007
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)
8 #include <pch_light.hpp>
11 # pragma warning(disable : 4756) // overflow in constant arithmetic
12 // Constants are too big for float case, but this doesn't matter for test.
15 #include "test_bessel_k.hpp"
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.
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|real_concept";
54 largest_type
= "long double|real_concept";
57 largest_type
= "(long\\s+)?double|real_concept";
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.
71 largest_type
, // test type(s)
72 ".*", // test data group
73 ".*", 4000, 1300); // test function
78 "Win32.*", // platform
79 largest_type
, // test type(s)
80 ".*large.*", // test data group
81 ".*", 250, 100); // test function
86 largest_type
, // test type(s)
87 ".*large.*", // test data group
88 ".*", 100, 50); // test function
93 "real_concept", // test type(s)
94 ".*", // test data group
95 ".*", 90, 50); // test function
100 largest_type
, // test type(s)
101 ".*", // test data group
102 ".*", 35, 15); // test function
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.
107 std::cout
<< "Tests run with " << BOOST_COMPILER
<< ", "
108 << BOOST_STDLIB
<< ", " << BOOST_PLATFORM
<< std::endl
;
111 BOOST_AUTO_TEST_CASE( test_main
)
114 gsl_set_error_handler_off();
117 BOOST_MATH_CONTROL_FP
;
119 #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
120 test_bessel(0.1F
, "float");
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");
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
;