Skip to content

Commit

Permalink
JuliaMath#3 (in part)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreySarnoff authored Dec 11, 2017
1 parent ef5aef4 commit 4876eb7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/KahanSummation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ function cumsum_kbn(v::AbstractVector{T}) where T<:AbstractFloat
end

"""
sum_kbn(A)
sum_kbn([f,] A)
Return the sum of all elements of `A`, using the Kahan-Babuska-Neumaier compensated
summation algorithm for additional accuracy.
summation algorithm for additional accuracy. When a function `f` is supplied, the
result of calling f on each element of `A` is summed.
"""
function sum_kbn(A)
T = @default_eltype(typeof(A))
Expand All @@ -113,4 +114,6 @@ function sum_kbn(A)
s - c
end

sum_kbn(f, A) = f.(A)

end # module

0 comments on commit 4876eb7

Please sign in to comment.