Remove duplicated error handling from ellint_rj.

This commit is contained in:
jzmaddock 2025-04-21 09:41:53 +01:00
parent 6113e186e2
commit 56f56115f9
2 changed files with 8 additions and 22 deletions

View File

@ -77,28 +77,6 @@ BOOST_MATH_GPU_ENABLED T ellint_rj_imp_final(T x, T y, T z, T p, const Policy& p
BOOST_MATH_STD_USING
constexpr auto function = "boost::math::ellint_rj<%1%>(%1%,%1%,%1%)";
if(x < 0)
{
return policies::raise_domain_error<T>(function, "Argument x must be non-negative, but got x = %1%", x, pol);
}
if(y < 0)
{
return policies::raise_domain_error<T>(function, "Argument y must be non-negative, but got y = %1%", y, pol);
}
if(z < 0)
{
return policies::raise_domain_error<T>(function, "Argument z must be non-negative, but got z = %1%", z, pol);
}
if(p == 0)
{
return policies::raise_domain_error<T>(function, "Argument p must not be zero, but got p = %1%", p, pol);
}
if(x + y == 0 || y + z == 0 || z + x == 0)
{
return policies::raise_domain_error<T>(function, "At most one argument can be zero, only possible result is %1%.", boost::math::numeric_limits<T>::quiet_NaN(), pol);
}
//
// Special cases from http://dlmf.nist.gov/19.20#iii
//

View File

@ -232,4 +232,12 @@ void test_spots(T, const char* type_name)
BOOST_MATH_CHECK_THROW(boost::math::ellint_3(T(1), T(-0.5), T(-2)), std::domain_error);
BOOST_MATH_CHECK_THROW(boost::math::ellint_3(T(0.5), T(1.2)), std::domain_error);
BOOST_MATH_CHECK_THROW(boost::math::ellint_3(T(1.5), T(0.5)), std::domain_error);
// Special case for ellint_rj and full coverage:
BOOST_MATH_CHECK_THROW(boost::math::ellint_rj(T(-0.5), T(0.5), T(0.5), T(0.5)), std::domain_error);
BOOST_MATH_CHECK_THROW(boost::math::ellint_rj(T(0.5), T(-0.5), T(0.5), T(0.5)), std::domain_error);
BOOST_MATH_CHECK_THROW(boost::math::ellint_rj(T(0.5), T(0.5), T(-0.5), T(0.5)), std::domain_error);
BOOST_MATH_CHECK_THROW(boost::math::ellint_rj(T(0.5), T(0.5), T(0.5), T(0.)), std::domain_error);
BOOST_MATH_CHECK_THROW(boost::math::ellint_rj(T(0.0), T(0.0), T(0.5), T(0.5)), std::domain_error);
BOOST_MATH_CHECK_THROW(boost::math::ellint_rj(T(0.0), T(0.5), T(0.0), T(0.5)), std::domain_error);
BOOST_MATH_CHECK_THROW(boost::math::ellint_rj(T(0.5), T(0.0), T(0.0), T(0.5)), std::domain_error);
}