]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/multiprecision/test/math/high_prec/test_gamma.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / multiprecision / test / math / high_prec / test_gamma.hpp
CommitLineData
7c673cae
FG
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/special_functions/gamma.hpp>
10#define BOOST_TEST_MAIN
11#include <boost/test/unit_test.hpp>
20effc67 12#include <boost/test/tools/floating_point_comparison.hpp>
7c673cae
FG
13#include <boost/math/tools/stats.hpp>
14#include <boost/math/tools/test.hpp>
15#include <boost/math/constants/constants.hpp>
7c673cae
FG
16#include <boost/array.hpp>
17#include "libs/math/test/functor.hpp"
18
19#include "libs/math/test/handle_test_result.hpp"
20#include "../table_type.hpp"
21
22#ifndef SC_
23#define SC_(x) static_cast<typename table_type<T>::type>(BOOST_JOIN(x, L))
24#endif
25
26template <class Real, class T>
27void do_test_gamma(const T& data, const char* type_name, const char* test_name)
28{
29 typedef typename T::value_type row_type;
30 typedef Real value_type;
31
32 typedef value_type (*pg)(value_type);
33#if defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS)
34 pg funcp = boost::math::tgamma<value_type>;
35#else
36 pg funcp = boost::math::tgamma;
37#endif
38
39 boost::math::tools::test_result<value_type> result;
40
41 std::cout << "Testing " << test_name << " with type " << type_name
92f5a8d4 42 << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
7c673cae
FG
43
44 //
45 // test tgamma against data:
46 //
47 result = boost::math::tools::test_hetero<Real>(
92f5a8d4
TL
48 data,
49 bind_func<Real>(funcp, 0),
50 extract_result<Real>(1));
7c673cae
FG
51 handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::tgamma", test_name);
52
53 //
54 // test lgamma against data:
55 //
56#if defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS)
57 funcp = boost::math::lgamma<value_type>;
58#else
92f5a8d4 59 funcp = boost::math::lgamma;
7c673cae
FG
60#endif
61 result = boost::math::tools::test_hetero<Real>(
92f5a8d4
TL
62 data,
63 bind_func<Real>(funcp, 0),
64 extract_result<Real>(2));
7c673cae
FG
65 handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::lgamma", test_name);
66
67 std::cout << std::endl;
68}
69
70template <class T>
71void test_gamma(T, const char* name)
72{
92f5a8d4 73#include "gamma.ipp"
7c673cae
FG
74
75 do_test_gamma<T>(gamma, name, "random values");
76
92f5a8d4 77#include "gamma_1_2.ipp"
7c673cae
FG
78
79 do_test_gamma<T>(gamma_1_2, name, "Values near 1 and 2");
80
92f5a8d4 81#include "gamma_0.ipp"
7c673cae
FG
82
83 do_test_gamma<T>(gamma_0, name, "Values near 0");
84
92f5a8d4 85#include "gamma_neg.ipp"
7c673cae
FG
86
87 do_test_gamma<T>(gamma_neg, name, "Negative arguments");
7c673cae 88}