]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/test_trig.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / math / test / test_trig.hpp
1 // Copyright John Maddock 2014.
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/floating_point_comparison.hpp>
10 #include <boost/math/special_functions/math_fwd.hpp>
11 #include <boost/math/constants/constants.hpp>
12 #include <boost/type_traits/is_floating_point.hpp>
13 #include <boost/array.hpp>
14 #include "functor.hpp"
15
16 #include "handle_test_result.hpp"
17 #include "table_type.hpp"
18
19 #ifndef SC_
20 #define SC_(x) static_cast<typename table_type<T>::type>(BOOST_JOIN(x, L))
21 #endif
22
23 template <class Real, class T>
24 void do_test_trig(const T& data, const char* type_name, const char* test_name)
25 {
26 #if !(defined(ERROR_REPORTING_MODE) && !defined(SIN_PI_RATIO_FUNCTION_TO_TEST))
27 typedef Real value_type;
28
29 typedef value_type (*pg)(value_type);
30 #ifdef SIN_PI_RATIO_FUNCTION_TO_TEST
31 pg funcp = SIN_PI_RATIO_FUNCTION_TO_TEST;
32 #elif defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS)
33 pg funcp = boost::math::sin_pi<value_type>;
34 #else
35 pg funcp = boost::math::sin_pi;
36 #endif
37
38 boost::math::tools::test_result<value_type> result;
39
40 std::cout << "Testing " << test_name << " with type " << type_name
41 << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
42
43 //
44 // test sin_pi against data:
45 //
46 result = boost::math::tools::test_hetero<Real>(
47 data,
48 bind_func<Real>(funcp, 0),
49 extract_result<Real>(1));
50 handle_test_result(result, data[result.worst()], result.worst(), type_name, "sin_pi", test_name);
51 //
52 // test cos_pi against data:
53 //
54 #ifdef COS_PI_RATIO_FUNCTION_TO_TEST
55 funcp = COS_PI_RATIO_FUNCTION_TO_TEST;
56 #elif defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS)
57 funcp = boost::math::cos_pi<value_type>;
58 #else
59 funcp = boost::math::cos_pi;
60 #endif
61 result = boost::math::tools::test_hetero<Real>(
62 data,
63 bind_func<Real>(funcp, 0),
64 extract_result<Real>(2));
65 handle_test_result(result, data[result.worst()], result.worst(), type_name, "cos_pi", test_name);
66 std::cout << std::endl;
67 #endif
68 }
69
70 template <class T>
71 void test_trig(T, const char* name)
72 {
73 //
74 // The actual test data is rather verbose, so it's in a separate file
75 //
76 // The contents are as follows, each row of data contains
77 // three items, input value a, input value b and erf(a, b):
78 //
79 # include "trig_data.ipp"
80
81 do_test_trig<T>(trig_data, name, "sin_pi and cos_pi");
82
83 # include "trig_data2.ipp"
84
85 do_test_trig<T>(trig_data2, name, "sin_pi and cos_pi near integers and half integers");
86 }
87