Skip to content

Commit

Permalink
Fix kronecker_product(::SMat, ::SMat)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Sep 27, 2023
1 parent d846989 commit ea11246
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/Sparse/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1481,16 +1481,21 @@ function kronecker_product(A::SMat{T}, B::SMat{T}) where {T}
for rB = B.rows
p = Int[]
v = T[]
o = (rA.pos[1]-1)*ncols(B)
for (pp, vv) = rA
for (qq, ww) = rB
push!(p, qq+o)
push!(v, vv*ww)
if !iszero(rA)
o = (rA.pos[1]-1)*ncols(B)
for (pp, vv) = rA
for (qq, ww) = rB
push!(p, qq+o)
push!(v, vv*ww)
end
o += ncols(B)
end
o += ncols(B)
end
push!(C, sparse_row(base_ring(A), p, v))
end
end
@assert nrows(C) == nrows(A)*nrows(B)
@assert ncols(C) <= ncols(A)*ncols(B)
C.c = ncols(A)*ncols(B)
return C
end

0 comments on commit ea11246

Please sign in to comment.