]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/test_sinc.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / math / test / test_sinc.hpp
1 // Copyright John Maddock 2018.
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 <boost/math/concepts/real_concept.hpp>
7 #define BOOST_TEST_MAIN
8 #include <boost/test/unit_test.hpp>
9 #include <boost/test/tools/floating_point_comparison.hpp>
10 #include <boost/math/special_functions/sinc.hpp>
11 #include <boost/array.hpp>
12 #include "functor.hpp"
13
14 #include "handle_test_result.hpp"
15 #include "table_type.hpp"
16
17 #ifndef SC_
18 #define SC_(x) static_cast<typename table_type<T>::type>(BOOST_JOIN(x, L))
19 #endif
20
21 template <class Real, class T>
22 void do_test_sinc(const T& data, const char* type_name, const char* test_name)
23 {
24 #if !(defined(ERROR_REPORTING_MODE) && !defined(DIGAMMA_FUNCTION_TO_TEST))
25 typedef Real value_type;
26
27 typedef value_type (*pg)(value_type);
28 #if defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS)
29 pg funcp = boost::math::sinc_pi<value_type>;
30 #else
31 pg funcp = boost::math::sinc_pi;
32 #endif
33
34 boost::math::tools::test_result<value_type> result;
35
36 std::cout << "Testing " << test_name << " with type " << type_name
37 << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
38
39 //
40 // test sinc against data:
41 //
42 result = boost::math::tools::test_hetero<Real>(
43 data,
44 bind_func<Real>(funcp, 0),
45 extract_result<Real>(1));
46 handle_test_result(result, data[result.worst()], result.worst(), type_name, "sinc_pi", test_name);
47 std::cout << std::endl;
48 #endif
49 }
50
51 template <class T>
52 void test_sinc(T, const char* name)
53 {
54 //
55 // The actual test data is rather verbose, so it's in a separate file
56 //
57 // The contents are as follows, each row of data contains
58 // three items, input value a, input value b and erf(a, b):
59 //
60 # include "sinc_data.ipp"
61
62 do_test_sinc<T>(sinc_data, name, "Sinc Function");
63 }
64