diff --git a/include/boost/math/special_functions.hpp b/include/boost/math/special_functions.hpp index aa7019a1e..d86a31b6b 100644 --- a/include/boost/math/special_functions.hpp +++ b/include/boost/math/special_functions.hpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include diff --git a/include/boost/math/special_functions/detail/polygamma.hpp b/include/boost/math/special_functions/detail/polygamma.hpp index 75baf3454..367de7a40 100644 --- a/include/boost/math/special_functions/detail/polygamma.hpp +++ b/include/boost/math/special_functions/detail/polygamma.hpp @@ -62,7 +62,7 @@ // know that we have to use logs for the initial terms: // part_term = ((n > boost::math::max_factorial::value) && (n * n > tools::log_max_value())) - ? 0 : boost::math::factorial(n - 1, pol) * pow(x, -n - 1); + ? T(0) : boost::math::factorial(n - 1, pol) * pow(x, -n - 1); if(part_term == 0) { // Either n is very large, or the power term underflows, @@ -140,7 +140,7 @@ { z_plus_k_pow_minus_m_minus_one = pow(z, minus_m_minus_one); sum0 += z_plus_k_pow_minus_m_minus_one; - ++z; + z += 1; } sum0 *= boost::math::factorial(n); if((n - 1) & 1) @@ -161,7 +161,7 @@ const bool b_negate = (( n % 2 ) == 0 ) ; const T n_fact = boost::math::factorial(n); - const T z_pow_n_plus_one = pow(x, static_cast(n + 1)); + const T z_pow_n_plus_one = pow(x, n + 1); const T n_fact_over_pow_term = n_fact / z_pow_n_plus_one; const T term0 = !b_negate ? n_fact_over_pow_term : -n_fact_over_pow_term; diff --git a/include/boost/math/special_functions/digamma.hpp b/include/boost/math/special_functions/digamma.hpp index d69b2cd68..3ac522000 100644 --- a/include/boost/math/special_functions/digamma.hpp +++ b/include/boost/math/special_functions/digamma.hpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -505,7 +506,7 @@ T digamma_imp(T x, const mpl::int_<0>* t, const Policy& pol) while(val < x) { result += 1 / val; - ++val; + val += 1; } } else if(floor(two_x) == two_x) diff --git a/include/boost/math/special_functions/factorials.hpp b/include/boost/math/special_functions/factorials.hpp index de24642ac..e36a098bb 100644 --- a/include/boost/math/special_functions/factorials.hpp +++ b/include/boost/math/special_functions/factorials.hpp @@ -151,7 +151,7 @@ T rising_factorial_imp(T x, int n, const Policy& pol) if((x < 1) && (x + n < 0)) { T val = boost::math::tgamma_delta_ratio(1 - x, static_cast(-n), pol); - return (n & 1) ? -val : val; + return (n & 1) ? T(-val) : val; } // // We don't optimise this for small n, because diff --git a/include/boost/math/special_functions/math_fwd.hpp b/include/boost/math/special_functions/math_fwd.hpp index e952dcdb5..f91d21eda 100644 --- a/include/boost/math/special_functions/math_fwd.hpp +++ b/include/boost/math/special_functions/math_fwd.hpp @@ -463,6 +463,20 @@ namespace boost template typename tools::promote_args::type digamma(T x, const Policy&); + // trigamma: + template + typename tools::promote_args::type trigamma(T x); + + template + typename tools::promote_args::type trigamma(T x, const Policy&); + + // polygamma: + template + typename tools::promote_args::type polygamma(int n, T x); + + template + typename tools::promote_args::type polygamma(int n, T x, const Policy&); + // Hypotenuse function sqrt(x ^ 2 + y ^ 2). template typename tools::promote_args::type @@ -1205,6 +1219,12 @@ namespace boost template \ inline typename boost::math::tools::promote_args::type digamma(T x){ return boost::math::digamma(x, Policy()); }\ \ + template \ + inline typename boost::math::tools::promote_args::type trigamma(T x){ return boost::math::trigamma(x, Policy()); }\ +\ + template \ + inline typename boost::math::tools::promote_args::type polygamma(int n, T x){ return boost::math::polygamma(n, x, Policy()); }\ + \ template \ inline typename boost::math::tools::promote_args::type \ hypot(T1 x, T2 y){ return boost::math::hypot(x, y, Policy()); }\ diff --git a/include/boost/math/special_functions/polygamma.hpp b/include/boost/math/special_functions/polygamma.hpp index 071f13ca3..2c6b94d97 100644 --- a/include/boost/math/special_functions/polygamma.hpp +++ b/include/boost/math/special_functions/polygamma.hpp @@ -72,13 +72,13 @@ } template - inline T trigamma(T x, const Policy &pol) + inline typename tools::promote_args::type trigamma(T x, const Policy &pol) { return boost::math::polygamma(1,x,pol); } template - inline T trigamma(T x) + inline typename tools::promote_args::type trigamma(T x) { return boost::math::trigamma(x,policies::policy<>()); } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 4f908aa9e..ca1acaec4 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -604,7 +604,7 @@ run test_normal.cpp pch ../../test/build//boost_unit_test_framework ; run test_owens_t.cpp ../../test/build//boost_unit_test_framework ; run test_pareto.cpp ../../test/build//boost_unit_test_framework ; run test_polygamma.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ; -run test_trigamma.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ; +run test_trigamma.cpp test_instances//test_instances ../../test/build//boost_unit_test_framework ; run test_poisson.cpp ../../test/build//boost_unit_test_framework : # command line : # input files @@ -774,6 +774,7 @@ run compile_test/sf_binomial_incl_test.cpp compile_test_main ; run compile_test/sf_cbrt_incl_test.cpp compile_test_main ; run compile_test/sf_cos_pi_incl_test.cpp compile_test_main ; run compile_test/sf_digamma_incl_test.cpp compile_test_main ; +run compile_test/sf_polygamma_incl_test.cpp compile_test_main ; run compile_test/sf_ellint_1_incl_test.cpp compile_test_main ; run compile_test/sf_ellint_2_incl_test.cpp compile_test_main ; run compile_test/sf_ellint_3_incl_test.cpp compile_test_main ; diff --git a/test/compile_test/instantiate.hpp b/test/compile_test/instantiate.hpp index c6a9d5a7e..776829a3a 100644 --- a/test/compile_test/instantiate.hpp +++ b/test/compile_test/instantiate.hpp @@ -166,6 +166,8 @@ void instantiate(RealType) boost::math::lgamma(v1); boost::math::lgamma(v1, &i); boost::math::digamma(v1); + boost::math::trigamma(v1); + boost::math::polygamma(i, v1); boost::math::tgamma_ratio(v1, v2); boost::math::tgamma_delta_ratio(v1, v2); boost::math::factorial(i); @@ -351,6 +353,8 @@ void instantiate(RealType) boost::math::lgamma(v1 * 1); boost::math::lgamma(v1 * 1, &i); boost::math::digamma(v1 * 1); + boost::math::trigamma(v1 * 1); + boost::math::polygamma(i, v1 * 1); boost::math::tgamma_ratio(v1 * 1, v2 + 0); boost::math::tgamma_delta_ratio(v1 * 1, v2 + 0); boost::math::factorial(i); @@ -525,6 +529,8 @@ void instantiate(RealType) boost::math::lgamma(v1, pol); boost::math::lgamma(v1, &i, pol); boost::math::digamma(v1, pol); + boost::math::trigamma(v1, pol); + boost::math::polygamma(i, v1, pol); boost::math::tgamma_ratio(v1, v2, pol); boost::math::tgamma_delta_ratio(v1, v2, pol); boost::math::factorial(i, pol); @@ -702,6 +708,8 @@ void instantiate(RealType) test::lgamma(v1); test::lgamma(v1, &i); test::digamma(v1); + test::trigamma(v1); + test::polygamma(i, v1); test::tgamma_ratio(v1, v2); test::tgamma_delta_ratio(v1, v2); test::factorial(i); @@ -893,6 +901,8 @@ void instantiate_mixed(RealType) boost::math::lgamma(i); boost::math::lgamma(i, &i); boost::math::digamma(i); + boost::math::trigamma(i); + boost::math::polygamma(i, i); boost::math::tgamma_ratio(i, l); boost::math::tgamma_ratio(fr, lr); boost::math::tgamma_delta_ratio(i, s); @@ -1035,6 +1045,8 @@ void instantiate_mixed(RealType) boost::math::lgamma(i, pol); boost::math::lgamma(i, &i, pol); boost::math::digamma(i, pol); + boost::math::trigamma(i, pol); + boost::math::polygamma(i, i, pol); boost::math::tgamma_ratio(i, l, pol); boost::math::tgamma_ratio(fr, lr, pol); boost::math::tgamma_delta_ratio(i, s, pol); @@ -1170,6 +1182,8 @@ void instantiate_mixed(RealType) test::lgamma(i); test::lgamma(i, &i); test::digamma(i); + test::trigamma(i); + test::polygamma(i, i); test::tgamma_ratio(i, l); test::tgamma_ratio(fr, lr); test::tgamma_delta_ratio(i, s); diff --git a/test/compile_test/sf_polygamma_incl_test.cpp b/test/compile_test/sf_polygamma_incl_test.cpp new file mode 100644 index 000000000..883644993 --- /dev/null +++ b/test/compile_test/sf_polygamma_incl_test.cpp @@ -0,0 +1,28 @@ +// Copyright John Maddock 2006. +// 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) +// +// Basic sanity check that header +// #includes all the files that it needs to. +// +#include +// +// Note this header includes no other headers, this is +// important if this test is to be meaningful: +// +#include "test_compile_result.hpp" + +void compile_and_link_test() +{ + check_result(boost::math::trigamma(f)); + check_result(boost::math::trigamma(d)); +#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS + check_result(boost::math::trigamma(l)); +#endif + check_result(boost::math::polygamma(1, f)); + check_result(boost::math::polygamma(1, d)); +#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS + check_result(boost::math::polygamma(1, l)); +#endif +} diff --git a/test/test_digamma.hpp b/test/test_digamma.hpp index 250ce1046..5d1de7cd7 100644 --- a/test/test_digamma.hpp +++ b/test/test_digamma.hpp @@ -83,7 +83,7 @@ void test_digamma(T, const char* name) do_test_digamma(digamma_bugs, name, "Digamma Function: Values near 0"); static const boost::array, 40> digamma_integers = { { - { 1, SC_(-0.57721566490153286060651209008240243) }, { 2, SC_(0.42278433509846713939348790991759757) }, { 3, SC_(0.92278433509846713939348790991759757) }, { 4, SC_(1.2561176684318004727268212432509309) }, { 5, SC_(1.5061176684318004727268212432509309) }, { 6, SC_(1.7061176684318004727268212432509309) }, { 7, SC_(1.8727843350984671393934879099175976) }, { 8, SC_(2.0156414779556099965363450527747404) }, { 9, SC_(2.1406414779556099965363450527747404) }, { SC_(10), SC_(2.2517525890667211076474561638858515) }, { SC_(11), SC_(2.3517525890667211076474561638858515) }, { SC_(12), SC_(2.4426616799758120167383652547949424) }, { SC_(13), SC_(2.5259950133091453500716985881282758) }, { SC_(14), SC_(2.6029180902322222731486216650513527) }, { SC_(15), SC_(2.6743466616607937017200502364799241) }, { SC_(16), SC_(2.7410133283274603683867169031465908) }, { SC_(17), SC_(2.8035133283274603683867169031465908) }, { SC_(18), SC_(2.8623368577392250742690698443230614) }, { SC_(19), SC_(2.9178924132947806298246253998786169) }, { SC_(20), SC_(2.9705239922421490508772569788259854) }, { SC_(21), SC_(3.0205239922421490508772569788259854) }, { SC_(22), SC_(3.0681430398611966699248760264450330) }, { SC_(23), SC_(3.1135975853157421244703305718995784) }, { SC_(24), SC_(3.1570758461853073418616349197256654) }, { SC_(25), SC_(3.1987425128519740085283015863923321) }, { SC_(26), SC_(3.2387425128519740085283015863923321) }, { SC_(27), SC_(3.2772040513135124700667631248538705) }, { SC_(28), SC_(3.3142410883505495071038001618909076) }, { SC_(29), SC_(3.3499553740648352213895144476051933) }, { SC_(30), SC_(3.3844381326855248765619282407086415) }, { SC_(31), SC_(3.4177714660188582098952615740419749) }, { SC_(32), SC_(3.4500295305349872421533260901710071) }, { SC_(33), SC_(3.4812795305349872421533260901710071) }, { SC_(34), SC_(3.5115825608380175451836291204740374) }, { SC_(35), SC_(3.5409943255438998981248055910622727) }, { SC_(36), SC_(3.5695657541153284695533770196337013) }, { SC_(37), SC_(3.5973435318931062473311547974114791) }, { SC_(38), SC_(3.6243705589201332743581818244385061) }, { SC_(39), SC_(3.6506863483938174848844976139121903) }, { SC_(40), SC_(3.6763273740348431259101386395532160) } + { 1, SC_(-0.57721566490153286060651209008240243) }, { 2, SC_(0.42278433509846713939348790991759757) }, { 3, SC_(0.92278433509846713939348790991759757) }, { 4, SC_(1.2561176684318004727268212432509309) }, { 5, SC_(1.5061176684318004727268212432509309) }, { 6, SC_(1.7061176684318004727268212432509309) }, { 7, SC_(1.8727843350984671393934879099175976) }, { 8, SC_(2.0156414779556099965363450527747404) }, { 9, SC_(2.1406414779556099965363450527747404) }, { SC_(10.0), SC_(2.2517525890667211076474561638858515) }, { SC_(11.0), SC_(2.3517525890667211076474561638858515) }, { SC_(12.0), SC_(2.4426616799758120167383652547949424) }, { SC_(13.0), SC_(2.5259950133091453500716985881282758) }, { SC_(14.0), SC_(2.6029180902322222731486216650513527) }, { SC_(15.0), SC_(2.6743466616607937017200502364799241) }, { SC_(16.0), SC_(2.7410133283274603683867169031465908) }, { SC_(17.0), SC_(2.8035133283274603683867169031465908) }, { SC_(18.0), SC_(2.8623368577392250742690698443230614) }, { SC_(19.0), SC_(2.9178924132947806298246253998786169) }, { SC_(20.0), SC_(2.9705239922421490508772569788259854) }, { SC_(21.0), SC_(3.0205239922421490508772569788259854) }, { SC_(22.0), SC_(3.0681430398611966699248760264450330) }, { SC_(23.0), SC_(3.1135975853157421244703305718995784) }, { SC_(24.0), SC_(3.1570758461853073418616349197256654) }, { SC_(25.0), SC_(3.1987425128519740085283015863923321) }, { SC_(26.0), SC_(3.2387425128519740085283015863923321) }, { SC_(27.0), SC_(3.2772040513135124700667631248538705) }, { SC_(28.0), SC_(3.3142410883505495071038001618909076) }, { SC_(29.0), SC_(3.3499553740648352213895144476051933) }, { SC_(30.0), SC_(3.3844381326855248765619282407086415) }, { SC_(31.0), SC_(3.4177714660188582098952615740419749) }, { SC_(32.0), SC_(3.4500295305349872421533260901710071) }, { SC_(33.0), SC_(3.4812795305349872421533260901710071) }, { SC_(34.0), SC_(3.5115825608380175451836291204740374) }, { SC_(35.0), SC_(3.5409943255438998981248055910622727) }, { SC_(36.0), SC_(3.5695657541153284695533770196337013) }, { SC_(37.0), SC_(3.5973435318931062473311547974114791) }, { SC_(38.0), SC_(3.6243705589201332743581818244385061) }, { SC_(39.0), SC_(3.6506863483938174848844976139121903) }, { SC_(40.0), SC_(3.6763273740348431259101386395532160) } } }; do_test_digamma(digamma_integers, name, "Digamma Function: Integer arguments"); diff --git a/test/test_instances/double_test_instances_5.cpp b/test/test_instances/double_test_instances_5.cpp index 3c4d0a336..62dbbe2f1 100644 --- a/test/test_instances/double_test_instances_5.cpp +++ b/test/test_instances/double_test_instances_5.cpp @@ -9,6 +9,7 @@ #define BOOST_MATH_OVERFLOW_ERROR_POLICY ignore_error #include #include +#include #endif #define BOOST_MATH_TEST_TYPE double diff --git a/test/test_instances/float_test_instances_5.cpp b/test/test_instances/float_test_instances_5.cpp index 13e9e34f3..4e2315c06 100644 --- a/test/test_instances/float_test_instances_5.cpp +++ b/test/test_instances/float_test_instances_5.cpp @@ -9,6 +9,7 @@ #define BOOST_MATH_OVERFLOW_ERROR_POLICY ignore_error #include #include +#include #endif #define BOOST_MATH_TEST_TYPE float diff --git a/test/test_instances/ldouble_test_instances_5.cpp b/test/test_instances/ldouble_test_instances_5.cpp index 5e0e04c23..6e4599b64 100644 --- a/test/test_instances/ldouble_test_instances_5.cpp +++ b/test/test_instances/ldouble_test_instances_5.cpp @@ -9,6 +9,7 @@ #define BOOST_MATH_OVERFLOW_ERROR_POLICY ignore_error #include #include +#include #endif #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS diff --git a/test/test_instances/real_concept_test_instances_5.cpp b/test/test_instances/real_concept_test_instances_5.cpp index 14fc0909b..6dd7d0433 100644 --- a/test/test_instances/real_concept_test_instances_5.cpp +++ b/test/test_instances/real_concept_test_instances_5.cpp @@ -9,6 +9,7 @@ #define BOOST_MATH_OVERFLOW_ERROR_POLICY ignore_error #include #include +#include #endif #include diff --git a/test/test_instances/test_instances.hpp b/test/test_instances/test_instances.hpp index 889e9b2f1..e13dad959 100644 --- a/test/test_instances/test_instances.hpp +++ b/test/test_instances/test_instances.hpp @@ -287,8 +287,13 @@ namespace boost{ namespace math{ // digamma: template tools::promote_args::type digamma(BOOST_MATH_TEST_TYPE x); - template tools::promote_args::type digamma(BOOST_MATH_TEST_TYPE x, const policies::policy<>&); + // trigamma: + template tools::promote_args::type trigamma(BOOST_MATH_TEST_TYPE x); + template tools::promote_args::type trigamma(BOOST_MATH_TEST_TYPE x, const policies::policy<>&); + // polygamma: + template tools::promote_args::type polygamma(int, BOOST_MATH_TEST_TYPE x); + template tools::promote_args::type polygamma(int, BOOST_MATH_TEST_TYPE x, const policies::policy<>&); #endif #ifdef TEST_GROUP_6 // Hypotenuse function sqrt(x ^ 2 + y ^ 2). diff --git a/test/test_polygamma.hpp b/test/test_polygamma.hpp index 19c91c1d4..bdd0db1e9 100644 --- a/test/test_polygamma.hpp +++ b/test/test_polygamma.hpp @@ -8,7 +8,6 @@ #include #include -#include #define BOOST_TEST_MAIN #include #include @@ -149,12 +148,12 @@ void test_polygamma(T, const char* name) { 7, SC_(-12.750), SC_(3.3035269585550319411369451657990653e8) }, { 7, SC_(-12.250), SC_(3.3035269585550014530679554645726841e8) }, { 7, SC_(-11.750), SC_(3.3035269585549597724076958273392155e8) }, { 7, SC_(-11.250), SC_(3.3035269585549020632656302567379925e8) }, { 7, SC_(-10.750), SC_(3.3035269585548210560734246359421460e8) }, { 7, SC_(-10.250), SC_(3.3035269585547056321166932680182245e8) }, { 7, SC_(-9.7500), SC_(3.3035269585545384621477943726294791e8) }, { 7, SC_(-9.2500), SC_(3.3035269585542919758450034698830934e8) }, { 7, SC_(-8.7500), SC_(3.3035269585539213080586956648886140e8) }, { 7, SC_(-8.2500), SC_(3.3035269585533516103728829633890794e8) }, { 7, SC_(-7.7500), SC_(3.3035269585524545242332002141349801e8) }, { 7, SC_(-7.2500), SC_(3.3035269585510030650375087453009371e8) }, { 7, SC_(-6.7500), SC_(3.3035269585485817969386206988585281e8) }, { 7, SC_(-6.2500), SC_(3.3035269585444002902560781621765444e8) }, { 7, SC_(-5.7500), SC_(3.3035269585368867935011094629708018e8) }, { 7, SC_(-5.2500), SC_(3.3035269585227536550842381621765444e8) }, { 7, SC_(-4.7500), SC_(3.3035269584947086190323815702711063e8) }, { 7, SC_(-4.2500), SC_(3.3035269584354251332378488235637904e8) }, { 7, SC_(-3.7500), SC_(3.3035269583002256126086884537779074e8) }, { 7, SC_(-3.2500), SC_(3.3035269579619261006329391884897976e8) }, { 7, SC_(-2.7500), SC_(3.3035269570114408444331054633801022e8) }, { 7, SC_(-2.2500), SC_(3.3035269539127781220563177006740899e8) }, { 7, SC_(-1.7500), SC_(3.3035269416026348990428605870784761e8) }, { 7, SC_(-1.2500), SC_(3.3035268771818605685450990413016373e8) }, { 7, SC_(-0.75000), SC_(3.3035263686402030648824099487997220e8) }, { 7, SC_(-0.25000), SC_(3.3035184214649965685450990413016373e8) }, { 8, SC_(-7.7500), SC_(-1.0569114259666913771892699180522388e10) }, { 8, SC_(-7.2500), SC_(1.0569114259666319911021283350705169e10) }, { 8, SC_(-6.7500), SC_(-1.0569114259667313537290849324034796e10) }, { 8, SC_(-6.2500), SC_(1.0569114259665591328976435838084546e10) }, { 8, SC_(-5.7500), SC_(-1.0569114259668699611772332137177045e10) }, { 8, SC_(-5.2500), SC_(1.0569114259662820559674440318084546e10) }, { 8, SC_(-4.7500), SC_(-1.0569114259674567879524502974422220e10) }, { 8, SC_(-4.2500), SC_(1.0569114259649513356345466704581650e10) }, { 8, SC_(-3.7500), SC_(-1.0569114259707322912185335499305285e10) }, { 8, SC_(-3.2500), SC_(1.0569114259560384126678660185038311e10) }, { 8, SC_(-2.7500), SC_(-1.0569114259982263662729459870590150e10) }, { 8, SC_(-2.2500), SC_(1.0569114258563670778105953357268290e10) }, { 8, SC_(-1.7500), SC_(-1.0569114264464825392297531107332441e10) }, { 8, SC_(-1.2500), SC_(1.0569114231281566759079742278380307e10) }, { 8, SC_(-0.75000), SC_(-1.0569114526390508516485165684831300e10) }, { 8, SC_(-0.25000), SC_(1.0569108819622773799079742278380307e10) }, { 9, SC_(-7.7500), SC_(3.8051374324233954962308727459400485e11) }, { 9, SC_(-7.2500), SC_(3.8051374324233938918730928010849146e11) }, { 9, SC_(-6.7500), SC_(3.8051374324233908537939910023379690e11) }, { 9, SC_(-6.2500), SC_(3.8051374324233848474063291767903138e11) }, { 9, SC_(-5.7500), SC_(3.8051374324233723728009045648294056e11) }, { 9, SC_(-5.2500), SC_(3.8051374324233449483283804413023138e11) }, { 9, SC_(-4.7500), SC_(3.8051374324232805216534792821594812e11) }, { 9, SC_(-4.2500), SC_(3.8051374324231168248427408936422641e11) }, { 9, SC_(-3.7500), SC_(3.8051374324226598999820108764248547e11) }, { 9, SC_(-3.2500), SC_(3.8051374324212293823321496967578170e11) }, { 9, SC_(-2.7500), SC_(3.8051374324160613219689518915140179e11) }, { 9, SC_(-2.2500), SC_(3.8051374323936280896024439692195702e11) }, { 9, SC_(-1.7500), SC_(3.8051374322693593017285422874024520e11) }, { 9, SC_(-1.2500), SC_(3.8051374313023439288413955260640509e11) }, { 9, SC_(-0.75000), SC_(3.8051374187988955981988925091310821e11) }, { 9, SC_(-0.25000), SC_(3.8051370416629108357213955260640509e11) }, - {SC_(10), SC_(-7.7500), SC_(-1.5220204740668341333676731352020598e13)}, { SC_(10), SC_(-7.2500), SC_(1.5220204740668340669650877835677384e13) }, { SC_(10), SC_(-6.7500), SC_(-1.5220204740668341932700845125388608e13) }, { SC_(10), SC_(-6.2500), SC_(1.5220204740668339422138220784050543e13) }, { SC_(10), SC_(-5.7500), SC_(-1.5220204740668344670625746819834321e13) }, { SC_(10), SC_(-5.2500), SC_(1.5220204740668333038285748986372463e13) }, { SC_(10), SC_(-4.7500), SC_(-1.5220204740668360644738342521168221e13) }, { SC_(10), SC_(-4.2500), SC_(1.5220204740668289586193246215389596e13) }, { SC_(10), SC_(-3.7500), SC_(-1.5220204740668491301932335869743932e13) }, { SC_(10), SC_(-3.2500), SC_(1.5220204740667845482073107110240315e13) }, { SC_(10), SC_(-2.7500), SC_(-1.5220204740670250922735818265720155e13) }, { SC_(10), SC_(-2.2500), SC_(1.5220204740659352776617813040228546e13) }, { SC_(10), SC_(-1.7500), SC_(-1.5220204740723597111914149030851634e13) }, { SC_(10), SC_(-1.2500), SC_(1.5220204740174337594057347065492760e13) }, { SC_(10), SC_(-0.75000), SC_(-1.5220204748421004942502520332720988e13) }, { SC_(10), SC_(-0.25000), SC_(1.5220204428462791119561347065492760e13) }, - {SC_(11), SC_(-7.7500), SC_(6.6969403856797204470999075620782555e14)}, { SC_(11), SC_(-7.2500), SC_(6.6969403856797204443997065278152669e14) }, { SC_(11), SC_(-6.7500), SC_(6.6969403856797204385976298181981934e14) }, { SC_(11), SC_(-6.2500), SC_(6.6969403856797204254719282828940321e14) }, { SC_(11), SC_(-5.7500), SC_(6.6969403856797203939795943831775966e14) }, { SC_(11), SC_(-5.2500), SC_(6.6969403856797203131161247792548979e14) }, { SC_(11), SC_(-4.7500), SC_(6.6969403856797200883878751610651220e14) }, { SC_(11), SC_(-4.2500), SC_(6.6969403856797194026913294831009712e14) }, { SC_(11), SC_(-3.7500), SC_(6.6969403856797170626423300519402108e14) }, { SC_(11), SC_(-3.2500), SC_(6.6969403856797079082317494121441662e14) }, { SC_(11), SC_(-2.7500), SC_(6.6969403856796654470987612349915749e14) }, { SC_(11), SC_(-2.2500), SC_(6.6969403856794204628163394590053064e14) }, { SC_(11), SC_(-1.7500), SC_(6.6969403856775315995316280043863158e14) }, { SC_(11), SC_(-1.2500), SC_(6.6969403856557086094467166780182235e14) }, { SC_(11), SC_(-0.75000), SC_(6.6969403851936945358946446654116707e14) }, { SC_(11), SC_(-0.25000), SC_(6.6969403582250925196910686780182235e14) }, - {SC_(12), SC_(-7.7500), SC_(-3.2145233093874118337222380549030432e16)}, { SC_(12), SC_(-7.2500), SC_(3.2145233093874118336089459241510371e16) }, { SC_(12), SC_(-6.7500), SC_(-3.2145233093874118338538862264211861e16) }, { SC_(12), SC_(-6.2500), SC_(3.2145233093874118332956585600971684e16) }, { SC_(12), SC_(-5.7500), SC_(-3.2145233093874118346470957452659967e16) }, { SC_(12), SC_(-5.2500), SC_(3.2145233093874118311384271328272970e16) }, { SC_(12), SC_(-4.7500), SC_(-3.2145233093874118410246620594666049e16) }, { SC_(12), SC_(-4.2500), SC_(3.2145233093874118103287175260580644e16) }, { SC_(12), SC_(-3.7500), SC_(-3.2145233093874119174645495148550237e16) }, { SC_(12), SC_(-3.2500), SC_(3.2145233093874114857792705593486958e16) }, { SC_(12), SC_(-2.7500), SC_(-3.2145233093874135691619437169973801e16) }, { SC_(12), SC_(-2.2500), SC_(3.2145233093874008724100861918481841e16) }, { SC_(12), SC_(-1.7500), SC_(-3.2145233093875066825103277125147005e16) }, { SC_(12), SC_(-1.2500), SC_(3.2145233093861362402303729768622063e16) }, { SC_(12), SC_(-0.75000), SC_(-3.2145233094206840811597208557586761e16) }, { SC_(12), SC_(-0.25000), SC_(3.2145233067527970956138307688622063e16) }, - {SC_(13), SC_(-7.7500), SC_(1.6715535177261375555623235851859237e18)}, { SC_(13), SC_(-7.2500), SC_(1.6715535177261375555616811505615971e18) }, { SC_(13), SC_(-6.7500), SC_(1.6715535177261375555601152932765871e18) }, { SC_(13), SC_(-6.2500), SC_(1.6715535177261375555560635840337346e18) }, { SC_(13), SC_(-5.7500), SC_(1.6715535177261375555448386655062426e18) }, { SC_(13), SC_(-5.2500), SC_(1.6715535177261375555111931703465213e18) }, { SC_(13), SC_(-4.7500), SC_(1.6715535177261375554006502097069245e18) }, { SC_(13), SC_(-4.2500), SC_(1.6715535177261375549959051229408070e18) }, { SC_(13), SC_(-3.7500), SC_(1.6715535177261375533086111846120836e18) }, { SC_(13), SC_(-3.2500), SC_(1.6715535177261375450685102745473439e18) }, { SC_(13), SC_(-2.7500), SC_(1.6715535177261374960497681856044819e18) }, { SC_(13), SC_(-2.2500), SC_(1.6715535177261371205337428998473234e18) }, { SC_(13), SC_(-1.7500), SC_(1.6715535177261330943278445785436631e18) }, { SC_(13), SC_(-1.2500), SC_(1.6715535177260640528966928029814669e18) }, { SC_(13), SC_(-0.75000), SC_(1.6715535177236684875710325164741107e18) }, { SC_(13), SC_(-0.25000), SC_(1.6715535174521967818565724133494669e18) }, - {SC_(20), SC_(-7.7500), SC_(-1.0700016187896297695358366297227405e31)}, { SC_(20), SC_(-7.2500), SC_(1.0700016187896297695358366297227207e31) }, { SC_(20), SC_(-6.7500), SC_(-1.0700016187896297695358366297227919e31) }, { SC_(20), SC_(-6.2500), SC_(1.0700016187896297695358366297225123e31) }, { SC_(20), SC_(-5.7500), SC_(-1.0700016187896297695358366297237267e31) }, { SC_(20), SC_(-5.2500), SC_(1.0700016187896297695358366297178064e31) }, { SC_(20), SC_(-4.7500), SC_(-1.0700016187896297695358366297508349e31) }, { SC_(20), SC_(-4.2500), SC_(1.0700016187896297695358366295346680e31) }, { SC_(20), SC_(-3.7500), SC_(-1.0700016187896297695358366312489970e31) }, { SC_(20), SC_(-3.2500), SC_(1.0700016187896297695358366140480322e31) }, { SC_(20), SC_(-2.7500), SC_(-1.0700016187896297695358368457690989e31) }, { SC_(20), SC_(-2.2500), SC_(1.0700016187896297695358322831891149e31) }, { SC_(20), SC_(-1.7500), SC_(-1.0700016187896297695359814356987569e31) }, { SC_(20), SC_(-1.2500), SC_(1.0700016187896297695260533442006924e31) }, { SC_(20), SC_(-0.75000), SC_(-1.0700016187896297714516730336449055e31) }, { SC_(20), SC_(-0.25000), SC_(1.0700016187896275255700182817756420e31) }, - {SC_(23), SC_(-7.7500), SC_(7.2766958095269026379022334905108869e36)}, { SC_(23), SC_(-7.2500), SC_(7.2766958095269026379022334905108869e36) }, { SC_(23), SC_(-6.7500), SC_(7.2766958095269026379022334905108869e36) }, { SC_(23), SC_(-6.2500), SC_(7.2766958095269026379022334905108868e36) }, { SC_(23), SC_(-5.7500), SC_(7.2766958095269026379022334905108866e36) }, { SC_(23), SC_(-5.2500), SC_(7.2766958095269026379022334905108848e36) }, { SC_(23), SC_(-4.7500), SC_(7.2766958095269026379022334905108714e36) }, { SC_(23), SC_(-4.2500), SC_(7.2766958095269026379022334905107503e36) }, { SC_(23), SC_(-3.7500), SC_(7.2766958095269026379022334905093860e36) }, { SC_(23), SC_(-3.2500), SC_(7.2766958095269026379022334904893135e36) }, { SC_(23), SC_(-2.7500), SC_(7.2766958095269026379022334900771270e36) }, { SC_(23), SC_(-2.2500), SC_(7.2766958095269026379022334770834817e36) }, { SC_(23), SC_(-1.7500), SC_(7.2766958095269026379022327513062336e36) }, { SC_(23), SC_(-1.2500), SC_(7.2766958095269026379021422520579094e36) }, { SC_(23), SC_(-0.75000), SC_(7.2766958095269026378642504512809960e36) }, { SC_(23), SC_(-0.25000), SC_(7.2766958095269025158194448897624671e36) } + {SC_(10.0), SC_(-7.7500), SC_(-1.5220204740668341333676731352020598e13)}, { SC_(10.0), SC_(-7.2500), SC_(1.5220204740668340669650877835677384e13) }, { SC_(10.0), SC_(-6.7500), SC_(-1.5220204740668341932700845125388608e13) }, { SC_(10.0), SC_(-6.2500), SC_(1.5220204740668339422138220784050543e13) }, { SC_(10.0), SC_(-5.7500), SC_(-1.5220204740668344670625746819834321e13) }, { SC_(10.0), SC_(-5.2500), SC_(1.5220204740668333038285748986372463e13) }, { SC_(10.0), SC_(-4.7500), SC_(-1.5220204740668360644738342521168221e13) }, { SC_(10.0), SC_(-4.2500), SC_(1.5220204740668289586193246215389596e13) }, { SC_(10.0), SC_(-3.7500), SC_(-1.5220204740668491301932335869743932e13) }, { SC_(10.0), SC_(-3.2500), SC_(1.5220204740667845482073107110240315e13) }, { SC_(10.0), SC_(-2.7500), SC_(-1.5220204740670250922735818265720155e13) }, { SC_(10.0), SC_(-2.2500), SC_(1.5220204740659352776617813040228546e13) }, { SC_(10.0), SC_(-1.7500), SC_(-1.5220204740723597111914149030851634e13) }, { SC_(10.0), SC_(-1.2500), SC_(1.5220204740174337594057347065492760e13) }, { SC_(10.0), SC_(-0.75000), SC_(-1.5220204748421004942502520332720988e13) }, { SC_(10.0), SC_(-0.25000), SC_(1.5220204428462791119561347065492760e13) }, + {SC_(11.0), SC_(-7.7500), SC_(6.6969403856797204470999075620782555e14)}, { SC_(11.0), SC_(-7.2500), SC_(6.6969403856797204443997065278152669e14) }, { SC_(11.0), SC_(-6.7500), SC_(6.6969403856797204385976298181981934e14) }, { SC_(11.0), SC_(-6.2500), SC_(6.6969403856797204254719282828940321e14) }, { SC_(11.0), SC_(-5.7500), SC_(6.6969403856797203939795943831775966e14) }, { SC_(11.0), SC_(-5.2500), SC_(6.6969403856797203131161247792548979e14) }, { SC_(11.0), SC_(-4.7500), SC_(6.6969403856797200883878751610651220e14) }, { SC_(11.0), SC_(-4.2500), SC_(6.6969403856797194026913294831009712e14) }, { SC_(11.0), SC_(-3.7500), SC_(6.6969403856797170626423300519402108e14) }, { SC_(11.0), SC_(-3.2500), SC_(6.6969403856797079082317494121441662e14) }, { SC_(11.0), SC_(-2.7500), SC_(6.6969403856796654470987612349915749e14) }, { SC_(11.0), SC_(-2.2500), SC_(6.6969403856794204628163394590053064e14) }, { SC_(11.0), SC_(-1.7500), SC_(6.6969403856775315995316280043863158e14) }, { SC_(11.0), SC_(-1.2500), SC_(6.6969403856557086094467166780182235e14) }, { SC_(11.0), SC_(-0.75000), SC_(6.6969403851936945358946446654116707e14) }, { SC_(11.0), SC_(-0.25000), SC_(6.6969403582250925196910686780182235e14) }, + {SC_(12.0), SC_(-7.7500), SC_(-3.2145233093874118337222380549030432e16)}, { SC_(12.0), SC_(-7.2500), SC_(3.2145233093874118336089459241510371e16) }, { SC_(12.0), SC_(-6.7500), SC_(-3.2145233093874118338538862264211861e16) }, { SC_(12.0), SC_(-6.2500), SC_(3.2145233093874118332956585600971684e16) }, { SC_(12.0), SC_(-5.7500), SC_(-3.2145233093874118346470957452659967e16) }, { SC_(12.0), SC_(-5.2500), SC_(3.2145233093874118311384271328272970e16) }, { SC_(12.0), SC_(-4.7500), SC_(-3.2145233093874118410246620594666049e16) }, { SC_(12.0), SC_(-4.2500), SC_(3.2145233093874118103287175260580644e16) }, { SC_(12.0), SC_(-3.7500), SC_(-3.2145233093874119174645495148550237e16) }, { SC_(12.0), SC_(-3.2500), SC_(3.2145233093874114857792705593486958e16) }, { SC_(12.0), SC_(-2.7500), SC_(-3.2145233093874135691619437169973801e16) }, { SC_(12.0), SC_(-2.2500), SC_(3.2145233093874008724100861918481841e16) }, { SC_(12.0), SC_(-1.7500), SC_(-3.2145233093875066825103277125147005e16) }, { SC_(12.0), SC_(-1.2500), SC_(3.2145233093861362402303729768622063e16) }, { SC_(12.0), SC_(-0.75000), SC_(-3.2145233094206840811597208557586761e16) }, { SC_(12.0), SC_(-0.25000), SC_(3.2145233067527970956138307688622063e16) }, + {SC_(13.0), SC_(-7.7500), SC_(1.6715535177261375555623235851859237e18)}, { SC_(13.0), SC_(-7.2500), SC_(1.6715535177261375555616811505615971e18) }, { SC_(13.0), SC_(-6.7500), SC_(1.6715535177261375555601152932765871e18) }, { SC_(13.0), SC_(-6.2500), SC_(1.6715535177261375555560635840337346e18) }, { SC_(13.0), SC_(-5.7500), SC_(1.6715535177261375555448386655062426e18) }, { SC_(13.0), SC_(-5.2500), SC_(1.6715535177261375555111931703465213e18) }, { SC_(13.0), SC_(-4.7500), SC_(1.6715535177261375554006502097069245e18) }, { SC_(13.0), SC_(-4.2500), SC_(1.6715535177261375549959051229408070e18) }, { SC_(13.0), SC_(-3.7500), SC_(1.6715535177261375533086111846120836e18) }, { SC_(13.0), SC_(-3.2500), SC_(1.6715535177261375450685102745473439e18) }, { SC_(13.0), SC_(-2.7500), SC_(1.6715535177261374960497681856044819e18) }, { SC_(13.0), SC_(-2.2500), SC_(1.6715535177261371205337428998473234e18) }, { SC_(13.0), SC_(-1.7500), SC_(1.6715535177261330943278445785436631e18) }, { SC_(13.0), SC_(-1.2500), SC_(1.6715535177260640528966928029814669e18) }, { SC_(13.0), SC_(-0.75000), SC_(1.6715535177236684875710325164741107e18) }, { SC_(13.0), SC_(-0.25000), SC_(1.6715535174521967818565724133494669e18) }, + {SC_(20.0), SC_(-7.7500), SC_(-1.0700016187896297695358366297227405e31)}, { SC_(20.0), SC_(-7.2500), SC_(1.0700016187896297695358366297227207e31) }, { SC_(20.0), SC_(-6.7500), SC_(-1.0700016187896297695358366297227919e31) }, { SC_(20.0), SC_(-6.2500), SC_(1.0700016187896297695358366297225123e31) }, { SC_(20.0), SC_(-5.7500), SC_(-1.0700016187896297695358366297237267e31) }, { SC_(20.0), SC_(-5.2500), SC_(1.0700016187896297695358366297178064e31) }, { SC_(20.0), SC_(-4.7500), SC_(-1.0700016187896297695358366297508349e31) }, { SC_(20.0), SC_(-4.2500), SC_(1.0700016187896297695358366295346680e31) }, { SC_(20.0), SC_(-3.7500), SC_(-1.0700016187896297695358366312489970e31) }, { SC_(20.0), SC_(-3.2500), SC_(1.0700016187896297695358366140480322e31) }, { SC_(20.0), SC_(-2.7500), SC_(-1.0700016187896297695358368457690989e31) }, { SC_(20.0), SC_(-2.2500), SC_(1.0700016187896297695358322831891149e31) }, { SC_(20.0), SC_(-1.7500), SC_(-1.0700016187896297695359814356987569e31) }, { SC_(20.0), SC_(-1.2500), SC_(1.0700016187896297695260533442006924e31) }, { SC_(20.0), SC_(-0.75000), SC_(-1.0700016187896297714516730336449055e31) }, { SC_(20.0), SC_(-0.25000), SC_(1.0700016187896275255700182817756420e31) }, + {SC_(23.0), SC_(-7.7500), SC_(7.2766958095269026379022334905108869e36)}, { SC_(23.0), SC_(-7.2500), SC_(7.2766958095269026379022334905108869e36) }, { SC_(23.0), SC_(-6.7500), SC_(7.2766958095269026379022334905108869e36) }, { SC_(23.0), SC_(-6.2500), SC_(7.2766958095269026379022334905108868e36) }, { SC_(23.0), SC_(-5.7500), SC_(7.2766958095269026379022334905108866e36) }, { SC_(23.0), SC_(-5.2500), SC_(7.2766958095269026379022334905108848e36) }, { SC_(23.0), SC_(-4.7500), SC_(7.2766958095269026379022334905108714e36) }, { SC_(23.0), SC_(-4.2500), SC_(7.2766958095269026379022334905107503e36) }, { SC_(23.0), SC_(-3.7500), SC_(7.2766958095269026379022334905093860e36) }, { SC_(23.0), SC_(-3.2500), SC_(7.2766958095269026379022334904893135e36) }, { SC_(23.0), SC_(-2.7500), SC_(7.2766958095269026379022334900771270e36) }, { SC_(23.0), SC_(-2.2500), SC_(7.2766958095269026379022334770834817e36) }, { SC_(23.0), SC_(-1.7500), SC_(7.2766958095269026379022327513062336e36) }, { SC_(23.0), SC_(-1.2500), SC_(7.2766958095269026379021422520579094e36) }, { SC_(23.0), SC_(-0.75000), SC_(7.2766958095269026378642504512809960e36) }, { SC_(23.0), SC_(-0.25000), SC_(7.2766958095269025158194448897624671e36) } } }; do_test_polygamma(neg_data, name, "Mathematica Data - negative arguments"); diff --git a/test/test_trigamma.cpp b/test/test_trigamma.cpp new file mode 100644 index 000000000..1a5a1f240 --- /dev/null +++ b/test/test_trigamma.cpp @@ -0,0 +1,165 @@ + +/////////////////////////////////////////////////////////////////////////////// +// Copyright 2013 Nikhar Agrawal +// Distributed under 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_TEST_MAIN + +#include +#include +#include +#include +#include + +#define SC_(x) static_cast::type>(BOOST_JOIN(x, L)) + +template +void test(const char* name) +{ + std::cout << "Testing type " << name << ":\n"; + + static const typename table_type::type data[] = + { + /* First 50 from 1 to 50 inclusive: */ + /* [Table[N[polygamma(1,x),40],{x, 1,50,1}] */ + + SC_(1.644934066848226436472415166646025189219), + SC_(0.6449340668482264364724151666460251892189), + SC_(0.3949340668482264364724151666460251892189), + SC_(0.2838229557371153253613040555349140781078), + SC_(0.2213229557371153253613040555349140781078), + SC_(0.1813229557371153253613040555349140781078), + SC_(0.1535451779593375475835262777571363003301), + SC_(0.1331370146940314251345466859204016064525), + SC_(0.1175120146940314251345466859204016064525), + SC_(0.1051663356816857461222010069080559274402), + SC_(0.09516633568168574612220100690805592744016), + SC_(0.08690187287176839075030018046177493570463), + SC_(0.07995742842732394630585573601733049126018), + SC_(0.07404026866401033683840011471555534333119), + SC_(0.06893822784768380622615521675637166986180), + SC_(0.06449378340323936178171077231192722541736), + SC_(0.06058753340323936178171077231192722541736), + SC_(0.05712732579078261437686648165448777905057), + SC_(0.05404090603769619462378006190140135929749), + SC_(0.05127082293520311983153629458838196871577), + SC_(0.04877082293520311983153629458838196871577), + SC_(0.04650324923905799511498300660652255828493), + SC_(0.04443713353657865627200779999495231035105), + SC_(0.04254677436833669029847282835033983398054), + SC_(0.04081066325722557918736171723922872286943), + SC_(0.03921066325722557918736171723922872286943), + SC_(0.03773137331639717682049781191378493588718), + SC_(0.03635963120391432359690384757907986044136), + SC_(0.03508412099983269094384262308928394207401), + SC_(0.03389506035773994421375938884433744980291), + SC_(0.03278394924662883310264827773322633869180), + SC_(0.03174336652030209012658168043874142714133), + SC_(0.03076680402030209012658168043874142714133), + SC_(0.02984853037475571730748158861137687250405), + SC_(0.02898347847164153045627051594701701091235), + SC_(0.02816715194102928555831133227354762315725), + SC_(0.02739554700275768062003972733527601821898), + SC_(0.02666508681283803124093088876697799046149), + SC_(0.02597256603721476254286994693872314281606), + SC_(0.02531510384129102815759710012741479304617), + SC_(0.02469010384129102815759710012741479304617), + SC_(0.02409521984367056414807895616548736889388), + SC_(0.02352832641963428296894063417002251628617), + SC_(0.02298749353699501850166102356969801655659), + SC_(0.02247096461137518379091722191680545457312), + SC_(0.02197713745088135663042339475631162741262), + SC_(0.02150454765882086513703965184515850832000), + SC_(0.02105185413233829383780923084017887952869), + SC_(0.02061782635456051606003145306240110175091), + SC_(0.02020133322669712580597064506573304677382), + + /* From 500 to 1000 inclusive: */ + /* N[Table[polygamma(1,x),{x,500,1000,10}],40] */ + + SC_(0.002002001333332266669714268647774197060731), + SC_(0.001962707907716779452707536987802627805478), + SC_(0.001924927220830560087836886751110357728817), + SC_(0.001888573565201797462176247714903982850228), + SC_(0.001853567587934717491642342315537909130701), + SC_(0.001819835712496207207148883544824689071325), + SC_(0.001787309622509112919049294530378524341727), + SC_(0.001755925799930688909525507873736210387807), + SC_(0.001725625111046822227695996850789819829573), + SC_(0.001696352434604175251311909533625714712743), + SC_(0.001668056327160065158600874171864846275643), + SC_(0.001640688721375697019508021597082845963148), + SC_(0.001614204653530344531908147526628406223744), + SC_(0.001588562017007133389350166010439711886334), + SC_(0.001563721338907567163849825550712474891492), + SC_(0.001539645577302094752249567207416345365696), + SC_(0.001516299936926392520203240617160426547639), + SC_(0.001493651701394760695953585236460286481018), + SC_(0.001471670080229094300578280356096446686477), + SC_(0.001450326069199311597153133670448160203387), + SC_(0.001429592322643144721734539533648659286144), + SC_(0.001409443036583397946176993267702984100733), + SC_(0.001389853841592191696522797555468410819444), + SC_(0.001370801704466910484446604323882526177420), + SC_(0.001352264837883752677688324896962748941904), + SC_(0.001334222617283810151070001951163903617504), + SC_(0.001316655504325086010791929491458814498671), + SC_(0.001299544976303159784503980965599319524818), + SC_(0.001282873461004509259711608908038169904080), + SC_(0.001266624276510810009925604298617591070236), + SC_(0.001250781575520731608186449075029891794096), + SC_(0.001235330293798588858327739384385581649440), + SC_(0.001220256102397340964751055441376021959125), + SC_(0.001205545363337428588618639743321944385431), + SC_(0.001191185088453291061973294466848346283972), + SC_(0.001177162901146542691814823893259588004310), + SC_(0.001163467000809082214935959719602656350021), + SC_(0.001150086129701189861587852965952522886083), + SC_(0.001137009542089218078848777802653932997102), + SC_(0.001124226975465055320838136039288794501131), + SC_(0.001111728623685357358627683939948964547062), + SC_(0.001099505111882790624790340268963560561212), + SC_(0.001087547473014387385213628807079818129189), + SC_(0.001075847125923723081414745258211721267207), + SC_(0.001064395854804124498228502056895669702911), + SC_(0.001053185789959620623711365384007169340153), + SC_(0.001042209389768959890535954112125269154314), + SC_(0.001031459423765829864168427986966001957702), + SC_(0.001020928956755509990450221440026807721340), + SC_(0.001010611333894637278361033654755961804543), + SC_(0.001000500166666633333357142823809599566846) + }; + + static const unsigned index[] = + { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730, 740, 750, 760, 770, 780, 790, 800, 810, 820, 830, 840, 850, 860, 870, 880, 890, 900, 910, 920, 930, 940, 950, 960, 970, 980, 990, 1000 + }; + + + static const unsigned table_size = sizeof(index) / sizeof(index[0]); + + T tol = boost::math::tools::epsilon() * 10; + for(unsigned i = 1; i < table_size; ++i) + { + T x(index[i]); + T tg = boost::math::trigamma(x); + BOOST_CHECK_CLOSE_FRACTION(tg, static_cast(data[i]), tol); + } + +} + + +BOOST_AUTO_TEST_CASE(test_main) +{ + test("float"); + test("double"); +#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS + test("long double"); + test("real_concept"); +#endif +} + + diff --git a/test/test_zeta.hpp b/test/test_zeta.hpp index 3948d9e05..ae8792932 100644 --- a/test/test_zeta.hpp +++ b/test/test_zeta.hpp @@ -81,7 +81,7 @@ void test_zeta(T, const char* name) do_test_zeta(zeta_1_below_data, name, "Zeta: Values close to and less than 1"); boost::array, 90> integer_data = { { - { 2, SC_(1.6449340668482264364724151666460252) }, { 3, SC_(1.2020569031595942853997381615114500) }, { 4, SC_(1.0823232337111381915160036965411679) }, { 5, SC_(1.0369277551433699263313654864570342) }, { 6, SC_(1.0173430619844491397145179297909205) }, { 7, SC_(1.0083492773819228268397975498497968) }, { 8, SC_(1.0040773561979443393786852385086525) }, { 9, SC_(1.0020083928260822144178527692324121) }, { SC_(10), SC_(1.0009945751278180853371459589003190) }, { SC_(11), SC_(1.0004941886041194645587022825264699) }, { SC_(12), SC_(1.0002460865533080482986379980477397) }, { SC_(13), SC_(1.0001227133475784891467518365263574) }, { SC_(14), SC_(1.0000612481350587048292585451051353) }, { SC_(15), SC_(1.0000305882363070204935517285106451) }, { SC_(16), SC_(1.0000152822594086518717325714876367) }, { SC_(17), SC_(1.0000076371976378997622736002935630) }, { SC_(18), SC_(1.0000038172932649998398564616446219) }, { SC_(19), SC_(1.0000019082127165539389256569577951) }, { SC_(20), SC_(1.0000009539620338727961131520386834) }, { SC_(21), SC_(1.0000004769329867878064631167196044) }, { SC_(22), SC_(1.0000002384505027277329900036481868) }, { SC_(23), SC_(1.0000001192199259653110730677887189) }, { SC_(24), SC_(1.0000000596081890512594796124402079) }, { SC_(25), SC_(1.0000000298035035146522801860637051) }, { SC_(26), SC_(1.0000000149015548283650412346585066) }, { SC_(27), SC_(1.0000000074507117898354294919810042) }, { SC_(28), SC_(1.0000000037253340247884570548192040) }, { SC_(29), SC_(1.0000000018626597235130490064039099) }, { SC_(30), SC_(1.0000000009313274324196681828717647) }, { SC_(31), SC_(1.0000000004656629065033784072989233) }, { SC_(32), SC_(1.0000000002328311833676505492001456) }, { SC_(33), SC_(1.0000000001164155017270051977592974) }, { SC_(34), SC_(1.0000000000582077208790270088924369) }, { SC_(35), SC_(1.0000000000291038504449709968692943) }, { SC_(36), SC_(1.0000000000145519218910419842359296) }, { SC_(37), SC_(1.0000000000072759598350574810145209) }, { SC_(38), SC_(1.0000000000036379795473786511902372) }, { SC_(39), SC_(1.0000000000018189896503070659475848) }, { SC_(40), SC_(1.0000000000009094947840263889282533) }, { SC_(41), SC_(1.0000000000004547473783042154026799) }, { SC_(42), SC_(1.0000000000002273736845824652515227) }, { SC_(43), SC_(1.0000000000001136868407680227849349) }, { SC_(44), SC_(1.0000000000000568434198762758560928) }, { SC_(45), SC_(1.0000000000000284217097688930185546) }, { SC_(46), SC_(1.0000000000000142108548280316067698) }, { SC_(47), SC_(1.0000000000000071054273952108527129) }, { SC_(48), SC_(1.0000000000000035527136913371136733) }, { SC_(49), SC_(1.0000000000000017763568435791203275) }, { SC_(50), SC_(1.0000000000000008881784210930815903) }, { SC_(51), SC_(1.0000000000000004440892103143813364) }, { SC_(52), SC_(1.0000000000000002220446050798041984) }, { SC_(53), SC_(1.0000000000000001110223025141066134) }, { SC_(54), SC_(1.0000000000000000555111512484548124) }, { SC_(55), SC_(1.0000000000000000277555756213612417) }, { SC_(56), SC_(1.0000000000000000138777878097252328) }, { SC_(57), SC_(1.0000000000000000069388939045441537) }, { SC_(58), SC_(1.0000000000000000034694469521659226) }, { SC_(59), SC_(1.0000000000000000017347234760475766) }, { SC_(60), SC_(1.0000000000000000008673617380119934) }, + { 2, SC_(1.6449340668482264364724151666460252) }, { 3, SC_(1.2020569031595942853997381615114500) }, { 4, SC_(1.0823232337111381915160036965411679) }, { 5, SC_(1.0369277551433699263313654864570342) }, { 6, SC_(1.0173430619844491397145179297909205) }, { 7, SC_(1.0083492773819228268397975498497968) }, { 8, SC_(1.0040773561979443393786852385086525) }, { 9, SC_(1.0020083928260822144178527692324121) }, { SC_(10.0), SC_(1.0009945751278180853371459589003190) }, { SC_(11.0), SC_(1.0004941886041194645587022825264699) }, { SC_(12.0), SC_(1.0002460865533080482986379980477397) }, { SC_(13.0), SC_(1.0001227133475784891467518365263574) }, { SC_(14.0), SC_(1.0000612481350587048292585451051353) }, { SC_(15.0), SC_(1.0000305882363070204935517285106451) }, { SC_(16.0), SC_(1.0000152822594086518717325714876367) }, { SC_(17.0), SC_(1.0000076371976378997622736002935630) }, { SC_(18.0), SC_(1.0000038172932649998398564616446219) }, { SC_(19.0), SC_(1.0000019082127165539389256569577951) }, { SC_(20.0), SC_(1.0000009539620338727961131520386834) }, { SC_(21.0), SC_(1.0000004769329867878064631167196044) }, { SC_(22.0), SC_(1.0000002384505027277329900036481868) }, { SC_(23.0), SC_(1.0000001192199259653110730677887189) }, { SC_(24.0), SC_(1.0000000596081890512594796124402079) }, { SC_(25.0), SC_(1.0000000298035035146522801860637051) }, { SC_(26.0), SC_(1.0000000149015548283650412346585066) }, { SC_(27.0), SC_(1.0000000074507117898354294919810042) }, { SC_(28.0), SC_(1.0000000037253340247884570548192040) }, { SC_(29.0), SC_(1.0000000018626597235130490064039099) }, { SC_(30.0), SC_(1.0000000009313274324196681828717647) }, { SC_(31.0), SC_(1.0000000004656629065033784072989233) }, { SC_(32.0), SC_(1.0000000002328311833676505492001456) }, { SC_(33.0), SC_(1.0000000001164155017270051977592974) }, { SC_(34.0), SC_(1.0000000000582077208790270088924369) }, { SC_(35.0), SC_(1.0000000000291038504449709968692943) }, { SC_(36.0), SC_(1.0000000000145519218910419842359296) }, { SC_(37.0), SC_(1.0000000000072759598350574810145209) }, { SC_(38.0), SC_(1.0000000000036379795473786511902372) }, { SC_(39.0), SC_(1.0000000000018189896503070659475848) }, { SC_(40.0), SC_(1.0000000000009094947840263889282533) }, { SC_(41.0), SC_(1.0000000000004547473783042154026799) }, { SC_(42.0), SC_(1.0000000000002273736845824652515227) }, { SC_(43.0), SC_(1.0000000000001136868407680227849349) }, { SC_(44.0), SC_(1.0000000000000568434198762758560928) }, { SC_(45.0), SC_(1.0000000000000284217097688930185546) }, { SC_(46.0), SC_(1.0000000000000142108548280316067698) }, { SC_(47.0), SC_(1.0000000000000071054273952108527129) }, { SC_(48.0), SC_(1.0000000000000035527136913371136733) }, { SC_(49.0), SC_(1.0000000000000017763568435791203275) }, { SC_(50.0), SC_(1.0000000000000008881784210930815903) }, { SC_(51.0), SC_(1.0000000000000004440892103143813364) }, { SC_(52.0), SC_(1.0000000000000002220446050798041984) }, { SC_(53.0), SC_(1.0000000000000001110223025141066134) }, { SC_(54.0), SC_(1.0000000000000000555111512484548124) }, { SC_(55.0), SC_(1.0000000000000000277555756213612417) }, { SC_(56.0), SC_(1.0000000000000000138777878097252328) }, { SC_(57.0), SC_(1.0000000000000000069388939045441537) }, { SC_(58.0), SC_(1.0000000000000000034694469521659226) }, { SC_(59.0), SC_(1.0000000000000000017347234760475766) }, { SC_(60.0), SC_(1.0000000000000000008673617380119934) }, { SC_(-61), SC_(-3.3066089876577576725680214670439210e34) }, { SC_(-59), SC_(3.5666582095375556109684574608651829e32) }, { SC_(-57), SC_(-4.1147288792557978697665486067619336e30) }, { SC_(-55), SC_(5.0890659468662289689766332915911925e28) }, { SC_(-53), SC_(-6.7645882379292820990945242301798478e26) }, { SC_(-51), SC_(9.6899578874635940656497942894654088e24) }, { SC_(-49), SC_(-1.5001733492153928733711440151515152e23) }, { SC_(-47), SC_(2.5180471921451095697089023320225526e21) }, { SC_(-45), SC_(-4.5979888343656503490437943262411348e19) }, { SC_(-43), SC_(9.1677436031953307756992753623188406e17) }, { SC_(-41), SC_(-2.0040310656516252738108421663238939e16) }, { SC_(-39), SC_(4.8241448354850170371581670362158167e14) }, { SC_(-37), SC_(-1.2850850499305083333333333333333333e13) }, { SC_(-35), SC_(3.8087931125245368811553022079337869e11) }, { SC_(-33), SC_(-1.2635724795916666666666666666666667e10) }, { SC_(-31), SC_(4.7238486772162990196078431372549020e8) }, { SC_(-29), SC_(-2.0052695796688078946143462272494531e7) }, { SC_(-27), SC_(974936.82385057471264367816091954023) }, { SC_(-25), SC_(-54827.583333333333333333333333333333) }, { SC_(-23), SC_(3607.5105463980463980463980463980464) }, { SC_(-21), SC_(-281.46014492753623188405797101449275) }, { SC_(-19), SC_(26.456212121212121212121212121212121) }, { SC_(-17), SC_(-3.0539543302701197438039543302701197) }, { SC_(-15), SC_(0.44325980392156862745098039215686275) }, { SC_(-13), SC_(-0.083333333333333333333333333333333333) }, { SC_(-11), SC_(0.021092796092796092796092796092796093) }, { -9, SC_(-0.0075757575757575757575757575757575758) }, { -7, SC_(0.0041666666666666666666666666666666667) }, { -5, SC_(-0.0039682539682539682539682539682539683) }, { -3, SC_(0.0083333333333333333333333333333333333) }, { -1, SC_(-0.083333333333333333333333333333333333) } } }; do_test_zeta(integer_data, name, "Zeta: Integer arguments");