Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@
}
else
{
e = z > static_cast<T>((std::numeric_limits<long long>::max)()) ? (std::numeric_limits<long long>::max)() : lltrunc(z, pol);
e = z >= static_cast<T>((std::numeric_limits<long long>::max)()) ? (std::numeric_limits<long long>::max)() : lltrunc(z, pol);
log_scaling += e;
if (z - e > tools::log_max_value<T>())
return policies::raise_overflow_error<T, Policy>(function, nullptr, pol);
prefix = exp(z - e);
}
if ((fabs(a) < 10) && (fabs(b) < 10))
Expand Down
3 changes: 2 additions & 1 deletion include/boost/math/special_functions/hypergeometric_1F1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <boost/math/tools/config.hpp>
#include <boost/math/policies/policy.hpp>
#include <boost/math/policies/error_handling.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
#include <boost/math/special_functions/detail/hypergeometric_series.hpp>
#include <boost/math/special_functions/detail/hypergeometric_asym.hpp>
#include <boost/math/special_functions/detail/hypergeometric_rational.hpp>
Expand Down Expand Up @@ -637,7 +638,7 @@ namespace boost { namespace math { namespace detail {
static const thread_local long long max_scaling = lltrunc(boost::math::tools::log_max_value<T>()) - 2;
static const thread_local T max_scale_factor = exp(T(max_scaling));

while (log_scaling > max_scaling)
while (!(boost::math::isinf)(result) && (log_scaling > max_scaling))
{
result *= max_scale_factor;
log_scaling -= max_scaling;
Expand Down
7 changes: 7 additions & 0 deletions test/test_1F1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,13 @@ void test_spots6(T, const char* type_name)
T val = boost::math::hypergeometric_1F1(hypergeometric_1F1_big_bugs[i][0], hypergeometric_1F1_big_bugs[i][1], hypergeometric_1F1_big_bugs[i][2]);
BOOST_CHECK((boost::math::isinf)(val));
}
// https://github.com/boostorg/math/issues/1288
BOOST_CHECK_EQUAL(boost::math::hypergeometric_1F1(SC_(2.0), SC_(3.0), SC_(1e30)),
(std::numeric_limits<double>::infinity)());
// This is the largest log_hypergeometric_1F1 we can currently compute, beyond this the fix for the above
// bug causes premature overflow. However, there is no easy fix and Wolfram also fails in this case. It's **hard** :(
BOOST_CHECK_CLOSE_FRACTION(boost::math::log_hypergeometric_1F1(SC_(2.0), SC_(3.0), static_cast<T>((std::numeric_limits<std::int64_t>::max)())),
SC_(9223372036854775765.02487480528339082), boost::math::tools::epsilon<T>() * 10);
}
}

Expand Down
Loading