We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ef5aef4 commit 4876eb7Copy full SHA for 4876eb7
src/KahanSummation.jl
@@ -86,10 +86,11 @@ function cumsum_kbn(v::AbstractVector{T}) where T<:AbstractFloat
86
end
87
88
"""
89
- sum_kbn(A)
+ sum_kbn([f,] A)
90
91
Return the sum of all elements of `A`, using the Kahan-Babuska-Neumaier compensated
92
-summation algorithm for additional accuracy.
+summation algorithm for additional accuracy. When a function `f` is supplied, the
93
+result of calling f on each element of `A` is summed.
94
95
function sum_kbn(A)
96
T = @default_eltype(typeof(A))
@@ -113,4 +114,6 @@ function sum_kbn(A)
113
114
s - c
115
116
117
+sum_kbn(f, A) = f.(A)
118
+
119
end # module
0 commit comments