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

matmul fails with empty inner dimension #1203

Open
mikmoore opened this issue Sep 25, 2023 · 0 comments
Open

matmul fails with empty inner dimension #1203

mikmoore opened this issue Sep 25, 2023 · 0 comments

Comments

@mikmoore
Copy link

StaticArrays at v1.6.2 on Julia v1.9.1.

StaticArrays attempts to index empty arrays, resulting in an error, when the inner dimension of a SMatrix-SMatrix multiply is empty. I.e., for M x 0 times 0 x N multiply.

julia> using StaticArrays

julia> Z = zero(SMatrix{1,0,Float64,0})
1×0 SMatrix{1, 0, Float64, 0} with indices SOneTo(1)×SOneTo(0)

julia> Z'*Z
0×0 SMatrix{0, 0, Float64, 0} with indices SOneTo(0)×SOneTo(0)

julia> Z*Z'
ERROR: BoundsError: attempt to access Tuple{} at index [1]
Stacktrace:
 [1] getindex(t::Tuple, i::Int64)
   @ Base ./tuple.jl:29
 [2] getindex
   @ ~/.julia/packages/StaticArrays/9KYrc/src/SArray.jl:62 [inlined]
 [3] macro expansion
   @ ~/.julia/packages/StaticArrays/9KYrc/src/matrix_multiply.jl:217 [inlined]
 [4] mul_loop(#unused#::Size{(1, 0)}, #unused#::Size{(0, 1)}, a::SMatrix{1, 0, Float64, 0}, b::SMatrix{0, 1, Float64, 0})
   @ StaticArrays ~/.julia/packages/StaticArrays/9KYrc/src/matrix_multiply.jl:188
 [5] macro expansion
   @ ~/.julia/packages/StaticArrays/9KYrc/src/matrix_multiply.jl:139 [inlined]
 [6] _mul(Sa::Size{(1, 0)}, Sb::Size{(0, 1)}, a::SMatrix{1, 0, Float64, 0}, b::SMatrix{0, 1, Float64, 0})
   @ StaticArrays ~/.julia/packages/StaticArrays/9KYrc/src/matrix_multiply.jl:130
 [7] *(A::SMatrix{1, 0, Float64, 0}, B::SMatrix{0, 1, Float64, 0})
   @ StaticArrays ~/.julia/packages/StaticArrays/9KYrc/src/matrix_multiply.jl:11
 [8] top-level scope
   @ REPL[401]:1
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

No branches or pull requests

1 participant