]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/math/test/test_2F0.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / math / test / test_2F0.hpp
CommitLineData
92f5a8d4
TL
1// Copyright John Maddock 2006.
2// Copyright Paul A. Bristow 2007, 2009
3// Use, modification and distribution are subject to the
4// Boost Software License, Version 1.0. (See accompanying file
5// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6
7#define BOOST_MATH_OVERFLOW_ERROR_POLICY ignore_error
8
9#include <boost/math/concepts/real_concept.hpp>
10#include <boost/math/special_functions/math_fwd.hpp>
11#define BOOST_TEST_MAIN
12#include <boost/test/unit_test.hpp>
13#include <boost/test/tools/floating_point_comparison.hpp>
14#include <boost/math/tools/stats.hpp>
15#include <boost/math/tools/test.hpp>
16#include <boost/math/tools/big_constant.hpp>
17#include <boost/math/constants/constants.hpp>
18#include <boost/type_traits/is_floating_point.hpp>
19#include <boost/array.hpp>
20#include "functor.hpp"
21
22#include "handle_test_result.hpp"
23#include "table_type.hpp"
24
25#include <boost/math/special_functions/hypergeometric_2F0.hpp>
26
27template <class Real, class T>
28void do_test_2F0(const T& data, const char* type_name, const char* test_name)
29{
30 typedef Real value_type;
31
32 typedef value_type(*pg)(value_type, value_type, value_type);
33#if defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS)
34 pg funcp = boost::math::hypergeometric_0F1<value_type, value_type>;
35#else
36 pg funcp = boost::math::hypergeometric_2F0;
37#endif
38
39 boost::math::tools::test_result<value_type> result;
40
41 std::cout << "Testing " << test_name << " with type " << type_name
42 << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
43
44 //
45 // test hypergeometric_2F0 against data:
46 //
47 result = boost::math::tools::test_hetero<Real>(
48 data,
49 bind_func<Real>(funcp, 0, 1, 2),
50 extract_result<Real>(3));
51 handle_test_result(result, data[result.worst()], result.worst(), type_name, "hypergeometric_0F1", test_name);
52 std::cout << std::endl;
53}
54
55#ifndef SC_
56#define SC_(x) BOOST_MATH_BIG_CONSTANT(T, 1000000, x)
57#endif
58
59template <class T>
60void test_spots1(T, const char* type_name)
61{
62#include "hypergeometric_2F0.ipp"
63
64 do_test_2F0<T>(hypergeometric_2F0, type_name, "Random non-integer a2, |z| < 1");
65
66#include "hypergeometric_2F0_large_z.ipp"
67
68 do_test_2F0<T>(hypergeometric_2F0_large_z, type_name, "Random non-integer a2, |z| > 1");
69}
70
71template <class T>
72void test_spots2(T, const char* type_name)
73{
74#include "hypergeometric_2F0_integer_a2.ipp"
75
76 do_test_2F0<T>(hypergeometric_2F0_integer_a2, type_name, "Integer a2, |z| > 1");
77
78#include "hypergeometric_2F0_half.ipp"
79
80 do_test_2F0<T>(hypergeometric_2F0_half, type_name, "a1 = a2 + 0.5");
81}
82
83template <class T>
84void test_spots(T z, const char* type_name)
85{
86 test_spots1(z, type_name);
87 test_spots2(z, type_name);
88
89 T a1 = 1;
90 T a2 = 0.1f;
91 z = -1;
92 if (std::numeric_limits<T>::has_infinity)
93 {
94 BOOST_CHECK((boost::math::isinf)(boost::math::hypergeometric_2F0(a1, a2, z)));
95 z = 1;
96 BOOST_CHECK((boost::math::isinf)(boost::math::hypergeometric_2F0(a1, a2, z)));
97 a2 = -2.4f;
98 BOOST_CHECK((boost::math::isinf)(boost::math::hypergeometric_2F0(a1, a2, z)));
99 a1 = -0.5f;
100 BOOST_CHECK((boost::math::isinf)(boost::math::hypergeometric_2F0(a1, a2, z)));
101 }
102}