2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

Fix up enhanced tests to make them multiprecision safe.

This commit is contained in:
jzmaddock
2024-02-29 08:39:37 +00:00
parent ebe7b36676
commit 54028c2fb1
4 changed files with 27 additions and 9 deletions

View File

@@ -191,7 +191,7 @@ void test_bessel(T, const char* name)
{
BOOST_CHECK_EQUAL(boost::math::cyl_bessel_i(T(0.25), T(8000)), std::numeric_limits<T>::infinity());
}
else
else BOOST_IF_CONSTEXPR(std::numeric_limits<T>::max_exponent10 < 9200)
{
BOOST_CHECK_EQUAL(boost::math::cyl_bessel_i(T(0.25), T(21000)), std::numeric_limits<T>::infinity());
}
@@ -209,6 +209,8 @@ void test_bessel(T, const char* name)
#endif
BOOST_IF_CONSTEXPR (std::numeric_limits<T>::max_exponent > 1000)
{
BOOST_IF_CONSTEXPR(std::is_floating_point<T>::value == false)
tolerance *= 2; // multiprecision type.
BOOST_CHECK_CLOSE_FRACTION(boost::math::cyl_bessel_i(0, T(700)), SC_(1.5295933476718737363162072288904508649662689614661164851272e302), tolerance);
BOOST_CHECK_CLOSE_FRACTION(boost::math::cyl_bessel_i(1, T(600)), SC_(6.1411813450668919369004006361519512681603654557478168763761e258), tolerance);
}

View File

