LogExpFunctions.jl
LogExpFunctions.jl copied to clipboard
logaddexp introduces NaNs for non-finite values
julia> using ForwardDiff, LogExpFunctions
julia> x = ForwardDiff.Dual(-Inf, 0.0)
Dual{Nothing}(-Inf,0.0)
julia> logaddexp(x, x)
Dual{Nothing}(-Inf,NaN)
I think this is related to JuliaDiff/ForwardDiff.jl#481.
It is the a == b in logaddexp, but I am not yet sure how to elegantly special-case this.
Conceptually, I would be OK with logaddexp(a, b) === b whenever a <= -Inf, after suitable promotion, and similarly of course for the arguments exchanged. This is the only one I would care to special-case, the rest can (and should) just propagate Inf and NaN.