pub trait LogSumExp: Iterator {
// Provided methods
fn log_sum_exp_no_alloc<T: Float + Ln2, L: Borrow<LogProb<T>>>(
self,
) -> Result<LogProb<T>, ProbabilitiesSumToGreaterThanOne>
where Self: Sized + Iterator<Item = L> { ... }
fn log_sum_exp_clamped_no_alloc<T: Float + Ln2, L: Borrow<LogProb<T>>>(
self,
) -> LogProb<T>
where Self: Sized + Iterator<Item = L> { ... }
fn log_sum_exp_float_no_alloc<T: Float + Ln2, L: Borrow<LogProb<T>>>(
self,
) -> T
where Self: Sized + Iterator<Item = L> { ... }
fn log_sum_exp<T: Float + Ln2 + Sum, L: Borrow<LogProb<T>>>(
self,
) -> Result<LogProb<T>, ProbabilitiesSumToGreaterThanOne>
where Self: Sized + Iterator<Item = L> { ... }
fn log_sum_exp_clamped<T: Float + Ln2 + Sum, L: Borrow<LogProb<T>>>(
self,
) -> LogProb<T>
where Self: Sized + Iterator<Item = L> { ... }
fn log_sum_exp_float<T: Float + Ln2 + Sum, L: Borrow<LogProb<T>>>(self) -> T
where Self: Sized + Iterator<Item = L> { ... }
}Expand description
This trait allows iterators to have LogSumExp.
Provided Methods§
Sourcefn log_sum_exp_no_alloc<T: Float + Ln2, L: Borrow<LogProb<T>>>(
self,
) -> Result<LogProb<T>, ProbabilitiesSumToGreaterThanOne>
fn log_sum_exp_no_alloc<T: Float + Ln2, L: Borrow<LogProb<T>>>( self, ) -> Result<LogProb<T>, ProbabilitiesSumToGreaterThanOne>
Sourcefn log_sum_exp_clamped_no_alloc<T: Float + Ln2, L: Borrow<LogProb<T>>>(
self,
) -> LogProb<T>
fn log_sum_exp_clamped_no_alloc<T: Float + Ln2, L: Borrow<LogProb<T>>>( self, ) -> LogProb<T>
Adds up an iterator of LogProb (as raw probabilities) and returns a new LogProb clamping values greater than 0.0.
Will only return Ok if the sum could be a valid LogProb. It does not allocate a vector and will often be faster than log_sum_exp_clamped if you expect there to be clamping as the iterator can short-circuit.
Sourcefn log_sum_exp_float_no_alloc<T: Float + Ln2, L: Borrow<LogProb<T>>>(self) -> T
fn log_sum_exp_float_no_alloc<T: Float + Ln2, L: Borrow<LogProb<T>>>(self) -> T
Sourcefn log_sum_exp<T: Float + Ln2 + Sum, L: Borrow<LogProb<T>>>(
self,
) -> Result<LogProb<T>, ProbabilitiesSumToGreaterThanOne>
fn log_sum_exp<T: Float + Ln2 + Sum, L: Borrow<LogProb<T>>>( self, ) -> Result<LogProb<T>, ProbabilitiesSumToGreaterThanOne>
Sourcefn log_sum_exp_clamped<T: Float + Ln2 + Sum, L: Borrow<LogProb<T>>>(
self,
) -> LogProb<T>
fn log_sum_exp_clamped<T: Float + Ln2 + Sum, L: Borrow<LogProb<T>>>( self, ) -> LogProb<T>
Adds up an iterator of LogProb (as raw probabilities) and returns a float with their sum,
regardless of if it would be a valid LogProb. It does allocate a vector, but is usally
slower than Self::log_sum_exp_clamped_no_alloc if you expect clamping.