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