summaryrefslogtreecommitdiff
path: root/boost/math/special_functions/ellint_1.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/math/special_functions/ellint_1.hpp')
-rw-r--r--boost/math/special_functions/ellint_1.hpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/boost/math/special_functions/ellint_1.hpp b/boost/math/special_functions/ellint_1.hpp
index d1d9d72e30..334c0ad808 100644
--- a/boost/math/special_functions/ellint_1.hpp
+++ b/boost/math/special_functions/ellint_1.hpp
@@ -51,12 +51,6 @@ T ellint_f_imp(T phi, T k, const Policy& pol)
BOOST_MATH_INSTRUMENT_VARIABLE(k);
BOOST_MATH_INSTRUMENT_VARIABLE(function);
- if (abs(k) > 1)
- {
- return policies::raise_domain_error<T>(function,
- "Got k = %1%, function requires |k| <= 1", k, pol);
- }
-
bool invert = false;
if(phi < 0)
{
@@ -104,18 +98,24 @@ T ellint_f_imp(T phi, T k, const Policy& pol)
}
T sinp = sin(rphi);
sinp *= sinp;
+ if (sinp * k * k >= 1)
+ {
+ return policies::raise_domain_error<T>(function,
+ "Got k^2 * sin^2(phi) = %1%, but the function requires this < 1", sinp * k * k, pol);
+ }
T cosp = cos(rphi);
cosp *= cosp;
BOOST_MATH_INSTRUMENT_VARIABLE(sinp);
BOOST_MATH_INSTRUMENT_VARIABLE(cosp);
if(sinp > tools::min_value<T>())
{
+ BOOST_ASSERT(rphi != 0); // precondition, can't be true if sin(rphi) != 0.
//
// Use http://dlmf.nist.gov/19.25#E5, note that
// c-1 simplifies to cot^2(rphi) which avoid cancellation:
//
T c = 1 / sinp;
- result = rphi == 0 ? static_cast<T>(0) : static_cast<T>(s * ellint_rf_imp(T(cosp / sinp), T(c - k * k), c, pol));
+ result = static_cast<T>(s * ellint_rf_imp(T(cosp / sinp), T(c - k * k), c, pol));
}
else
result = s * sin(rphi);