logaddexp-rs

crates.io docs license build

Stable implementations of logaddexp and logsumexp in rust. Computing log(sum_i(exp(v_i))) for more than one value can esily result in overflow. This crate provies implementations for two (lnaddexp) and many (lnsumexp) that are more stable (less prone to overfloe) than doing that computation naively.

Usage

Run

$ cargo add logadexp

Then import the trait you want to use and call the function on the appropriate types

``` use logaddexp::LogAddExp;

f64::lnaddexp(..., ...); ```

``` use logaddexp::LogSumExp;

[...].intoiter().lnsum_exp(); ```