From 43ee5254dbbec64f4f1b992c4bf9a78a303677a4 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Mon, 20 Jul 2020 09:29:18 +0100 Subject: [PATCH] No long double policy: Fix up lambert_w. --- include/boost/math/special_functions/lambert_w.hpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/include/boost/math/special_functions/lambert_w.hpp b/include/boost/math/special_functions/lambert_w.hpp index 5cd50fba7..a0d5de215 100644 --- a/include/boost/math/special_functions/lambert_w.hpp +++ b/include/boost/math/special_functions/lambert_w.hpp @@ -996,20 +996,18 @@ T lambert_w0_approx(T z) //! and then refined using Halley iterations. template -inline T get_near_singularity_param(T z) +inline T do_get_near_singularity_param(T z) { BOOST_MATH_STD_USING const T p2 = 2 * (boost::math::constants::e() * z + 1); const T p = sqrt(p2); return p; } -inline float get_near_singularity_param(float z) +template +inline T get_near_singularity_param(T z, const Policy) { - return static_cast(get_near_singularity_param((double)z)); -} -inline double get_near_singularity_param(double z) -{ - return static_cast(get_near_singularity_param((long double)z)); + typedef typename policies::precision::type precision_type; + return static_cast(get_near_singularity_param((precision_type)z)); } // Forward declarations: @@ -1220,7 +1218,7 @@ T lambert_w_negative_rational_float(T z, const Policy& pol) else { // z is very close (within 0.01) of the singularity at e^-1. - return lambert_w_singularity_series(get_near_singularity_param(z)); + return lambert_w_singularity_series(get_near_singularity_param(z, pol)); } }