Skip to content

Commit cdd323d

Browse files
authored
prevent redundant isfinite check
1 parent 4e8836c commit cdd323d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/erf.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,8 @@ function erfinv(y::BigFloat)
424424
# Float64 overflowed, use asymptotic estimate instead
425425
# from erfc(x) ≈ exp(-x²)/x√π ≈ y ⟹ -log(yπ) ≈ x² + log(x) ≈ x²
426426
x = copysign(sqrt(-log((1-abs(y))*sqrtπ)), y)
427+
isfinite(x) || return x
427428
end
428-
isfinite(x) || return x
429429
sqrtπhalf = sqrtπ * 0.5
430430
tol = 2eps(abs(x))
431431
while true # Newton iterations
@@ -451,8 +451,8 @@ function erfcinv(y::BigFloat)
451451
x = -sqrt(-log((2-y)*sqrtπ))
452452
end
453453
# TODO: Newton convergence is slow near y=0 singularity; accelerate?
454+
isfinite(x) || return x
454455
end
455-
isfinite(x) || return x
456456
sqrtπhalf = sqrtπ * 0.5
457457
tol = 2eps(abs(x))
458458
while true # Newton iterations

0 commit comments

Comments
 (0)