Skip to content

Commit 7a0e8e0

Browse files
committed
More casting of pow
1 parent 677f3b6 commit 7a0e8e0

12 files changed

+22
-22
lines changed

include/boost/math/special_functions/beta.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ T ibeta_series(T a, T b, T x, T s0, const Lanczos&, bool normalised, T* p_deriva
586586
if(a * b < bgh * 10)
587587
result *= exp((b - 0.5f) * boost::math::log1p(a / bgh, pol));
588588
else
589-
result *= pow(cgh / bgh, b - 0.5f);
589+
result *= pow(cgh / bgh, T(b - 0.5f));
590590
result *= pow(x * cgh / agh, a);
591591
result *= sqrt(agh / boost::math::constants::e<T>());
592592

@@ -963,14 +963,14 @@ T binomial_ccdf(T n, T k, T x, T y, const Policy& pol)
963963
int start = itrunc(n * x);
964964
if(start <= k + 1)
965965
start = itrunc(k + 2);
966-
result = static_cast<T>(pow(x, start) * pow(y, n - start) * boost::math::binomial_coefficient<T>(itrunc(n), itrunc(start), pol));
966+
result = static_cast<T>(pow(x, T(start)) * pow(y, n - T(start)) * boost::math::binomial_coefficient<T>(itrunc(n), itrunc(start), pol));
967967
if(result == 0)
968968
{
969969
// OK, starting slightly above the mode didn't work,
970970
// we'll have to sum the terms the old fashioned way:
971971
for(unsigned i = start - 1; i > k; --i)
972972
{
973-
result += static_cast<T>(pow(x, static_cast<int>(i)) * pow(y, n - i) * boost::math::binomial_coefficient<T>(itrunc(n), itrunc(i), pol));
973+
result += static_cast<T>(pow(x, static_cast<T>(i)) * pow(y, n - i) * boost::math::binomial_coefficient<T>(itrunc(n), itrunc(i), pol));
974974
}
975975
}
976976
else

include/boost/math/special_functions/chebyshev.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ inline Real chebyshev_imp(unsigned n, Real const & x, const Policy&)
5151
if (x > 1 || x < -1)
5252
{
5353
Real t = sqrt(x*x -1);
54-
return static_cast<Real>((pow(x+t, static_cast<int>(n+1)) - pow(x-t, static_cast<int>(n+1)))/(2*t));
54+
return static_cast<Real>((pow(x+t, static_cast<Real>(n+1)) - pow(x-t, static_cast<Real>(n+1)))/(2*t));
5555
}
5656
T1 = 2*x;
5757
}

include/boost/math/special_functions/detail/bessel_jy_asym.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void temme_asymptotic_y_small_x(T v, T x, T* Y, T* Y1, const Policy& pol)
175175
p /= k - v;
176176
q /= k + v;
177177
c *= c_mult / k;
178-
T c1 = pow(-x * x / 4, k) / factorial<T>(k, pol);
178+
T c1 = pow(-x * x / 4, T(k)) / factorial<T>(k, pol);
179179
g = f + g_prefix * q;
180180
h = -k * g + p;
181181
y += c * g;

