Files
multiprecision/test/math/high_prec/test_gamma.hpp
René Ferdinand Rivera Morell 6df8e19f00 Add support for modular build structure. (#632)
* Make the library modular usable.

* Switch to library requirements instead of source. As source puts extra source in install targets.

* Add missing import-search for cconfig/predef checks.

* Add requires-b2 check to top-level build file.

* Bump B2 require to 5.2

* Change all <source> references to <library>.

* Update copyright dates.

* Move inter-lib dependencies to a project variable and into the build targets.

* Adjust doc build to avoid boost-root references.

* Update build deps.

* Change Boost Test build refs to work with both old and modular test lib targets.

* Adjust CI for changes to the inspect tool. Also simplify the build and test to avoid future config problems as it can mor easily adjust to future CI changes.

* Use latest CI image to get a modern C++ compiler rthat doesn't ICE, we hope.

* Current CircleCI images need sudo to install packages.

* Undo search-lib change.

---------

Co-authored-by: Matt Borland <matt@mattborland.com>
2025-06-10 10:21:15 -04:00

88 lines
2.4 KiB
C++

// Copyright John Maddock 2006.
// Copyright Paul A. Bristow 2007, 2009
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_MATH_OVERFLOW_ERROR_POLICY ignore_error
#include <boost/math/special_functions/gamma.hpp>
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#include <boost/test/tools/floating_point_comparison.hpp>
#include <boost/math/tools/stats.hpp>
#include <boost/math/tools/test.hpp>
#include <boost/math/constants/constants.hpp>
#include <array>
#include "functor.hpp"
#include "handle_test_result.hpp"
#include "../table_type.hpp"
#ifndef SC_
#define SC_(x) static_cast<typename table_type<T>::type>(BOOST_JOIN(x, L))
#endif
template <class Real, class T>
void do_test_gamma(const T& data, const char* type_name, const char* test_name)
{
typedef Real value_type;
typedef value_type (*pg)(value_type);
#if defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS)
pg funcp = boost::math::tgamma<value_type>;
#else
pg funcp = boost::math::tgamma;
#endif
boost::math::tools::test_result<value_type> result;
std::cout << "Testing " << test_name << " with type " << type_name
<< "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
//
// test tgamma against data:
//
result = boost::math::tools::test_hetero<Real>(
data,
bind_func<Real>(funcp, 0),
extract_result<Real>(1));
handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::tgamma", test_name);
//
// test lgamma against data:
//
#if defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS)
funcp = boost::math::lgamma<value_type>;
#else
funcp = boost::math::lgamma;
#endif
result = boost::math::tools::test_hetero<Real>(
data,
bind_func<Real>(funcp, 0),
extract_result<Real>(2));
handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::lgamma", test_name);
std::cout << std::endl;
}
template <class T>
void test_gamma(T, const char* name)
{
#include "gamma.ipp"
do_test_gamma<T>(gamma, name, "random values");
#include "gamma_1_2.ipp"
do_test_gamma<T>(gamma_1_2, name, "Values near 1 and 2");
#include "gamma_0.ipp"
do_test_gamma<T>(gamma_0, name, "Values near 0");
#include "gamma_neg.ipp"
do_test_gamma<T>(gamma_neg, name, "Negative arguments");
}