Skip to content

Commit fb0af63

Browse files
authored
update beta error messages and checks (#1003)
1 parent 281f491 commit fb0af63

File tree

1 file changed

+6
-11
lines changed
  • include/boost/math/special_functions

1 file changed

+6
-11
lines changed

include/boost/math/special_functions/beta.hpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,18 +1021,15 @@ T ibeta_imp(T a, T b, T x, const Policy& pol, bool inv, bool normalised, T* p_de
10211021
BOOST_MATH_ASSERT((p_derivative == 0) || normalised);
10221022

10231023
if(!(boost::math::isfinite)(a))
1024-
return policies::raise_domain_error<T>(function, "The argument a to the incomplete beta function must be >= zero (got a=%1%).", a, pol);
1024+
return policies::raise_domain_error<T>(function, "The argument a to the incomplete beta function must be finite (got a=%1%).", a, pol);
10251025
if(!(boost::math::isfinite)(b))
1026-
return policies::raise_domain_error<T>(function, "The argument b to the incomplete beta function must be >= zero (got b=%1%).", b, pol);
1027-
if(!(boost::math::isfinite)(x))
1026+
return policies::raise_domain_error<T>(function, "The argument b to the incomplete beta function must be finite (got b=%1%).", b, pol);
1027+
if (!(0 <= x && x <= 1))
10281028
return policies::raise_domain_error<T>(function, "The argument x to the incomplete beta function must be in [0,1] (got x=%1%).", x, pol);
10291029

10301030
if(p_derivative)
10311031
*p_derivative = -1; // value not set.
10321032

1033-
if((x < 0) || (x > 1))
1034-
return policies::raise_domain_error<T>(function, "Parameter x outside the range [0,1] in the incomplete beta function (got x=%1%).", x, pol);
1035-
10361033
if(normalised)
10371034
{
10381035
if(a < 0)
@@ -1422,18 +1419,16 @@ T ibeta_derivative_imp(T a, T b, T x, const Policy& pol)
14221419
// start with the usual error checks:
14231420
//
14241421
if (!(boost::math::isfinite)(a))
1425-
return policies::raise_domain_error<T>(function, "The argument a to the incomplete beta function must be >= zero (got a=%1%).", a, pol);
1422+
return policies::raise_domain_error<T>(function, "The argument a to the incomplete beta function must be finite (got a=%1%).", a, pol);
14261423
if (!(boost::math::isfinite)(b))
1427-
return policies::raise_domain_error<T>(function, "The argument b to the incomplete beta function must be >= zero (got b=%1%).", b, pol);
1428-
if (!(boost::math::isfinite)(x))
1424+
return policies::raise_domain_error<T>(function, "The argument b to the incomplete beta function must be finite (got b=%1%).", b, pol);
1425+
if (!(0 <= x && x <= 1))
14291426
return policies::raise_domain_error<T>(function, "The argument x to the incomplete beta function must be in [0,1] (got x=%1%).", x, pol);
14301427

14311428
if(a <= 0)
14321429
return policies::raise_domain_error<T>(function, "The argument a to the incomplete beta function must be greater than zero (got a=%1%).", a, pol);
14331430
if(b <= 0)
14341431
return policies::raise_domain_error<T>(function, "The argument b to the incomplete beta function must be greater than zero (got b=%1%).", b, pol);
1435-
if((x < 0) || (x > 1))
1436-
return policies::raise_domain_error<T>(function, "Parameter x outside the range [0,1] in the incomplete beta function (got x=%1%).", x, pol);
14371432
//
14381433
// Now the corner cases:
14391434
//

0 commit comments

Comments
 (0)