include/boost/math/special_functions/detail/bessel_jy_series.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ T bessel_yn_small_z(int n, T z, T* scale, const Policy& pol)
236236
}
237237
else
238238
{
239-
auto p = static_cast<T>(pow(z / 2, n));
239+
auto p = static_cast<T>(pow(z / 2, T(n)));
240240
T result = -((boost::math::factorial<T>(n - 1, pol) / constants::pi<T>()));
241241
if(p * tools::max_value<T>() < result)
242242
{

include/boost/math/special_functions/detail/hypergeometric_1F1_bessel.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
//
185185
if ((j < cache_size - 2) && (tools::max_value<T>() / fabs(64 * bessel_cache[j] / bessel_cache[j + 1]) < fabs(bessel_cache[j])))
186186
{
187-
T rescale = static_cast<T>(pow(fabs(bessel_cache[j] / bessel_cache[j + 1]), j + 1) * 2);
187+
T rescale = static_cast<T>(pow(fabs(bessel_cache[j] / bessel_cache[j + 1]), T(j + 1)) * 2);
188188
if (!((boost::math::isfinite)(rescale)))
189189
rescale = tools::max_value<T>();
190190
for (int k = j; k < cache_size; ++k)
@@ -259,7 +259,7 @@
259259
//
260260
if ((j < cache_size - 2) && (tools::max_value<T>() / fabs(64 * bessel_cache[j] / bessel_cache[j + 1]) < fabs(bessel_cache[j])))
261261
{
262-
T rescale = static_cast<T>(pow(fabs(bessel_cache[j] / bessel_cache[j + 1]), j + 1) * 2);
262+
T rescale = static_cast<T>(pow(fabs(bessel_cache[j] / bessel_cache[j + 1]), T(j + 1)) * 2);
263263
if (!((boost::math::isfinite)(rescale)))
264264
rescale = tools::max_value<T>();
265265
for (int k = j; k < cache_size; ++k)
@@ -558,7 +558,7 @@
558558
//
559559
if((j < cache_size - 2) && (bessel_i_cache[j + 1] != 0) && (tools::max_value<T>() / fabs(64 * bessel_i_cache[j] / bessel_i_cache[j + 1]) < fabs(bessel_i_cache[j])))
560560
{
561-
T rescale = static_cast<T>(pow(fabs(bessel_i_cache[j] / bessel_i_cache[j + 1]), j + 1) * 2);
561+
T rescale = static_cast<T>(pow(fabs(bessel_i_cache[j] / bessel_i_cache[j + 1]), T(j + 1)) * 2);
562562
if (rescale > tools::max_value<T>())
563563
rescale = tools::max_value<T>();
564564
for (int k = j; k < cache_size; ++k)
@@ -591,7 +591,7 @@
591591
std::uintmax_t max_iter = boost::math::policies::get_max_series_iterations<Policy>();
592592
T result = boost::math::tools::sum_series(s, boost::math::policies::get_epsilon<T, Policy>(), max_iter);
593593
boost::math::policies::check_series_iterations<T>("boost::math::hypergeometric_1F1_AS_13_3_6<%1%>(%1%,%1%,%1%)", max_iter, pol);
594-
result *= boost::math::tgamma(b_minus_a - 0.5f, pol) * pow(z / 4, -b_minus_a + 0.5f);
594+
result *= boost::math::tgamma(b_minus_a - 0.5f, pol) * pow(z / 4, -b_minus_a + T(0.5f));
595595
long long scale = lltrunc(z / 2);
596596
log_scaling += scale;
597597
log_scaling += s.scaling();

include/boost/math/special_functions/detail/hypergeometric_pFq_checked_series.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
return std::make_pair(r, r);
147147
}
148148
std::pair<Real, Real> r = hypergeometric_pFq_checked_series_impl(aj, bj, Real(1 / z), pol, termination, log_scale);
149-
Real mul = pow(-z, -*aj.begin());
149+
Real mul = pow(-z, Real(-*aj.begin()));
150150
r.first *= mul;
151151
r.second *= mul;
152152
return r;

include/boost/math/special_functions/detail/polygamma.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace boost { namespace math { namespace detail{
5353
if(n == 1) return 1 / x;
5454
T nlx = n * log(x);
5555
if((nlx < tools::log_max_value<T>()) && (n < (int)max_factorial<T>::value))
56-
return ((n & 1) ? 1 : -1) * boost::math::factorial<T>(n - 1, pol) * static_cast<T>(pow(x, -n));
56+
return ((n & 1) ? 1 : -1) * boost::math::factorial<T>(n - 1, pol) * static_cast<T>(pow(x, T(-n)));
5757
else
5858
return ((n & 1) ? 1 : -1) * exp(boost::math::lgamma(T(n), pol) - n * log(x));
5959
}
@@ -80,7 +80,7 @@ namespace boost { namespace math { namespace detail{
8080
// know that we have to use logs for the initial terms:
8181
//
8282
part_term = ((n > (int)boost::math::max_factorial<T>::value) && (T(n) * n > tools::log_max_value<T>()))
83-
? T(0) : static_cast<T>(boost::math::factorial<T>(n - 1, pol) * pow(x, -n - 1));
83+
? T(0) : static_cast<T>(boost::math::factorial<T>(n - 1, pol) * pow(x, T(-n - 1)));
8484
if(part_term == 0)
8585
{
8686
// Either n is very large, or the power term underflows,
@@ -159,7 +159,7 @@ namespace boost { namespace math { namespace detail{
159159
{
160160
for(int k = 1; k <= iter; ++k)
161161
{
162-
z_plus_k_pow_minus_m_minus_one = static_cast<T>(pow(z, minus_m_minus_one));
162+
z_plus_k_pow_minus_m_minus_one = static_cast<T>(pow(z, T(minus_m_minus_one)));
163163
sum0 += z_plus_k_pow_minus_m_minus_one;
164164
z += 1;
165165
}
@@ -203,7 +203,7 @@ namespace boost { namespace math { namespace detail{
203203
// be n! / z^(n+1), but since we're scaling by n! it's just
204204
// 1 / z^(n+1) for now:
205205
//
206-
T prefix = static_cast<T>(pow(x, n + 1)); // Warning supression: Integer power returns at least a double
206+
T prefix = static_cast<T>(pow(x, T(n + 1))); // Warning supression: Integer power returns at least a double
207207
if(prefix == 0)
208208
return boost::math::policies::raise_overflow_error<T>(function, nullptr, pol);
209209
prefix = 1 / prefix;

include/boost/math/special_functions/hypergeometric_2F0.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ namespace boost { namespace math { namespace detail {
9494
// http://functions.wolfram.com/07.31.03.0083.01
9595
int n = static_cast<int>(static_cast<std::uintmax_t>(boost::math::lltrunc(-2 * a1)));
9696
T smz = sqrt(-z);
97-
return static_cast<T>(pow(2 / smz, -n) * boost::math::hermite(n, 1 / smz, pol)); // Warning suppression: integer power returns at least a double
97+
return static_cast<T>(pow(2 / smz, T(-n)) * boost::math::hermite(n, 1 / smz, pol)); // Warning suppression: integer power returns at least a double
9898
}
9999

100100
if (is_a1_integer && is_a2_integer)

include/boost/math/special_functions/lambert_w.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ struct lambert_w0_small_z_series_term
835835
++k;
836836
term *= -z / k;
837837
//T t = pow(z, k) * pow(T(k), -1 + k) / factorial<T>(k); // (z^k * k(k-1)^k) / k!
838-
T result = term * pow(T(k), -1 + k); // term * k^(k-1)
838+
T result = term * pow(T(k), T(-1 + k)); // term * k^(k-1)
839839
// std::cout << " k = " << k << ", term = " << term << ", result = " << result << std::endl;
840840
return result; //
841841
}

include/boost/math/special_functions/owens_t.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ namespace boost
588588
}
589589
#endif
590590
n = (std::min)(n, 1500);
591-
T d = pow(3 + sqrt(T(8)), n);
591+
T d = pow(3 + sqrt(T(8)), T(n));
592592
d = (d + 1 / d) / 2;
593593
T b = -1;
594594
T c = -d;
@@ -706,7 +706,7 @@ namespace boost
706706
}
707707
#endif
708708
n = (std::min)(n, 1500);
709-
RealType d = pow(3 + sqrt(RealType(8)), n);
709+
RealType d = pow(3 + sqrt(RealType(8)), RealType(n));
710710
d = (d + 1 / d) / 2;
711711
RealType b = -1;
712712
RealType c = -d;

include/boost/math/special_functions/zeta.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -956,9 +956,9 @@ T zeta_imp(T s, T sc, const Policy& pol, const Tag& tag)
956956
else if((v & 1) == 0)
957957
{
958958
if(((v / 2) <= (int)boost::math::max_bernoulli_b2n<T>::value) && (v <= (int)boost::math::max_factorial<T>::value))
959-
return T(((v / 2 - 1) & 1) ? -1 : 1) * ldexp(T(1), v - 1) * static_cast<T>(pow(constants::pi<T, Policy>(), v)) *
959+
return T(((v / 2 - 1) & 1) ? -1 : 1) * ldexp(T(1), v - 1) * static_cast<T>(pow(constants::pi<T, Policy>(), T(v))) *
960960
boost::math::unchecked_bernoulli_b2n<T>(v / 2) / boost::math::unchecked_factorial<T>(v);
961-
return T(((v / 2 - 1) & 1) ? -1 : 1) * ldexp(T(1), v - 1) * static_cast<T>(pow(constants::pi<T, Policy>(), v)) *
961+
return T(((v / 2 - 1) & 1) ? -1 : 1) * ldexp(T(1), v - 1) * static_cast<T>(pow(constants::pi<T, Policy>(), T(v))) *
962962
boost::math::bernoulli_b2n<T>(v / 2) / boost::math::factorial<T>(v, pol);
963963
}
964964
else

include/boost/math/tools/series.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ inline typename Functor::result_type kahan_sum_series(Functor& func, int bits) n
131131

132132
typedef typename Functor::result_type result_type;
133133

134-
result_type factor = pow(result_type(2), bits);
134+
result_type factor = pow(result_type(2), result_type(bits));
135135
result_type result = func();
136136
result_type next_term, y, t;
137137
result_type carry = 0;

0 commit comments

Comments
 (0)