-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
SparseMatrixCSC * Vector not supported with StaticArray eltypes #33169
Comments
I went ahead and started preparing a PR, as I need this for my work. I have a question though: how does one go about testing stuff in Base using non-stdlib packages such as StaticArrays? Can I just write "using StaticArrays" and test away? |
Unfortunately no. For OffsetArrays we developed a mini-package just for testing: https://github.com/JuliaLang/julia/blob/master/test/testhelpers/OffsetArrays.jl. The reason is that packages may evolve away from testing the thing that you originally wanted to test. In this case I can replicate your error with ad, vd = Matrix.(a), Vector.(v) so I don't think this is a major limitation for you. |
Hi Tim, Regarding testing, I understand the problem. If I include a |
I don't think you can fix that. How long of a zero vector do you create? |
Yes, the idea would be to initialize the target vector EDIT: I'm talking about this spot julia/stdlib/SparseArrays/src/linalg.jl Lines 34 to 42 in 36c59c1
|
The problem is more general than this specific case (mat * mat also fails with these eltypes) , and boils down to
SparseArrays.mul!
corresponding to the five-argument versionmul!(C, A, B, α, β)
(as opposed to the three-argument version for dense matrices). It is assumed inSparseArray.:*
thatT = promote_op(matprod, eltype(A), eltype(B))
has aα = one(T)
and aβ = zero(T)
that areNumber
s. In this case theone
function is not even defined for a generalSArray
s, and it is actually never aNumber
. Thezero(::SArray)
is defined, but again is not a number but anSArray
.It seems to me that a good way to make this work in general is to simply replace
one(T)
by1
andzero(T)
by0
(Int
s, or perhapstrue
andfalse
) in the following lines (and similar ones), and rely on type conversion inmul!
to do the right thingjulia/stdlib/SparseArrays/src/linalg.jl
Lines 79 to 80 in 36c59c1
This change does not fail any tests locally for me and fixes this issue. I can prepare a PR if this approach is acceptable.
The text was updated successfully, but these errors were encountered: