-
-
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
get pairwise-sum accuracy for cumsum (fix #9648) #9650
Conversation
Probably worth backporting too. |
Aside from needing to address the (quite serious) element type problem that has already been lurking in master, this looks very nice! |
We could define something like: _cumsum_type{T<:Number}(v::AbstractArray{T}) = typeof(r_promote(AddFun, zero(T)::T))
_cumsum_type(v) = typeof(r_promote(AddFun, v[1])) to use the same type as |
That's very reasonable, actually. Merge this whenever you're happy. |
Note also that |
get pairwise-sum accuracy for cumsum (fix #9648)
…use same codepath for 1d arrays (see discussion in JuliaLang#9650)
This fixes #9648 (our
cumsum
function had naive-summation accuracy despite using a pairwise-like algorithm). No performance impact as far as I can tell (difference from oldBase.cumsum_pairwise
is negligible).