You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
logaddexp(x, y) computes (x.exp() + y.exp()).log() more stably than doing those operations naively, and is particularly useful when doing floating point computations in log-space for better precision / stability.
Num-traits seems like the right place for this implementation, which is why I'm opening an issue., but it also seems like most things are just forwarded, so maybe it was decided here to only provide functionality that could be be forwarded, even if things like abs_sub aren't in std.
I'm happy to submit a PR, but wanted to verify that this was desired / in scope before putting more work into it.
The text was updated successfully, but these errors were encountered:
Did you consider proposing these for the standard library? Generally, I do prefer to leave the actual implementation there and just provide the generic interface here. We do have some implementations for version compatibility or no_std fallbacks, but those are low effort. (FWIW, abs_sub is indeed in std, just deprecated.)
If nothing else, supposing std does add functions like these some day, I would want us to match the API here -- but that's hard to predict if we go first. :)
I have not proposed adding it to the standard library, primarily because I see these as somewhat scientific. There's a reason they occur in libraries like pytorch and numpy, but not in most standard math libraries. I think the second reason they're not frequently in standard libraries is that the implementation is composed of the primitives that are there, notably ln_1p. The api is useful, but it doesn't require anything lower level.
Those explanations, combined with your response on just providing generic compatibility makes me feel like this would be better served in a library supporting scientific math.
logaddexp(x, y)
computes(x.exp() + y.exp()).log()
more stably than doing those operations naively, and is particularly useful when doing floating point computations in log-space for better precision / stability.Num-traits seems like the right place for this implementation, which is why I'm opening an issue., but it also seems like most things are just forwarded, so maybe it was decided here to only provide functionality that could be be forwarded, even if things like
abs_sub
aren't in std.I'm happy to submit a PR, but wanted to verify that this was desired / in scope before putting more work into it.
The text was updated successfully, but these errors were encountered: