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

Fix test tolerances for new tgamma code.

This commit is contained in:
jzmaddock
2014-01-06 17:24:45 +00:00
parent 49b30df548
commit c005d4d4d1
9 changed files with 44 additions and 23 deletions

View File

@@ -106,6 +106,9 @@ void test_bessel_zeros(RealType)
static_cast<RealType>(boost::math::tools::epsilon<long double>()),
boost::math::tools::epsilon<RealType>());
std::cout << "Tolerance for type " << typeid(RealType).name() << " is " << tolerance << "." << std::endl;
//
// An extra fudge factor for real_concept which has a less accurate tgamma:
RealType tolerance_tgamma_extra = std::numeric_limits<RealType>::is_specialized ? 1 : 10;
// http://www.wolframalpha.com/
using boost::math::cyl_bessel_j_zero; // (nu, j)
@@ -913,8 +916,8 @@ Calculated using cpp_dec_float_50
//}
// Table[N[AiryBiZero[n], 51], {n, 1, 20, 1}]
BOOST_CHECK_CLOSE_FRACTION(airy_bi_zero<RealType>(1), static_cast<RealType>(-1.17371322270912792491997996247390210454364638917570L), tolerance * 4);
BOOST_CHECK_CLOSE_FRACTION(airy_bi_zero<RealType>(2), static_cast<RealType>(-3.27109330283635271568022824016641380630093596910028L), tolerance);
BOOST_CHECK_CLOSE_FRACTION(airy_bi_zero<RealType>(1), static_cast<RealType>(-1.17371322270912792491997996247390210454364638917570L), tolerance * 4 * tolerance_tgamma_extra);
BOOST_CHECK_CLOSE_FRACTION(airy_bi_zero<RealType>(2), static_cast<RealType>(-3.27109330283635271568022824016641380630093596910028L), tolerance * tolerance_tgamma_extra);
BOOST_CHECK_CLOSE_FRACTION(airy_bi_zero<RealType>(3), static_cast<RealType>(-4.83073784166201593266770933990517817696614261732301L), tolerance);
BOOST_CHECK_CLOSE_FRACTION(airy_bi_zero<RealType>(4), static_cast<RealType>(-6.16985212831025125983336452055593667996554943427563L), tolerance);
BOOST_CHECK_CLOSE_FRACTION(airy_bi_zero<RealType>(5), static_cast<RealType>(-7.37676207936776371359995933044254122209152229939710L), tolerance);
@@ -957,7 +960,7 @@ Calculated using cpp_dec_float_50
unsigned int n_roots = 1U;
std::vector<RealType> roots;
boost::math::airy_bi_zero<RealType>(2U, n_roots, std::back_inserter(roots));
BOOST_CHECK_CLOSE_FRACTION(roots[0], static_cast<RealType>(-3.27109330283635271568022824016641380630093596910028L), tolerance);
BOOST_CHECK_CLOSE_FRACTION(roots[0], static_cast<RealType>(-3.27109330283635271568022824016641380630093596910028L), tolerance * tolerance_tgamma_extra);
}
} // template <class RealType> void test_spots(RealType)

View File

