Skip to content

Commit

Permalink
Fix multiplication
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Sep 21, 2023
1 parent aeb3f9b commit d9ca7a5
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/Sparse/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -691,37 +691,36 @@ end
#
################################################################################

function *(b::T, A::SMat{T}) where T
B = sparse_matrix(base_ring(A), nrows(A), ncols(A))
function *(b::T, A::SMat{T}) where {T}
if iszero(b)
return B
return sparse_matrix(base_ring(A), nrows(A), ncols(A))
end
B = sparse_matrix(base_ring(A), 0, ncols(A))
for a in A
push!(B, b*a)
push!(B, b * a)
end
return B
end

function *(b, A::SMat)
return base_ring(A)(b)*A
return base_ring(A)(b) * A
end

function *(A::SMat{T}, b::T) where T
B = sparse_matrix(base_ring(A), nrows(A), ncols(A))
function *(A::SMat{T}, b::T) where {T}
if iszero(b)
return B
return sparse_matrix(base_ring(A), nrows(A), ncols(A))
end
B = sparse_matrix(base_ring(A), 0, ncols(A))
for a in A
push!(B, a*b)
push!(B, a * b)
end
return B
end

function *(A::SMat, b)
return A*base_ring(A)(b)
return A * base_ring(A)(b)
end


################################################################################
#
# Submatrix
Expand Down

0 comments on commit d9ca7a5

Please sign in to comment.