Skip to main content

Module accumulators

Module accumulators 

Source
Expand description

Pluggable accumulation strategies for numerical algorithms.

This module defines the Accumulator trait and a set of concrete implementations used internally by crate::algorithms::vector_norms and available for use in custom algorithms.

§Trait hierarchy

Accumulator
├── SumAccumulator    (adds rescale_by; used for L1/L2 norms)
│   ├── NaiveSum
│   └── NeumaierSum
├── MaxAccumulator    (running maximum of real values)
├── MinAccumulator    (running minimum of real values)
└── MaxAbsValueAccumulator  (running maximum of |x|; used for L∞ norm)

§Choosing a summation strategy

StrategySpeedAccuracyUse when
NaiveSumfastestO(N·ε) errordata is well-scaled
NeumaierSum~2× slowerO(ε) errorcomponents span many magnitudes

§Parallel reduction

All accumulators support parallel chunked reductions via the default Accumulator::new_parallel method, which uses rayon fold + reduce with Accumulator::combine as the merge operation. Accumulator::new() must be the identity element for combine — this holds for all types in this module.

Structs§

MaxAbsValueAccumulator
Accumulator that computes the maximum absolute value over a sequence of scalars: maxᵢ |xᵢ|.
MaxAccumulator
Accumulator that tracks the running maximum of real values.
MinAccumulator
Accumulator that tracks the running minimum of real values.
NaiveSum
Naive (plain +=) accumulator.
NeumaierSum
Neumaier compensated accumulator for sums of floating-point (real or complex) numbers.

Traits§

Accumulator
Base trait for incremental accumulation over a sequence of values.
NeumaierAddable
A trait for types that can participate in Neumaier compensated summation.
SumAccumulator
A generic accumulator for summing a sequence of values with configurable precision/performance trade-offs.