@@ -86,6 +86,13 @@ void expected_results()
largest_type, // test type(s)
".*large.*", // test data group
".*", 100, 50); // test function
add_expected_result(
".*", // compiler
".*", // stdlib
".*", // platform
"real_concept", // test type(s)
".*", // test data group
".*", 70, 30); // test function
add_expected_result(
".*", // compiler
".*", // stdlib

View File

@@ -264,28 +264,28 @@ void expected_results()
".*", // platform
"real_concept", // test type(s)
"factorials", // test data group
"boost::math::tgamma", 70, 25); // test function
"boost::math::tgamma", 400, 100); // test function
add_expected_result(
".*", // compiler
".*", // stdlib
".*", // platform
"real_concept", // test type(s)
"factorials", // test data group
"boost::math::lgamma", 40, 4); // test function
"boost::math::lgamma", 200, 20); // test function
add_expected_result(
".*", // compiler
".*", // stdlib
".*", // platform
"real_concept", // test type(s)
"near.*", // test data group
"boost::math::tgamma", 80, 60); // test function
"boost::math::tgamma", 300, 100); // test function
add_expected_result(
".*", // compiler
".*", // stdlib
".*", // platform
"real_concept", // test type(s)
"near.*", // test data group
"boost::math::lgamma", 10000000, 10000000); // test function
"boost::math::lgamma", 15000000, 10000000); // test function
add_expected_result(
".*", // compiler
".*", // stdlib

View File

@@ -190,6 +190,8 @@ void test_spots(T)
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
// An extra fudge factor for real_concept which has a less accurate tgamma:
T tolerance_tgamma_extra = std::numeric_limits<T>::is_specialized ? 1 : 4;
int sign = 1;
BOOST_CHECK_CLOSE(::boost::math::lgamma(static_cast<T>(3.5), &sign), static_cast<T>(1.2009736023470742248160218814507129957702389154682L), tolerance);
@@ -198,7 +200,7 @@ void test_spots(T)
BOOST_CHECK(sign == 1);
BOOST_CHECK_CLOSE(::boost::math::lgamma(static_cast<T>(-0.125), &sign), static_cast<T>(2.1653002489051702517540619481440174064962195287626L), tolerance);
BOOST_CHECK(sign == -1);
BOOST_CHECK_CLOSE(::boost::math::lgamma(static_cast<T>(-3.125), &sign), static_cast<T>(0.1543111276840418242676072830970532952413339012367L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::lgamma(static_cast<T>(-3.125), &sign), static_cast<T>(0.1543111276840418242676072830970532952413339012367L), tolerance * tolerance_tgamma_extra);
BOOST_CHECK(sign == 1);
BOOST_CHECK_CLOSE(::boost::math::lgamma(static_cast<T>(-53249.0/1024), &sign), static_cast<T>(-149.43323093420259741100038126078721302600128285894L), tolerance);
BOOST_CHECK(sign == -1);

View File

@@ -299,14 +299,14 @@ void expected_results()
"[^|]*", // platform
"real_concept", // test type(s)
"[^|]*medium[^|]*", // test data group
"[^|]*", 200, 50); // test function
"[^|]*", 1000, 200); // test function
add_expected_result(
"[^|]*", // compiler
"[^|]*", // stdlib
"[^|]*", // platform
"real_concept", // test type(s)
"[^|]*small[^|]*", // test data group
".*", 20, 10); // test function
".*", 100, 20); // test function
add_expected_result(
"[^|]*", // compiler
"[^|]*", // stdlib
@@ -320,7 +320,7 @@ void expected_results()
"[^|]*", // platform
"real_concept", // test type(s)
"[^|]*integer[^|]*", // test data group
".*", 40, 10); // test function
".*", 200, 40); // test function
//
// Finish off by printing out the compiler/stdlib/platform names,

View File

