pub trait SumAccumulator: Accumulator<Input: Zero + Clone, Output = <Self as Accumulator>::Input> {
// Required method
fn rescale_by(&mut self, r: &Self::Input);
}Expand description
A generic accumulator for summing a sequence of values with configurable precision/performance trade-offs.
The trait abstracts over how terms are collected, allowing different
accumulation strategies to be swapped in without duplicating the calling
code. It is used internally by the crate::algorithms::vector_norms vector-norm functions (scaled
sum-of-squares loop), but is general enough for any sequential summation
task. Two strategies ship with the crate:
- Naive (
NaiveSum): plain+=— fast but accumulates O(N·ε) rounding error. - Neumaier (
NeumaierSum): Kahan/Neumaier compensated summation — recovers O(ε) rounding error at a small overhead cost.
Implement this trait to plug a custom accumulation strategy wherever it is accepted.
Required Methods§
Sourcefn rescale_by(&mut self, r: &Self::Input)
fn rescale_by(&mut self, r: &Self::Input)
Multiply the entire accumulated sum by r.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".