Skip to content

Commit

Permalink
Merge pull request #8 from mckib2/add-beta-underflow-patch
Browse files Browse the repository at this point in the history
FIX: add upstream beta underflow patch
  • Loading branch information
mckib2 authored Jul 16, 2022
2 parents 2a1a7e9 + 7e860b2 commit 3af99e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion boost/math/special_functions/beta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ T ibeta_power_terms(T a,
else
{
T p1 = pow(b1, a / b);
T l3 = (log(p1) + log(b2)) * b;
T l3 = (p1 != 0) && (b2 != 0) ? (log(p1) + log(b2)) * b : tools::max_value<T>(); // arbitrary large value if the logs would fail!
if((l3 < tools::log_max_value<T>())
&& (l3 > tools::log_min_value<T>()))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/boost/math/special_functions/beta.hpp b/include/boost/math/special_functions/beta.hpp
index 87e8950dc..f74937c1a 100644
--- a/boost/math/special_functions/beta.hpp
+++ b/boost/math/special_functions/beta.hpp
@@ -390,7 +390,7 @@ T ibeta_power_terms(T a,
else
{
T p1 = pow(b1, a / b);
- T l3 = (log(p1) + log(b2)) * b;
+ T l3 = (p1 != 0) && (b2 != 0) ? (log(p1) + log(b2)) * b : tools::max_value<T>(); // arbitrary large value if the logs would fail!
if((l3 < tools::log_max_value<T>())
&& (l3 > tools::log_min_value<T>()))
{

0 comments on commit 3af99e6

Please sign in to comment.