@@ -163,14 +163,17 @@ void test_spots(T)
#if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__))
tolerance *= 10;
#endif
// An extra fudge factor for real_concept which has a less accurate tgamma:
T tolerance_tgamma_extra = std::numeric_limits<T>::is_specialized ? 1 : 10;
BOOST_CHECK_CLOSE(::boost::math::tgamma(static_cast<T>(5), static_cast<T>(1)), static_cast<T>(23.912163676143750903709045060494956383977723517065L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::tgamma(static_cast<T>(5), static_cast<T>(5)), static_cast<T>(10.571838841565097874621959975919877646444998907920L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::tgamma(static_cast<T>(5), static_cast<T>(10)), static_cast<T>(0.70206451384706574414638719662835463671916532623256L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::tgamma(static_cast<T>(5), static_cast<T>(100)), static_cast<T>(3.8734332808745531496973774140085644548465762343719e-36L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::tgamma(static_cast<T>(0.5), static_cast<T>(0.5)), static_cast<T>(0.56241823159440712427949495730204306902676756479651L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::tgamma(static_cast<T>(0.5), static_cast<T>(0.5)), static_cast<T>(0.56241823159440712427949495730204306902676756479651L), tolerance * tolerance_tgamma_extra);
BOOST_CHECK_CLOSE(::boost::math::tgamma(static_cast<T>(0.5), static_cast<T>(9)/10), static_cast<T>(0.31853210360412109873859360390443790076576777747449L), tolerance*10);
BOOST_CHECK_CLOSE(::boost::math::tgamma(static_cast<T>(0.5), static_cast<T>(5)), static_cast<T>(0.0027746032604128093194908357272603294120210079791437L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::tgamma(static_cast<T>(0.5), static_cast<T>(100)), static_cast<T>(3.7017478604082789202535664481339075721362102520338e-45L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::tgamma(static_cast<T>(0.5), static_cast<T>(100)), static_cast<T>(3.7017478604082789202535664481339075721362102520338e-45L), tolerance * tolerance_tgamma_extra);
BOOST_CHECK_CLOSE(::boost::math::tgamma_lower(static_cast<T>(5), static_cast<T>(1)), static_cast<T>(0.087836323856249096290954939505043616022276482935091L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::tgamma_lower(static_cast<T>(5), static_cast<T>(5)), static_cast<T>(13.428161158434902125378040024080122353555001092080L), tolerance);

View File

@@ -226,6 +226,9 @@ void test_spot(
RealType Q, // Complement of CDF
RealType tol) // Test tolerance
{
// An extra fudge factor for real_concept which has a less accurate tgamma:
RealType tolerance_tgamma_extra = std::numeric_limits<RealType>::is_specialized ? 1 : 5;
boost::math::non_central_t_distribution<RealType> dist(df, ncp);
BOOST_CHECK_CLOSE(
cdf(dist, t), P, tol);
@@ -235,11 +238,11 @@ void test_spot(
BOOST_CHECK_CLOSE(
variance(dist), naive_variance(df, ncp), tol);
BOOST_CHECK_CLOSE(
skewness(dist), naive_skewness(df, ncp), tol * 10);
skewness(dist), naive_skewness(df, ncp), tol * 10 * tolerance_tgamma_extra);
BOOST_CHECK_CLOSE(
kurtosis_excess(dist), naive_kurtosis_excess(df, ncp), tol * 50);
kurtosis_excess(dist), naive_kurtosis_excess(df, ncp), tol * 50 * tolerance_tgamma_extra);
BOOST_CHECK_CLOSE(
kurtosis(dist), 3 + naive_kurtosis_excess(df, ncp), tol * 50);
kurtosis(dist), 3 + naive_kurtosis_excess(df, ncp), tol * 50 * tolerance_tgamma_extra);
}
catch(const std::domain_error&)
{

View File

@@ -115,7 +115,7 @@ void expected_results()
"[^|]*", // platform
"real_concept", // test type(s)
"[^|]*", // test data group
"boost::math::tgamma_ratio[^|]*", 150, 50); // test function
"boost::math::tgamma_ratio[^|]*", 250, 150); // test function
//
// Finish off by printing out the compiler/stdlib/platform names,

View File

@@ -135,13 +135,16 @@ void test_spots(T, const char* t)
BOOST_CHECK_CLOSE(::boost::math::zeta(ldexp(static_cast<T>(1), -33)), static_cast<T>(-0.500000000106978525095789001562046589421133388262409441738089L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::zeta(ldexp(static_cast<T>(1), -34)), static_cast<T>(-0.500000000053489262544495600736249301842352101231724731340202L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast<T>(1), -20)), static_cast<T>(-0.499999123632834911086872289657767335473025908373776645822722L), tolerance);
// An extra fudge factor for real_concept which has a less accurate tgamma:
T tolerance_tgamma_extra = std::numeric_limits<T>::is_specialized ? 1 : 10;
BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast<T>(1), -20)), static_cast<T>(-0.499999123632834911086872289657767335473025908373776645822722L), tolerance * tolerance_tgamma_extra);
BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast<T>(1), -21)), static_cast<T>(-0.499999561816189359548137231641582253243376087534976981434190L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast<T>(1), -22)), static_cast<T>(-0.499999780908037655734554449793729262345041281451929584703788L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast<T>(1), -23)), static_cast<T>(-0.499999890454004571852312499433422838864632848598847415933664L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast<T>(1), -24)), static_cast<T>(-0.499999945226998721921779295091241395945379526155584220813497L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast<T>(1), -25)), static_cast<T>(-0.499999972613498469959715937215237923104705216198368099221577L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast<T>(1), -26)), static_cast<T>(-0.499999986306749012229554607064736104475024094525587925697276L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast<T>(1), -22)), static_cast<T>(-0.499999780908037655734554449793729262345041281451929584703788L), tolerance * tolerance_tgamma_extra);
BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast<T>(1), -23)), static_cast<T>(-0.499999890454004571852312499433422838864632848598847415933664L), tolerance * tolerance_tgamma_extra);
BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast<T>(1), -24)), static_cast<T>(-0.499999945226998721921779295091241395945379526155584220813497L), tolerance * tolerance_tgamma_extra);
BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast<T>(1), -25)), static_cast<T>(-0.499999972613498469959715937215237923104705216198368099221577L), tolerance * tolerance_tgamma_extra);
BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast<T>(1), -26)), static_cast<T>(-0.499999986306749012229554607064736104475024094525587925697276L), tolerance * tolerance_tgamma_extra);
BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast<T>(1), -27)), static_cast<T>(-0.499999993153374450427200221401546739119918746163907954406855L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast<T>(1), -28)), static_cast<T>(-0.499999996576687211291705684949926422460038672790251466963619L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast<T>(1), -29)), static_cast<T>(-0.499999998288343602165379216634983519354686193860717726606017L), tolerance);