2
0
mirror of https://github.com/boostorg/math.git synced 2026-02-26 16:52:27 +00:00

gamma.hpp coverage.

This commit is contained in:
jzmaddock
2024-07-03 19:52:07 +01:00
parent d8a4900e59
commit 24ede6fcdd
3 changed files with 34 additions and 6 deletions

View File

@@ -3,6 +3,8 @@
// 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_PROMOTE_DOUBLE_POLICY false
#include "math_unit_test.hpp"
#include <cfenv>
#include <iostream>
@@ -13,5 +15,9 @@ int main()
{
CHECK_EQUAL(boost::math::tgamma(-200.5), 0.0); // triggers internal exception handling
CHECK_EQUAL(boost::math::gamma_p(500.125, 1e-50), 0.0); // triggers internal exception handling
// Lines that can only be hit when promotion to 80-bit reals is turned off
CHECK_ULP_CLOSE(boost::math::tgamma(44.0, 0.000001), 6.04152630633738356373551320685139975072645120000000000000000e52, 10);
CHECK_ULP_CLOSE(boost::math::gamma_p(1.0001, boost::math::gamma_p_inv(1.0001, 1e-200)), 1e-200, 10);
return boost::math::test::report_errors();
}

View File

@@ -179,6 +179,16 @@ void test_spots(T, const char*)
BOOST_CHECK_CLOSE_FRACTION(boost::math::tgamma_delta_ratio(T(ldexp(T(1), -1074)), T(200)), T(5.13282785052571536804189023927976812551830809667482691717029e-50L), tol * 10);
BOOST_CHECK_CLOSE_FRACTION(boost::math::tgamma_delta_ratio(T(200), T(ldexp(T(1), -1074))), T(1), tol);
}
#if LDBL_MAX_EXP >= 16384
if(0 != ldexp(T(1), -16445))
{
// This is denorm_min at 80 bit long double precision:
BOOST_CHECK_CLOSE_FRACTION(boost::math::tgamma_ratio(T(ldexp(T(1), -16445)), T(200)), T(6.956968705776973348795055087648739671964943862403874276047e4577L), tol * 50);
BOOST_CHECK_CLOSE_FRACTION(boost::math::tgamma_ratio(T(200), T(ldexp(T(1), -16445))), T(1.43740764446678254374798600325709882852078655978124426386e-4578L), tol * 10);
BOOST_CHECK_CLOSE_FRACTION(boost::math::tgamma_delta_ratio(T(ldexp(T(1), -16445)), T(200)), T(6.956968705776973348795055087648739671964943862403874276047e4577L), tol * 10);
BOOST_CHECK_CLOSE_FRACTION(boost::math::tgamma_delta_ratio(T(200), T(ldexp(T(1), -16445))), T(1), tol);
}
#endif
}
//
// Coverage:
@@ -186,4 +196,10 @@ void test_spots(T, const char*)
BOOST_CHECK_EQUAL(boost::math::tgamma_delta_ratio(T(2), T(0)), T(1));
BOOST_CHECK_EQUAL(boost::math::tgamma_delta_ratio(T(200), T(0)), T(1));
BOOST_CHECK_EQUAL(boost::math::tgamma_delta_ratio(T(2000), T(0)), T(1));
BOOST_CHECK_EQUAL(boost::math::tgamma_ratio(T(0.5), T(100000)), T(0));
BOOST_IF_CONSTEXPR(std::numeric_limits<T>::has_infinity)
{
BOOST_CHECK_EQUAL(boost::math::tgamma_ratio(T(100000), T(0.5)), std::numeric_limits<T>::infinity());
}
}