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

sparse binary broadcast incorrect for non-(zero-preserving) functions #19110

Closed
Sacha0 opened this issue Oct 26, 2016 · 5 comments
Closed

sparse binary broadcast incorrect for non-(zero-preserving) functions #19110

Sacha0 opened this issue Oct 26, 2016 · 5 comments
Labels
sparse Sparse arrays

Comments

@Sacha0
Copy link
Member

Sacha0 commented Oct 26, 2016

The definitions here and here cause

julia> VERSION
v"0.6.0-dev.1092"

julia> broadcast((x,y) -> sin(x) + cos(y), speye(5), speye(5))
5×5 sparse matrix with 5 Float64 nonzero entries:
    [1, 1]  =  1.38177
    [2, 2]  =  1.38177
    [3, 3]  =  1.38177
    [4, 4]  =  1.38177
    [5, 5]  =  1.38177

julia> broadcast((x,y) -> sin(x) + cos(y), Array(speye(5)), Array(speye(5)))
5×5 Array{Float64,2}:
 1.38177  1.0      1.0      1.0      1.0
 1.0      1.38177  1.0      1.0      1.0
 1.0      1.0      1.38177  1.0      1.0
 1.0      1.0      1.0      1.38177  1.0
 1.0      1.0      1.0      1.0      1.38177

Best!

@stevengj
Copy link
Member

Ouch. Yet another reason that all the sparse broadcast methods should be replaced with a unified approach that (a) assumes purity, (b) checks f(0...), and (c) always returns a SparseMatrixCSC even if the output is dense, as we've discussed in #18590.

@Sacha0
Copy link
Member Author

Sacha0 commented Oct 26, 2016

Ouch. Yet another reason that all the sparse broadcast methods should be replaced with a unified approach that (a) assumes purity, (b) checks f(0...), and (c) always returns a SparseMatrixCSC even if the output is dense, as we've discussed in #18590.

Agreed. Discovered this bug while experimenting with an implementation; look for more from me shortly :). Best!

@Sacha0
Copy link
Member Author

Sacha0 commented Dec 8, 2016

#19371 provided a partial fix. #19518 should close this altogether. Best!

@pabloferz
Copy link
Contributor

I believe this one is already fixed. Right?

@Sacha0
Copy link
Member Author

Sacha0 commented Jan 22, 2017

I believe this one is already fixed. Right?

Yes, happily fixed :).

@Sacha0 Sacha0 closed this as completed Jan 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sparse Sparse arrays
Projects
None yet
Development

No branches or pull requests

3 participants