@@ -180,7 +180,7 @@ void test_bessel(T, const char* name)
BOOST_IF_CONSTEXPR(std::numeric_limits<T>::has_infinity)
{
BOOST_CHECK_EQUAL(boost::math::cyl_bessel_k(T(0), T(0)), std::numeric_limits<T>::infinity());
BOOST_IF_CONSTEXPR(std::numeric_limits<T>::min_exponent <= -1021)
BOOST_IF_CONSTEXPR(std::numeric_limits<T>::min_exponent > -1021)
{
BOOST_CHECK_EQUAL(boost::math::cyl_bessel_k(16, ldexp(T(1), -1021)), std::numeric_limits<T>::infinity());
}

View File

@@ -247,29 +247,42 @@ void test_bessel(T, const char* name)
BOOST_IF_CONSTEXPR(std::numeric_limits<T>::has_infinity && (std::numeric_limits<T>::min_exponent < -1072))
{
static const std::array<std::array<T, 3>, 7> coverage_data = { {
#if LDBL_MAX_10_EXP > 4931
#if (LDBL_MAX_10_EXP > 4931) || defined(TEST_MPF_50) || defined(TEST_MPFR_50) || defined(TEST_CPP_DEC_FLOAT) || defined(TEST_FLOAT128) || defined(TEST_CPP_BIN_FLOAT)
{{ SC_(15.25), ldexp(T(1), -1071), SC_(-9.39553199265929955912687892204143267985847111378392154596e4931)}},
#else
{{ SC_(15.25), ldexp(T(1), -1071), -std::numeric_limits<T>::infinity() }},
#endif
#if LDBL_MAX_10_EXP > 4945
#if (LDBL_MAX_10_EXP > 4945) || defined(TEST_MPF_50) || defined(TEST_MPFR_50) || defined(TEST_CPP_DEC_FLOAT) || defined(TEST_FLOAT128) || defined(TEST_CPP_BIN_FLOAT)
{{ SC_(15.25), ldexp(T(1), -1074), SC_(-5.55960167798850683070863439793e+4945)}},
#else
{{ SC_(15.25), ldexp(T(1), -1074), -std::numeric_limits<T>::infinity() }},
#endif
#if LDBL_MAX_10_EXP > 9872
#if (LDBL_MAX_10_EXP > 9872) || defined(TEST_MPF_50) || defined(TEST_MPFR_50) || defined(TEST_CPP_DEC_FLOAT) || defined(TEST_FLOAT128) || defined(TEST_CPP_BIN_FLOAT)
{{ SC_(31.25), ldexp(T(1), -1045), SC_(-1.64443614527479263825137492596041426343778386094212520006e9872)}},
#else
{{ SC_(31.25), ldexp(T(1), -1045), -std::numeric_limits<T>::infinity() }},
#endif
#if defined(TEST_MPF_50) || defined(TEST_MPFR_50) || defined(TEST_CPP_DEC_FLOAT) || defined(TEST_FLOAT128) || defined(TEST_CPP_BIN_FLOAT)
// Our exponent range may be so extreme that we can't trigger the coverage cases below, so use a copy of previous cases here
// as a placeholder.
{{ SC_(15.25), ldexp(T(1), -1071), SC_(-9.39553199265929955912687892204143267985847111378392154596e4931)}},
{{ SC_(15.25), ldexp(T(1), -1071), SC_(-9.39553199265929955912687892204143267985847111378392154596e4931)}},
#else
{{ SC_(233.0), ldexp(T(1), -63), -std::numeric_limits<T>::infinity() }},
{{ SC_(233.0), ldexp(T(1), -64), -std::numeric_limits<T>::infinity() }},
#if LDBL_MAX_10_EXP > 413
#endif
#if (LDBL_MAX_10_EXP > 413) || defined(TEST_MPF_50) || defined(TEST_MPFR_50) || defined(TEST_CPP_DEC_FLOAT) || defined(TEST_FLOAT128) || defined(TEST_CPP_BIN_FLOAT)
{{ SC_(200.25), SC_(1.25), SC_(-3.545198572052800784992190965856441074217589237581037286156e413)}},
#else
{{ SC_(200.25), SC_(1.25), -std::numeric_limits<T>::infinity()}},
#endif
#if defined(TEST_MPF_50) || defined(TEST_MPFR_50) || defined(TEST_CPP_DEC_FLOAT) || defined(TEST_FLOAT128) || defined(TEST_CPP_BIN_FLOAT)
// Our exponent range may be so extreme that we can't trigger the coverage cases below, so use a copy of previous cases here
// as a placeholder.
{{ SC_(15.25), ldexp(T(1), -1071), SC_(-9.39553199265929955912687892204143267985847111378392154596e4931)}},
#else
{{ SC_(1652.25), SC_(1.25), -std::numeric_limits<T>::infinity()}},
#endif
} };
do_test_cyl_neumann_y<T>(coverage_data, name, "Extra Coverage Data");

View File

@@ -83,9 +83,11 @@ void test_binomial(T, const char* type_name)
//
BOOST_CHECK_THROW(boost::math::binomial_coefficient<T>(2, 3), std::domain_error);
T tolerance = boost::math::tools::epsilon<T>() * 200;
#if LDBL_MAX_10_EXP > 320
#if (LDBL_MAX_10_EXP > 320) || defined(TEST_MPF_50) || defined(TEST_MPFR_50) || defined(TEST_CPP_DEC_FLOAT) || defined(TEST_FLOAT128) || defined(TEST_CPP_BIN_FLOAT)
BOOST_IF_CONSTEXPR(std::numeric_limits<T>::max_exponent10 > 320)
{
BOOST_IF_CONSTEXPR(std::is_floating_point<T>::value == false)
tolerance *= 2;
BOOST_CHECK_CLOSE_FRACTION(boost::math::binomial_coefficient<T>(1072, 522), SC_(8.5549524921358966076960008392254468438388716743112653656397e320), tolerance);
}
else BOOST_IF_CONSTEXPR(std::numeric_limits<T>::has_infinity)
@@ -98,12 +100,13 @@ void test_binomial(T, const char* type_name)
BOOST_CHECK_EQUAL(boost::math::binomial_coefficient<T>(1072, 522), std::numeric_limits<T>::infinity());
}
#endif
#if LDBL_MAX_10_EXP > 4946
#if (LDBL_MAX_10_EXP > 4946) || defined(TEST_MPF_50) || defined(TEST_MPFR_50) || defined(TEST_CPP_DEC_FLOAT) || defined(TEST_FLOAT128) || defined(TEST_CPP_BIN_FLOAT)
BOOST_IF_CONSTEXPR(std::numeric_limits<T>::max_exponent10 > 4946)
{
BOOST_CHECK_CLOSE_FRACTION(boost::math::binomial_coefficient<T>(16441, 8151), SC_(5.928641856224322477306131563286843903129818155323061805272e4946), tolerance);
}
else BOOST_IF_CONSTEXPR(std::numeric_limits<T>::has_infinity)
else BOOST_IF_CONSTEXPR(std::numeric_limits<T>::has_infinity && (std::numeric_limits<T>::max_exponent10 < 4950))
{
BOOST_CHECK_EQUAL(boost::math::binomial_coefficient<T>(16441, 8151), std::numeric_limits<T>::infinity());
}