mirror of
https://github.com/boostorg/math.git
synced 2026-01-29 07:42:11 +00:00
Fix initialization of power series so that we don't get a spurious overflow error from tgamma when the result is actually zero.
[SVN r86415]
This commit is contained in:
@@ -48,7 +48,13 @@ struct sph_bessel_j_small_z_series_term
|
||||
{
|
||||
BOOST_MATH_STD_USING
|
||||
mult = x / 2;
|
||||
term = pow(mult, T(v)) / boost::math::tgamma(v+1+T(0.5f), Policy());
|
||||
if(v + 3 > max_factorial<T>::value)
|
||||
{
|
||||
term = v * log(mult) - boost::math::lgamma(v+1+T(0.5f), Policy());
|
||||
term = exp(term);
|
||||
}
|
||||
else
|
||||
term = pow(mult, T(v)) / boost::math::tgamma(v+1+T(0.5f), Policy());
|
||||
mult *= -mult;
|
||||
}
|
||||
T operator()()
|
||||
@@ -142,6 +148,11 @@ inline T sph_bessel_j_imp(unsigned n, T x, const Policy& pol)
|
||||
if(n == 0)
|
||||
return boost::math::sinc_pi(x, pol);
|
||||
//
|
||||
// Special case for x == 0:
|
||||
//
|
||||
if(x == 0)
|
||||
return 0;
|
||||
//
|
||||
// When x is small we may end up with 0/0, use series evaluation
|
||||
// instead, especially as it converges rapidly:
|
||||
//
|
||||
@@ -752,3 +763,4 @@ inline OutputIterator cyl_neumann_zero(T v,
|
||||
|
||||
#endif // BOOST_MATH_BESSEL_HPP
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user