Skip to content

Conversation

@andreasnoack
Copy link
Member

This gives warnings of the type:

Warning: New definition 
    *(SparseMatrixCSC{T1,Ti<:Integer},AbstractArray{T2,1}) at linalg/sparse.jl:13
is ambiguous with 
    *(AbstractArray{T,N},BitArray{N}) at linalg/bitarray.jl:67.
Make sure 
    *(SparseMatrixCSC{T,Ti<:Integer},BitArray{1})
is defined first.

but works fine. What is the better solution to get rid of the warnings?

@timholy
Copy link
Member

timholy commented Oct 1, 2013

What's happening is that Julia is indicating that it's not clear "who" should be handling the product of a sparse matrix and a BitVector: is it the sparse-array code, or the BitVector code? It's not surprising that you're getting the correct answer, because both sparse matrices and BitVectors support elementwise access, and so you should get the right answer no matter which multiplication code is used to compute the answer. However, from an efficiency perspective, Julia cannot guess by itself which one should be "in charge" (presumably it should be the sparse-multiplication code); it may well be computing that product by using the BitVector code, and accessing every element of the matrix (even the zeros).

As the warning suggests, I think your best option is to define a special case for the product SparseMatrixCSC*BitVector. You don't necessarily have to write a separate routine; you can define a sparsemat_vec_mul function and then write several versions of (*) that call it for a variety of types.

@simonster
Copy link
Member

I think you could also define a method for the ambiguous types that calls the desired * method using invoke.

@StefanKarpinski
Copy link
Member

I'm not sure if invoke still has significant overhead – it might. cc: @JeffBezanson

@ViralBShah
Copy link
Member

This PR is a good idea - but we need to get rid of the warnings.

@andreasnoack
Copy link
Member Author

The warnings are gone now by using the invoke trick.

@ViralBShah
Copy link
Member

@JeffBezanson ?

@JeffBezanson
Copy link
Member

invoke can be type-inferred just fine, but is still not the fastest thing around. I have no problem with it though, since eventually making it as fast as anything else is pretty straightforward.

@ViralBShah
Copy link
Member

@andreasnoackjensen I guess you could merge this when you are ready.

andreasnoack added a commit that referenced this pull request Oct 6, 2013
RFC: Make sparse multiplication work for AbstractArrays
@andreasnoack andreasnoack merged commit 8eef0cf into master Oct 6, 2013
@andreasnoack andreasnoack deleted the anj/sparse branch October 6, 2013 05:47
tecosaur added a commit to tecosaur/julia that referenced this pull request Oct 15, 2025
Includes these changes:

f5d171019 * Drop the search keymap, removed in Julia 1.13 (#???)
93a960c76 * origin/master Adapt delayed delete mechanism (JuliaLang#4392)
4184c9ba0 * Add ASCII requirement for package naming (JuliaLang#4404)
tecosaur added a commit to tecosaur/julia that referenced this pull request Oct 15, 2025
Includes these changes:

f5d171019 * Drop the search keymap, removed in Julia 1.13 (#???)
93a960c76 * origin/master Adapt delayed delete mechanism (JuliaLang#4392)
4184c9ba0 * Add ASCII requirement for package naming (JuliaLang#4404)
tecosaur added a commit to tecosaur/julia that referenced this pull request Oct 16, 2025
Includes these changes:

f5d171019 * Drop the search keymap, removed in Julia 1.13 (#???)
93a960c76 * origin/master Adapt delayed delete mechanism (JuliaLang#4392)
4184c9ba0 * Add ASCII requirement for package naming (JuliaLang#4404)
tecosaur added a commit to tecosaur/julia that referenced this pull request Oct 16, 2025
Includes these changes:

f5d171019 * Drop the search keymap, removed in Julia 1.13 (#???)
93a960c76 * origin/master Adapt delayed delete mechanism (JuliaLang#4392)
4184c9ba0 * Add ASCII requirement for package naming (JuliaLang#4404)
tecosaur added a commit to tecosaur/julia that referenced this pull request Oct 17, 2025
Includes these changes:

f5d171019 * Drop the search keymap, removed in Julia 1.13 (#???)
93a960c76 * origin/master Adapt delayed delete mechanism (JuliaLang#4392)
4184c9ba0 * Add ASCII requirement for package naming (JuliaLang#4404)
tecosaur added a commit to tecosaur/julia that referenced this pull request Oct 17, 2025
Includes these changes:

f5d171019 * Drop the search keymap, removed in Julia 1.13 (#???)
93a960c76 * origin/master Adapt delayed delete mechanism (JuliaLang#4392)
4184c9ba0 * Add ASCII requirement for package naming (JuliaLang#4404)
tecosaur added a commit to tecosaur/julia that referenced this pull request Oct 18, 2025
Includes these changes:

f5d171019 * Drop the search keymap, removed in Julia 1.13 (#???)
93a960c76 * origin/master Adapt delayed delete mechanism (JuliaLang#4392)
4184c9ba0 * Add ASCII requirement for package naming (JuliaLang#4404)
tecosaur added a commit to tecosaur/julia that referenced this pull request Oct 18, 2025
Includes these changes:

f5d171019 * Drop the search keymap, removed in Julia 1.13 (#???)
93a960c76 * origin/master Adapt delayed delete mechanism (JuliaLang#4392)
4184c9ba0 * Add ASCII requirement for package naming (JuliaLang#4404)
tecosaur added a commit to tecosaur/julia that referenced this pull request Oct 18, 2025
Includes these changes:

f5d171019 * Drop the search keymap, removed in Julia 1.13 (#???)
93a960c76 * origin/master Adapt delayed delete mechanism (JuliaLang#4392)
4184c9ba0 * Add ASCII requirement for package naming (JuliaLang#4404)
tecosaur added a commit to tecosaur/julia that referenced this pull request Oct 18, 2025
Includes these changes:

f5d171019 * Drop the search keymap, removed in Julia 1.13 (#???)
93a960c76 * origin/master Adapt delayed delete mechanism (JuliaLang#4392)
4184c9ba0 * Add ASCII requirement for package naming (JuliaLang#4404)
tecosaur added a commit to tecosaur/julia that referenced this pull request Oct 19, 2025
Includes these changes:

f5d171019 * Drop the search keymap, removed in Julia 1.13 (#???)
93a960c76 * origin/master Adapt delayed delete mechanism (JuliaLang#4392)
4184c9ba0 * Add ASCII requirement for package naming (JuliaLang#4404)
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.

7 participants