mirror of
https://github.com/boostorg/math.git
synced 2026-02-22 03:22:28 +00:00
Fix case where b is a negative integer and z is also negative. (#983)
* Fix case where b is a negative integer and z is also negative. Add tests etc. Fixes: https://github.com/boostorg/math/issues/982.
This commit is contained in:
@@ -460,13 +460,28 @@ namespace boost { namespace math { namespace detail {
|
||||
return hypergeometric_1F1_checked_series_impl(a, b, z, pol, log_scaling);
|
||||
}
|
||||
}
|
||||
// Let's otherwise make z positive (almost always)
|
||||
// by Kummer's transformation
|
||||
// (we also don't transform if z belongs to [-1,0])
|
||||
long long scaling = lltrunc(z);
|
||||
T r = exp(z - scaling) * detail::hypergeometric_1F1_imp<T>(b_minus_a, b, -z, pol, log_scaling);
|
||||
log_scaling += scaling;
|
||||
return r;
|
||||
if ((b < 0) && (floor(b) == b))
|
||||
{
|
||||
// Negative integer b, so a must be a negative integer too.
|
||||
// Kummer's transformation fails here!
|
||||
if(a > -50)
|
||||
return detail::hypergeometric_1F1_generic_series(a, b, z, pol, log_scaling, function);
|
||||
// Is there anything better than this??
|
||||
return hypergeometric_1F1_imp(a, float_next(b), z, pol, log_scaling);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Let's otherwise make z positive (almost always)
|
||||
// by Kummer's transformation
|
||||
// (we also don't transform if z belongs to [-1,0])
|
||||
// Also note that Kummer's transformation fails when b is
|
||||
// a negative integer, although this seems to be unmentioned
|
||||
// in the literature...
|
||||
long long scaling = lltrunc(z);
|
||||
T r = exp(z - scaling) * detail::hypergeometric_1F1_imp<T>(b_minus_a, b, -z, pol, log_scaling);
|
||||
log_scaling += scaling;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Check for initial divergence:
|
||||
|
||||
Reference in New Issue
Block a user