From 63f09b4c30688e534710da2fdc556aeaef0140aa Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Mon, 13 May 2019 19:16:00 +0100 Subject: [PATCH] ellint_3: rearrange special cases for better performance and to avoid redundant check. Fixes https://github.com/boostorg/math/issues/197. --- include/boost/math/special_functions/ellint_3.hpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/boost/math/special_functions/ellint_3.hpp b/include/boost/math/special_functions/ellint_3.hpp index b8b36729c..22563d5d6 100644 --- a/include/boost/math/special_functions/ellint_3.hpp +++ b/include/boost/math/special_functions/ellint_3.hpp @@ -73,6 +73,9 @@ T ellint_pi_imp(T v, T phi, T k, T vc, const Policy& pol) if(v == 1) { + if (k == 0) + return tan(phi); + // http://functions.wolfram.com/08.06.03.0008.01 T m = k * k; result = sqrt(1 - m * sphi * sphi) * tan(phi) - ellint_e_imp(phi, k, pol); @@ -143,10 +146,6 @@ T ellint_pi_imp(T v, T phi, T k, T vc, const Policy& pol) T vcr = sqrt(vc); return atan(vcr * tan(phi)) / vcr; } - else if(v == 1) - { - return tan(phi); - } else { // v > 1: