Skip to content

Commit

Permalink
use real log1p when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Expander committed Feb 21, 2024
1 parent da0451e commit 5bf6eeb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Log.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ end
# returns complex logarithm of 1+z;
# handles case when imag(z) == -0.0
function clog1p(z::Complex)
log1p(convert_minus_0(z))
if iszero(imag(z)) && real(z) > -one(real(z))
Complex(log1p(real(z)), zero(real(z)))
else
log1p(convert_minus_0(z))
end
end

# returns |ln(x)|^2 for all x
Expand Down

0 comments on commit 5bf6eeb

Please sign in to comment.