diff --git a/src/KahanSummation.jl b/src/KahanSummation.jl index 8bb79db..fde6700 100644 --- a/src/KahanSummation.jl +++ b/src/KahanSummation.jl @@ -23,6 +23,12 @@ else end end +if isdefined(Base, :promote_sys_size_add) + using Base: promote_sys_size_add +else + promote_sys_size_add(x::T) where {T} = Base.r_promote(+, zero(T)::T) +end + """ cumsum_kbn(A, dim::Integer) @@ -87,7 +93,7 @@ summation algorithm for additional accuracy. """ function sum_kbn(A) T = @default_eltype(typeof(A)) - c = Base.promote_sys_size_add(zero(T)::T) + c = promote_sys_size_add(zero(T)::T) i = start(A) if done(A, i) return c diff --git a/test/runtests.jl b/test/runtests.jl index 4301490..133e2e5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,6 +5,9 @@ using KahanSummation using Compat using Compat.Test +# Shadow the names in Base if they're defined +import KahanSummation: sum_kbn, cumsum_kbn + @testset "cumsum_kbn" begin v = [1,1e100,1,-1e100]*1000 v2 = [1,-1e100,1,1e100]*1000