From c005d4d4d1b0a7bb669dc80dbdeecf506ab58566 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Mon, 6 Jan 2014 17:24:45 +0000 Subject: [PATCH] Fix test tolerances for new tgamma code. --- test/test_bessel_airy_zeros.cpp | 9 ++++++--- test/test_bessel_k.cpp | 7 +++++++ test/test_gamma.cpp | 8 ++++---- test/test_gamma.hpp | 4 +++- test/test_igamma.cpp | 6 +++--- test/test_igamma.hpp | 7 +++++-- test/test_nc_t.cpp | 9 ++++++--- test/test_tgamma_ratio.cpp | 2 +- test/test_zeta.hpp | 15 +++++++++------ 9 files changed, 44 insertions(+), 23 deletions(-) diff --git a/test/test_bessel_airy_zeros.cpp b/test/test_bessel_airy_zeros.cpp index dbe425dd4..90bb9cb15 100644 --- a/test/test_bessel_airy_zeros.cpp +++ b/test/test_bessel_airy_zeros.cpp @@ -106,6 +106,9 @@ void test_bessel_zeros(RealType) static_cast(boost::math::tools::epsilon()), boost::math::tools::epsilon()); 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::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(1), static_cast(-1.17371322270912792491997996247390210454364638917570L), tolerance * 4); - BOOST_CHECK_CLOSE_FRACTION(airy_bi_zero(2), static_cast(-3.27109330283635271568022824016641380630093596910028L), tolerance); + BOOST_CHECK_CLOSE_FRACTION(airy_bi_zero(1), static_cast(-1.17371322270912792491997996247390210454364638917570L), tolerance * 4 * tolerance_tgamma_extra); + BOOST_CHECK_CLOSE_FRACTION(airy_bi_zero(2), static_cast(-3.27109330283635271568022824016641380630093596910028L), tolerance * tolerance_tgamma_extra); BOOST_CHECK_CLOSE_FRACTION(airy_bi_zero(3), static_cast(-4.83073784166201593266770933990517817696614261732301L), tolerance); BOOST_CHECK_CLOSE_FRACTION(airy_bi_zero(4), static_cast(-6.16985212831025125983336452055593667996554943427563L), tolerance); BOOST_CHECK_CLOSE_FRACTION(airy_bi_zero(5), static_cast(-7.37676207936776371359995933044254122209152229939710L), tolerance); @@ -957,7 +960,7 @@ Calculated using cpp_dec_float_50 unsigned int n_roots = 1U; std::vector roots; boost::math::airy_bi_zero(2U, n_roots, std::back_inserter(roots)); - BOOST_CHECK_CLOSE_FRACTION(roots[0], static_cast(-3.27109330283635271568022824016641380630093596910028L), tolerance); + BOOST_CHECK_CLOSE_FRACTION(roots[0], static_cast(-3.27109330283635271568022824016641380630093596910028L), tolerance * tolerance_tgamma_extra); } } // template void test_spots(RealType) diff --git a/test/test_bessel_k.cpp b/test/test_bessel_k.cpp index 7e3d440bd..52ea92f12 100644 --- a/test/test_bessel_k.cpp +++ b/test/test_bessel_k.cpp @@ -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 diff --git a/test/test_gamma.cpp b/test/test_gamma.cpp index a3edb2803..8c5d5a8bb 100644 --- a/test/test_gamma.cpp +++ b/test/test_gamma.cpp @@ -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 diff --git a/test/test_gamma.hpp b/test/test_gamma.hpp index d33665f3e..859887e1c 100644 --- a/test/test_gamma.hpp +++ b/test/test_gamma.hpp @@ -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::is_specialized ? 1 : 4; int sign = 1; BOOST_CHECK_CLOSE(::boost::math::lgamma(static_cast(3.5), &sign), static_cast(1.2009736023470742248160218814507129957702389154682L), tolerance); @@ -198,7 +200,7 @@ void test_spots(T) BOOST_CHECK(sign == 1); BOOST_CHECK_CLOSE(::boost::math::lgamma(static_cast(-0.125), &sign), static_cast(2.1653002489051702517540619481440174064962195287626L), tolerance); BOOST_CHECK(sign == -1); - BOOST_CHECK_CLOSE(::boost::math::lgamma(static_cast(-3.125), &sign), static_cast(0.1543111276840418242676072830970532952413339012367L), tolerance); + BOOST_CHECK_CLOSE(::boost::math::lgamma(static_cast(-3.125), &sign), static_cast(0.1543111276840418242676072830970532952413339012367L), tolerance * tolerance_tgamma_extra); BOOST_CHECK(sign == 1); BOOST_CHECK_CLOSE(::boost::math::lgamma(static_cast(-53249.0/1024), &sign), static_cast(-149.43323093420259741100038126078721302600128285894L), tolerance); BOOST_CHECK(sign == -1); diff --git a/test/test_igamma.cpp b/test/test_igamma.cpp index c2bea0bad..b22b649e3 100644 --- a/test/test_igamma.cpp +++ b/test/test_igamma.cpp @@ -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, diff --git a/test/test_igamma.hpp b/test/test_igamma.hpp index ce805bd42..bbfdcf0e5 100644 --- a/test/test_igamma.hpp +++ b/test/test_igamma.hpp @@ -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::is_specialized ? 1 : 10; + BOOST_CHECK_CLOSE(::boost::math::tgamma(static_cast(5), static_cast(1)), static_cast(23.912163676143750903709045060494956383977723517065L), tolerance); BOOST_CHECK_CLOSE(::boost::math::tgamma(static_cast(5), static_cast(5)), static_cast(10.571838841565097874621959975919877646444998907920L), tolerance); BOOST_CHECK_CLOSE(::boost::math::tgamma(static_cast(5), static_cast(10)), static_cast(0.70206451384706574414638719662835463671916532623256L), tolerance); BOOST_CHECK_CLOSE(::boost::math::tgamma(static_cast(5), static_cast(100)), static_cast(3.8734332808745531496973774140085644548465762343719e-36L), tolerance); - BOOST_CHECK_CLOSE(::boost::math::tgamma(static_cast(0.5), static_cast(0.5)), static_cast(0.56241823159440712427949495730204306902676756479651L), tolerance); + BOOST_CHECK_CLOSE(::boost::math::tgamma(static_cast(0.5), static_cast(0.5)), static_cast(0.56241823159440712427949495730204306902676756479651L), tolerance * tolerance_tgamma_extra); BOOST_CHECK_CLOSE(::boost::math::tgamma(static_cast(0.5), static_cast(9)/10), static_cast(0.31853210360412109873859360390443790076576777747449L), tolerance*10); BOOST_CHECK_CLOSE(::boost::math::tgamma(static_cast(0.5), static_cast(5)), static_cast(0.0027746032604128093194908357272603294120210079791437L), tolerance); - BOOST_CHECK_CLOSE(::boost::math::tgamma(static_cast(0.5), static_cast(100)), static_cast(3.7017478604082789202535664481339075721362102520338e-45L), tolerance); + BOOST_CHECK_CLOSE(::boost::math::tgamma(static_cast(0.5), static_cast(100)), static_cast(3.7017478604082789202535664481339075721362102520338e-45L), tolerance * tolerance_tgamma_extra); BOOST_CHECK_CLOSE(::boost::math::tgamma_lower(static_cast(5), static_cast(1)), static_cast(0.087836323856249096290954939505043616022276482935091L), tolerance); BOOST_CHECK_CLOSE(::boost::math::tgamma_lower(static_cast(5), static_cast(5)), static_cast(13.428161158434902125378040024080122353555001092080L), tolerance); diff --git a/test/test_nc_t.cpp b/test/test_nc_t.cpp index 639f208ee..5b41ae5a9 100644 --- a/test/test_nc_t.cpp +++ b/test/test_nc_t.cpp @@ -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::is_specialized ? 1 : 5; + boost::math::non_central_t_distribution 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&) { diff --git a/test/test_tgamma_ratio.cpp b/test/test_tgamma_ratio.cpp index aa7ab7e76..36e5cbda2 100644 --- a/test/test_tgamma_ratio.cpp +++ b/test/test_tgamma_ratio.cpp @@ -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, diff --git a/test/test_zeta.hpp b/test/test_zeta.hpp index db75f7987..0b42f0fad 100644 --- a/test/test_zeta.hpp +++ b/test/test_zeta.hpp @@ -135,13 +135,16 @@ void test_spots(T, const char* t) BOOST_CHECK_CLOSE(::boost::math::zeta(ldexp(static_cast(1), -33)), static_cast(-0.500000000106978525095789001562046589421133388262409441738089L), tolerance); BOOST_CHECK_CLOSE(::boost::math::zeta(ldexp(static_cast(1), -34)), static_cast(-0.500000000053489262544495600736249301842352101231724731340202L), tolerance); - BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast(1), -20)), static_cast(-0.499999123632834911086872289657767335473025908373776645822722L), tolerance); + // An extra fudge factor for real_concept which has a less accurate tgamma: + T tolerance_tgamma_extra = std::numeric_limits::is_specialized ? 1 : 10; + + BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast(1), -20)), static_cast(-0.499999123632834911086872289657767335473025908373776645822722L), tolerance * tolerance_tgamma_extra); BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast(1), -21)), static_cast(-0.499999561816189359548137231641582253243376087534976981434190L), tolerance); - BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast(1), -22)), static_cast(-0.499999780908037655734554449793729262345041281451929584703788L), tolerance); - BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast(1), -23)), static_cast(-0.499999890454004571852312499433422838864632848598847415933664L), tolerance); - BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast(1), -24)), static_cast(-0.499999945226998721921779295091241395945379526155584220813497L), tolerance); - BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast(1), -25)), static_cast(-0.499999972613498469959715937215237923104705216198368099221577L), tolerance); - BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast(1), -26)), static_cast(-0.499999986306749012229554607064736104475024094525587925697276L), tolerance); + BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast(1), -22)), static_cast(-0.499999780908037655734554449793729262345041281451929584703788L), tolerance * tolerance_tgamma_extra); + BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast(1), -23)), static_cast(-0.499999890454004571852312499433422838864632848598847415933664L), tolerance * tolerance_tgamma_extra); + BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast(1), -24)), static_cast(-0.499999945226998721921779295091241395945379526155584220813497L), tolerance * tolerance_tgamma_extra); + BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast(1), -25)), static_cast(-0.499999972613498469959715937215237923104705216198368099221577L), tolerance * tolerance_tgamma_extra); + BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast(1), -26)), static_cast(-0.499999986306749012229554607064736104475024094525587925697276L), tolerance * tolerance_tgamma_extra); BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast(1), -27)), static_cast(-0.499999993153374450427200221401546739119918746163907954406855L), tolerance); BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast(1), -28)), static_cast(-0.499999996576687211291705684949926422460038672790251466963619L), tolerance); BOOST_CHECK_CLOSE(::boost::math::zeta(-ldexp(static_cast(1), -29)), static_cast(-0.499999998288343602165379216634983519354686193860717726606017L), tolerance);