summaryrefslogtreecommitdiff
path: root/boost/math/special_functions/zeta.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:33:54 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:36:09 +0900
commitd9ec475d945d3035377a0d89ed42e382d8988891 (patch)
tree34aff2cee4b209906243ab5499d61f3edee2982f /boost/math/special_functions/zeta.hpp
parent71d216b90256936a9638f325af9bc69d720e75de (diff)
downloadboost-d9ec475d945d3035377a0d89ed42e382d8988891.tar.gz
boost-d9ec475d945d3035377a0d89ed42e382d8988891.tar.bz2
boost-d9ec475d945d3035377a0d89ed42e382d8988891.zip
Imported Upstream version 1.60.0
Change-Id: Ie709530d6d5841088ceaba025cbe175a4ef43050 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/math/special_functions/zeta.hpp')
-rw-r--r--boost/math/special_functions/zeta.hpp182
1 files changed, 94 insertions, 88 deletions
diff --git a/boost/math/special_functions/zeta.hpp b/boost/math/special_functions/zeta.hpp
index 1ba282f4d1..616bb0cccc 100644
--- a/boost/math/special_functions/zeta.hpp
+++ b/boost/math/special_functions/zeta.hpp
@@ -200,20 +200,20 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const mpl::int_<53>&)
// Expected Error Term: -2.020e-18
// Max error found at double precision: 3.994987e-17
static const T P[6] = {
- 0.24339294433593750202L,
- -0.49092470516353571651L,
- 0.0557616214776046784287L,
- -0.00320912498879085894856L,
- 0.000451534528645796438704L,
- -0.933241270357061460782e-5L,
+ static_cast<T>(0.24339294433593750202L),
+ static_cast<T>(-0.49092470516353571651L),
+ static_cast<T>(0.0557616214776046784287L),
+ static_cast<T>(-0.00320912498879085894856L),
+ static_cast<T>(0.000451534528645796438704L),
+ static_cast<T>(-0.933241270357061460782e-5L),
};
static const T Q[6] = {
- 1L,
- -0.279960334310344432495L,
- 0.0419676223309986037706L,
- -0.00413421406552171059003L,
- 0.00024978985622317935355L,
- -0.101855788418564031874e-4L,
+ static_cast<T>(1L),
+ static_cast<T>(-0.279960334310344432495L),
+ static_cast<T>(0.0419676223309986037706L),
+ static_cast<T>(-0.00413421406552171059003L),
+ static_cast<T>(0.00024978985622317935355L),
+ static_cast<T>(-0.101855788418564031874e-4L),
};
result = tools::evaluate_polynomial(P, sc) / tools::evaluate_polynomial(Q, sc);
result -= 1.2433929443359375F;
@@ -225,20 +225,20 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const mpl::int_<53>&)
// Maximum Deviation Found: 9.007e-20
// Expected Error Term: 9.007e-20
static const T P[6] = {
- 0.577215664901532860516,
- 0.243210646940107164097,
- 0.0417364673988216497593,
- 0.00390252087072843288378,
- 0.000249606367151877175456,
- 0.110108440976732897969e-4,
+ static_cast<T>(0.577215664901532860516L),
+ static_cast<T>(0.243210646940107164097L),
+ static_cast<T>(0.0417364673988216497593L),
+ static_cast<T>(0.00390252087072843288378L),
+ static_cast<T>(0.000249606367151877175456L),
+ static_cast<T>(0.110108440976732897969e-4L),
};
static const T Q[6] = {
- 1,
- 0.295201277126631761737,
- 0.043460910607305495864,
- 0.00434930582085826330659,
- 0.000255784226140488490982,
- 0.10991819782396112081e-4,
+ static_cast<T>(1.0),
+ static_cast<T>(0.295201277126631761737L),
+ static_cast<T>(0.043460910607305495864L),
+ static_cast<T>(0.00434930582085826330659L),
+ static_cast<T>(0.000255784226140488490982L),
+ static_cast<T>(0.10991819782396112081e-4L),
};
result = tools::evaluate_polynomial(P, T(-sc)) / tools::evaluate_polynomial(Q, T(-sc));
result += 1 / (-sc);
@@ -249,21 +249,21 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const mpl::int_<53>&)
// Expected Error Term: -5.946e-22
static const float Y = 0.6986598968505859375;
static const T P[6] = {
- -0.0537258300023595030676,
- 0.0445163473292365591906,
- 0.0128677673534519952905,
- 0.00097541770457391752726,
- 0.769875101573654070925e-4,
- 0.328032510000383084155e-5,
+ static_cast<T>(-0.0537258300023595030676L),
+ static_cast<T>(0.0445163473292365591906L),
+ static_cast<T>(0.0128677673534519952905L),
+ static_cast<T>(0.00097541770457391752726L),
+ static_cast<T>(0.769875101573654070925e-4L),
+ static_cast<T>(0.328032510000383084155e-5L),
};
static const T Q[7] = {
- 1,
- 0.33383194553034051422,
- 0.0487798431291407621462,
- 0.00479039708573558490716,
- 0.000270776703956336357707,
- 0.106951867532057341359e-4,
- 0.236276623974978646399e-7,
+ 1.0f,
+ static_cast<T>(0.33383194553034051422L),
+ static_cast<T>(0.0487798431291407621462L),
+ static_cast<T>(0.00479039708573558490716L),
+ static_cast<T>(0.000270776703956336357707L),
+ static_cast<T>(0.106951867532057341359e-4L),
+ static_cast<T>(0.236276623974978646399e-7L),
};
result = tools::evaluate_polynomial(P, T(s - 2)) / tools::evaluate_polynomial(Q, T(s - 2));
result += Y + 1 / (-sc);
@@ -275,23 +275,23 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const mpl::int_<53>&)
// Max error found at double precision: 2.009135e-16
static const T P[6] = {
- -2.49710190602259410021,
- -2.60013301809475665334,
- -0.939260435377109939261,
- -0.138448617995741530935,
- -0.00701721240549802377623,
- -0.229257310594893932383e-4,
+ static_cast<T>(-2.49710190602259410021L),
+ static_cast<T>(-2.60013301809475665334L),
+ static_cast<T>(-0.939260435377109939261L),
+ static_cast<T>(-0.138448617995741530935L),
+ static_cast<T>(-0.00701721240549802377623L),
+ static_cast<T>(-0.229257310594893932383e-4L),
};
static const T Q[9] = {
- 1,
- 0.706039025937745133628,
- 0.15739599649558626358,
- 0.0106117950976845084417,
- -0.36910273311764618902e-4,
- 0.493409563927590008943e-5,
- -0.234055487025287216506e-6,
- 0.718833729365459760664e-8,
- -0.1129200113474947419e-9,
+ 1.0f,
+ static_cast<T>(0.706039025937745133628L),
+ static_cast<T>(0.15739599649558626358L),
+ static_cast<T>(0.0106117950976845084417L),
+ static_cast<T>(-0.36910273311764618902e-4L),
+ static_cast<T>(0.493409563927590008943e-5L),
+ static_cast<T>(-0.234055487025287216506e-6L),
+ static_cast<T>(0.718833729365459760664e-8L),
+ static_cast<T>(-0.1129200113474947419e-9L),
};
result = tools::evaluate_polynomial(P, T(s - 4)) / tools::evaluate_polynomial(Q, T(s - 4));
result = 1 + exp(result);
@@ -302,24 +302,24 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const mpl::int_<53>&)
// Expected Error Term: 7.117e-16
// Max error found at double precision: 9.387771e-16
static const T P[7] = {
- -4.78558028495135619286,
- -1.89197364881972536382,
- -0.211407134874412820099,
- -0.000189204758260076688518,
- 0.00115140923889178742086,
- 0.639949204213164496988e-4,
- 0.139348932445324888343e-5,
+ static_cast<T>(-4.78558028495135619286L),
+ static_cast<T>(-1.89197364881972536382L),
+ static_cast<T>(-0.211407134874412820099L),
+ static_cast<T>(-0.000189204758260076688518L),
+ static_cast<T>(0.00115140923889178742086L),
+ static_cast<T>(0.639949204213164496988e-4L),
+ static_cast<T>(0.139348932445324888343e-5L),
};
static const T Q[9] = {
- 1,
- 0.244345337378188557777,
- 0.00873370754492288653669,
- -0.00117592765334434471562,
- -0.743743682899933180415e-4,
- -0.21750464515767984778e-5,
- 0.471001264003076486547e-8,
- -0.833378440625385520576e-10,
- 0.699841545204845636531e-12,
+ 1.0f,
+ static_cast<T>(0.244345337378188557777L),
+ static_cast<T>(0.00873370754492288653669L),
+ static_cast<T>(-0.00117592765334434471562L),
+ static_cast<T>(-0.743743682899933180415e-4L),
+ static_cast<T>(-0.21750464515767984778e-5L),
+ static_cast<T>(0.471001264003076486547e-8L),
+ static_cast<T>(-0.833378440625385520576e-10L),
+ static_cast<T>(0.699841545204845636531e-12L),
};
result = tools::evaluate_polynomial(P, T(s - 7)) / tools::evaluate_polynomial(Q, T(s - 7));
result = 1 + exp(result);
@@ -329,24 +329,24 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const mpl::int_<53>&)
// Max error in interpolated form: 1.668e-17
// Max error found at long double precision: 1.669714e-17
static const T P[8] = {
- -10.3948950573308896825,
- -2.85827219671106697179,
- -0.347728266539245787271,
- -0.0251156064655346341766,
- -0.00119459173416968685689,
- -0.382529323507967522614e-4,
- -0.785523633796723466968e-6,
- -0.821465709095465524192e-8,
+ static_cast<T>(-10.3948950573308896825L),
+ static_cast<T>(-2.85827219671106697179L),
+ static_cast<T>(-0.347728266539245787271L),
+ static_cast<T>(-0.0251156064655346341766L),
+ static_cast<T>(-0.00119459173416968685689L),
+ static_cast<T>(-0.382529323507967522614e-4L),
+ static_cast<T>(-0.785523633796723466968e-6L),
+ static_cast<T>(-0.821465709095465524192e-8L),
};
static const T Q[10] = {
- 1,
- 0.208196333572671890965,
- 0.0195687657317205033485,
- 0.00111079638102485921877,
- 0.408507746266039256231e-4,
- 0.955561123065693483991e-6,
- 0.118507153474022900583e-7,
- 0.222609483627352615142e-14,
+ 1.0f,
+ static_cast<T>(0.208196333572671890965L),
+ static_cast<T>(0.0195687657317205033485L),
+ static_cast<T>(0.00111079638102485921877L),
+ static_cast<T>(0.408507746266039256231e-4L),
+ static_cast<T>(0.955561123065693483991e-6L),
+ static_cast<T>(0.118507153474022900583e-7L),
+ static_cast<T>(0.222609483627352615142e-14L),
};
result = tools::evaluate_polynomial(P, T(s - 15)) / tools::evaluate_polynomial(Q, T(s - 15));
result = 1 + exp(result);
@@ -883,14 +883,14 @@ T zeta_imp_odd_integer(int s, const T& sc, const Policy& pol, const mpl::false_&
if(!is_init)
{
is_init = true;
- for(int k = 0; k < sizeof(results) / sizeof(results[0]); ++k)
+ for(unsigned k = 0; k < sizeof(results) / sizeof(results[0]); ++k)
{
T arg = k * 2 + 3;
T c_arg = 1 - arg;
results[k] = zeta_polynomial_series(arg, c_arg, pol);
}
}
- int index = (s - 3) / 2;
+ unsigned index = (s - 3) / 2;
return index >= sizeof(results) / sizeof(results[0]) ? zeta_polynomial_series(T(s), sc, pol): results[index];
}
@@ -915,8 +915,12 @@ T zeta_imp(T s, T sc, const Policy& pol, const Tag& tag)
//
if(floor(s) == s)
{
+#ifndef BOOST_NO_EXCEPTIONS
+ // Without exceptions we expect itrunc to return INT_MAX on overflow
+ // and we fall through anyway.
try
{
+#endif
int v = itrunc(s);
if(v == s)
{
@@ -925,12 +929,12 @@ T zeta_imp(T s, T sc, const Policy& pol, const Tag& tag)
if(((-v) & 1) == 0)
return 0;
int n = (-v + 1) / 2;
- if(n <= boost::math::max_bernoulli_b2n<T>::value)
+ if(n <= (int)boost::math::max_bernoulli_b2n<T>::value)
return T((-v & 1) ? -1 : 1) * boost::math::unchecked_bernoulli_b2n<T>(n) / (1 - v);
}
else if((v & 1) == 0)
{
- if(((v / 2) <= boost::math::max_bernoulli_b2n<T>::value) && (v <= boost::math::max_factorial<T>::value))
+ if(((v / 2) <= (int)boost::math::max_bernoulli_b2n<T>::value) && (v <= (int)boost::math::max_factorial<T>::value))
return T(((v / 2 - 1) & 1) ? -1 : 1) * ldexp(T(1), v - 1) * pow(constants::pi<T, Policy>(), v) *
boost::math::unchecked_bernoulli_b2n<T>(v / 2) / boost::math::unchecked_factorial<T>(v);
return T(((v / 2 - 1) & 1) ? -1 : 1) * ldexp(T(1), v - 1) * pow(constants::pi<T, Policy>(), v) *
@@ -939,9 +943,11 @@ T zeta_imp(T s, T sc, const Policy& pol, const Tag& tag)
else
return zeta_imp_odd_integer(v, sc, pol, mpl::bool_<(Tag::value <= 113) && Tag::value>());
}
+#ifndef BOOST_NO_EXCEPTIONS
}
catch(const boost::math::rounding_error&){} // Just fall through, s is too large to round
catch(const std::overflow_error&){}
+#endif
}
if(fabs(s) < tools::root_epsilon<T>())