SparseArrays.jl icon indicating copy to clipboard operation
SparseArrays.jl copied to clipboard

Drop StridedArray restriction for some sparse mul!s?

Open tkf opened this issue 6 years ago • 4 comments

Currently, mul!(C, A, B, α, β) for the case A is a sparse matrix is defined as

https://github.com/JuliaLang/julia/blob/2d4f4d26a0c5a74717d826dc7e1e62f7650a2e9d/stdlib/SparseArrays/src/linalg.jl#L34-L52

This method is not used in case B is Symmetric, sparse, etc. https://github.com/JuliaLang/LinearAlgebra.jl/issues/663

Would it be crazy to remove restriction B::Union{StridedVector,AdjOrTransStridedMatrix}? As indexing on B does not appear in the inner-most loop, I wonder if it is not such a bad default. Of course, it depends on how dense A is (for col = 1:size(A, 2) could be considered "inner-most" if A is super sparse). However, it's not immediately apparent that there is a case where the generic fallback can be much better than the code assuming that A is sparse.

tkf avatar Sep 11 '19 02:09 tkf

Are you proposing that we change it to AbstractVecOrMat?

andreasnoack avatar Sep 11 '19 07:09 andreasnoack

Yes.

tkf avatar Sep 11 '19 08:09 tkf

Seems reasonable to me

andreasnoack avatar Sep 11 '19 08:09 andreasnoack

Make a PR here?

ViralBShah avatar Jan 18 '22 09:01 ViralBShah