-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
more accurate cumsum #9648
Comments
This implementation appears to achieve accuracy equal to
In a quick benchmark it takes about twice as long as |
Okay, this variant achieves the same accuracy as function csp!(v::AbstractVector, c::AbstractVector, s, i1, n)
if n < 128
@inbounds s_ = v[i1]
@inbounds c[i1] = +(s, s_)
for i = i1+1:i1+n-1
@inbounds s_ = +(s_, v[i])
@inbounds c[i] = +(s, s_)
end
return s_
else
n2 = div(n,2)
s_ = csp!(v, c, s, i1, n2)
s_ += csp!(v, c, s + s_, i1+n2, n-n2)
return s_
end
end |
get pairwise-sum accuracy for cumsum (fix #9648)
This is my fault in #4039, I think: although
cumsum
implements a "pairwise" algorithm, unlike thesum
function it doesn't actually get any accuracy benefit from this, and is in fact equivalent to naive summation:produces
true
. Is there an easy way to rearrangecumsum_pairwise
so that it is as accurate assum
?cc: @lindahua, @timholy
The text was updated successfully, but these errors were encountered: