Skip to content
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

Merged
merged 2 commits into from
Jan 7, 2015

Conversation

stevengj
Copy link
Member

@stevengj stevengj commented Jan 6, 2015

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 old Base.cumsum_pairwise is negligible).

@stevengj
Copy link
Member Author

stevengj commented Jan 7, 2015

Probably worth backporting too.

@timholy
Copy link
Sponsor Member

timholy commented Jan 7, 2015

Aside from needing to address the (quite serious) element type problem that has already been lurking in master, this looks very nice!

@stevengj
Copy link
Member Author

stevengj commented Jan 7, 2015

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 sum. But since that is a breaking change I would prefer to put it in a separate PR.

@timholy
Copy link
Sponsor Member

timholy commented Jan 7, 2015

That's very reasonable, actually. Merge this whenever you're happy.

@stevengj
Copy link
Member Author

stevengj commented Jan 7, 2015

Note also that cumsum! uses a completely different codepath in multidimensional.jl.

stevengj added a commit that referenced this pull request Jan 7, 2015
get pairwise-sum accuracy for cumsum (fix #9648)
@stevengj stevengj merged commit 3de4d53 into JuliaLang:master Jan 7, 2015
stevengj added a commit to stevengj/julia that referenced this pull request Jan 7, 2015
@tkelman tkelman added this to the 0.3.6 milestone Jan 8, 2015
stevengj added a commit that referenced this pull request Jan 18, 2015
@tkelman
Copy link
Contributor

tkelman commented Jan 18, 2015

backported in cf4b604 and b5410df

@stevengj stevengj deleted the cumsum_pairwise branch March 12, 2018 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

more accurate cumsum
3 participants