Skip to main content

numpy_pairwise_sum

Function numpy_pairwise_sum 

Source
pub fn numpy_pairwise_sum<T>(values: &[T]) -> T
where T: Copy + Default + Add<Output = T>,
Expand description

numpy’s pairwise_sum, the kernel of its float add.reduce over a contiguous run, every addition in T: below 8 values a running sum from 0; up to 128, eight running sums seeded with the first eight values and stepped over the 8-value blocks, folded as ((r0 + r1) + (r2 + r3)) + ((r4 + r5) + (r6 + r7)), then the remainder in order; beyond that the two halves (the first a multiple of 8 long) summed apart. pandas’ float32 and float64 sums are it bit for bit, where a sum rounded once or added left to right differs in the last place (fvsao.23, br-frankenpandas-9iim6).