KahanSummation.jl

Sum and cumulative sum using the Kahan-Babuska-Neumaier algorithm
Author JuliaMath
Popularity
20 Stars
Updated Last
3 Months Ago
Started In
December 2017

KahanSummation.jl

Travis Coveralls

This package provides variants of sum and cumsum, called sum_kbn and cumsum_kbn respectively, using the Kahan-Babuska-Neumaier (KBN) algorithm for additional precision. These functions are typically slower and less memory efficient than sum and cumsum.

These functions were formerly part of Julia's Base library. This package works and is supported.


Examples

julia> using KahanSummation

julia> vec = [1.0, 1.0e16, -1.0e16, -0.5];

julia> sum(vec), sum_kbn(vec)
(-0.5, 0.5)

julia> vec = [1.0, 1.0e16, 1.0, -1.0e16];

julia> cumsum_kbn(vec) .- cumsum(vec)
4-element Array{Float64,1}:
 0.0
 0.0
 2.0
 1.0

see the tests for more examples.

Required Packages

No packages found.