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

max() on sparse matrices #12118

Closed
nassarhuda opened this issue Jul 11, 2015 · 1 comment
Closed

max() on sparse matrices #12118

nassarhuda opened this issue Jul 11, 2015 · 1 comment
Labels
sparse Sparse arrays

Comments

@nassarhuda
Copy link
Contributor

max() on 2 sparse matrices returns an Array{Float64,Int64}, can this be changed to return a sparse matrix as well?

julia> A = sprand(5,5,1/5)
5x5 sparse matrix with 2 Float64 entries:
    [4, 2]  =  0.502774
    [5, 2]  =  0.224851

julia> B = sprand(5,5,1/5)
5x5 sparse matrix with 6 Float64 entries:
    [1, 1]  =  0.359682
    [5, 1]  =  0.608841
    [4, 2]  =  0.989943
    [2, 3]  =  0.671907
    [5, 4]  =  0.34389
    [4, 5]  =  0.0793254

julia> C = max(A,B)
5x5 Array{Float64,2}:
 0.359682  0.0       0.0       0.0      0.0      
 0.0       0.0       0.671907  0.0      0.0      
 0.0       0.0       0.0       0.0      0.0      
 0.0       0.989943  0.0       0.0      0.0793254
 0.608841  0.224851  0.0       0.34389  0.0    
@kshyatt kshyatt added the sparse Sparse arrays label Jul 11, 2015
@tkelman
Copy link
Contributor

tkelman commented Jul 11, 2015

Makes sense to me. Best to post a cross-reference link when you post both an issue and a related mailing list thread, here https://groups.google.com/forum/#!topic/julia-users/Qh-7q0U5etA

Looks like @which max(A,B) is falling back to the AbstractArray definition from @vectorize_2arg. Could probably get away with adding max and min to the specialized sparse broadcast loop here.

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