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

Fix, clean up, and generify broadcast[!] over pairs of sparse matrices #19371

Merged
merged 1 commit into from
Dec 1, 2016

Conversation

Sacha0
Copy link
Member

@Sacha0 Sacha0 commented Nov 21, 2016

This pull request fixes (#19110), cleans up, and slightly generifies broadcast[!] over pairs of sparse matrices.

This pull request does not fundamentally change existing semantics or implementation. Apart from the fix for #19110, changes that reduce cognitive load for wetware interpreters (removal of meta-fu, transformation of variable names and expressions to more enlightening alternatives, insertion of comments) constitute most of the diff. About half the additions derive from the #19110 fix, which unfortunately duplicates part of the existing implementation. (The bulk of that duplication could go away in exchange for some efficiency (both time and memory).)

This pull request represents a first step, not where the code should land. The next step requires settling map!/ broadcast!'s semantics for sparse matrices, and steps thereafter require determining broadcast_zpreserving!'s fate. I will open issues to hash those design questions out.

Best!

@Sacha0 Sacha0 added sparse Sparse arrays broadcast Applying a function over a collection labels Nov 21, 2016
## Broadcast operations involving two sparse matrices
function broadcast{Tf}(f::Tf, A::SparseMatrixCSC, B::SparseMatrixCSC)
indextypeC = promote_type(eltype(A.rowval), eltype(B.rowval))
entrytypeC = Base.Broadcast.promote_eltype_op(f, A, B)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Base. prefix shouldn't be necessary, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

promote_eltype_op is not exported, necessitating the Base.Broadcast. qualification? Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, you need Broadcast but since this is part of Base you shouldn't need Base, I think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file isn't part of Base.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, my mistake. Sorry for the noise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

promote_eltype_op is defined in abstractarray.jl in Base so you can drop the Broadcast

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nixed the qualification's Broadcast part. Thanks!

@Sacha0
Copy link
Member Author

Sacha0 commented Nov 28, 2016

Fixed / improved a few lines with benefit of what I learned from #19438. Absent objections or requests for time, I plan to merge this Thursday morning PST. Best!

…here the broadcast function does not return zero when both arguments are zero.
@Sacha0
Copy link
Member Author

Sacha0 commented Dec 1, 2016

Rebased. Planning to merge once CI clears. Best!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
broadcast Applying a function over a collection bugfix This change fixes an existing bug sparse Sparse arrays
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants