@@ -52,16 +52,14 @@ function _lambertw(x::Real, k, maxits)
52
52
end
53
53
54
54
# Real x, k = 0
55
- # This appears to be inferrable with T=Float64 and T=BigFloat, including if x=Inf.
56
55
# There is a magic number here. It could be noted, or possibly removed.
57
56
# In particular, the fancy initial condition selection does not seem to help speed.
58
- function lambertw_branch_zero (x:: T , maxits):: T where T<: Real
59
- isnan (x) && return (NaN )
60
- x == Inf && return Inf # appears to return convert(BigFloat, Inf) for x == BigFloat(Inf)
57
+ function lambertw_branch_zero (x:: T , maxits) where T<: Real
58
+ isfinite (x) || return x
61
59
one_t = one (T)
62
60
oneoe = - one_t / convert (T, MathConstants. e) # The branch point
63
61
x == oneoe && return - one_t
64
- oneoe <= x || throw (DomainError (x))
62
+ oneoe < x || throw (DomainError (x))
65
63
itwo_t = 1 / convert (T, 2 )
66
64
if x > one_t
67
65
lx = log (x)
77
75
function lambertw_branch_one (x:: T , maxits) where T<: Real
78
76
oneoe = - one (T) / convert (T, MathConstants. e)
79
77
x == oneoe && return - one (T) # W approaches -1 as x -> -1/e from above
80
- oneoe <= x || throw (DomainError (x)) # branch domain exludes x < -1/e
78
+ oneoe < x || throw (DomainError (x)) # branch domain exludes x < -1/e
81
79
x == zero (T) && return - convert (T, Inf ) # W decreases w/o bound as x -> 0 from below
82
80
x < zero (T) || throw (DomainError (x))
83
81
return lambertw_root_finding (x, log (- x), maxits)
0 commit comments