Skip to content

Commit 94e44f9

Browse files
committed
lambertw_root_find: fix diff type
1 parent 1ee62c4 commit 94e44f9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/lambertw.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ function lambertw_root_finding(z::T, x0::T, maxits) where T <: Number
126126
two_t = convert(T, 2)
127127
x = x0
128128
lastx = x
129-
lastdiff = zero(T)
130-
converged::Bool = false
129+
lastdiff = zero(real(T))
130+
converged = false
131131
for i in 1:maxits
132132
ex = exp(x)
133133
xexz = x * ex - z
134134
x1 = x + 1
135135
x -= xexz / (ex * x1 - (x + two_t) * xexz / (two_t * x1 ))
136136
xdiff = abs(lastx - x)
137-
if xdiff <= 3 * eps(abs(lastx)) || lastdiff == xdiff # second condition catches two-value cycle
137+
if xdiff <= 3 * eps(lastdiff) || lastdiff == xdiff # second condition catches two-value cycle
138138
converged = true
139139
break
140140
end

0 commit comments

Comments
 (0)