Skip to content

Commit

Permalink
logaddexp code-style
Browse files Browse the repository at this point in the history
  • Loading branch information
cossio committed May 19, 2020
1 parent b1d5a17 commit b7a603d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/basicfuns.jl
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,12 @@ end
Return `log(exp(x) + exp(y))`, avoiding intermediate overflow/undeflow, and handling non-finite values.
"""
logaddexp(x::Real, y::Real) = max(x,y) + log1pexp(-ifelse(x == y, zero(x - y), abs(x - y)))
function logaddexp(x::Real, y::Real)
# ensure Δ = 0 if x = y = Inf
Δ = ifelse(x == y, zero(x - y), abs(x - y))
max(x, y) + log1pexp(-Δ)
end

Base.@deprecate logsumexp(x::Real, y::Real) logaddexp(x, y)

"""
Expand Down

0 comments on commit b7a603d

Please sign in to comment.