LogExpFunctions.jl
LogExpFunctions.jl copied to clipboard
`logsumexp(f, x)` (and `logsumexp!(f, out, x)`)
How about having a version that takes a function to avoid allocation when doing logsumexp(f.(x)) ?
Would you be open to a PR?
Would it be just
logsumexp(f, x) = logsumexp(f(xi) for xi in x)
? Or maybe
logsumexp(f, x; dims=:) = logsumexp(Broadcast.instantiate(Broadcast.broadcasted(f, x)); dims=dims)
- changing
::AbstractArrayto::Base.AbstractArrayOrBroadcasted?
In any case, I think it could be convenient even though at least the first alternative already works. So I guess a PR would be great 🙂