diff --git a/stdlib/SparseArrays/src/linalg.jl b/stdlib/SparseArrays/src/linalg.jl index 6e9a751dd4306..ad8ffb2b14f63 100644 --- a/stdlib/SparseArrays/src/linalg.jl +++ b/stdlib/SparseArrays/src/linalg.jl @@ -968,7 +968,7 @@ function copyinds!(C::SparseMatrixCSC, A::SparseMatrixCSC) end # multiply by diagonal matrix as vector -function mul!(C::SparseMatrixCSC, A::SparseMatrixCSC, D::Diagonal{<:Vector}) +function mul!(C::SparseMatrixCSC, A::SparseMatrixCSC, D::Diagonal{T, <:Vector}) where T m, n = size(A) b = D.diag (n==length(b) && size(A)==size(C)) || throw(DimensionMismatch()) @@ -982,7 +982,7 @@ function mul!(C::SparseMatrixCSC, A::SparseMatrixCSC, D::Diagonal{<:Vector}) C end -function mul!(C::SparseMatrixCSC, D::Diagonal{<:Vector}, A::SparseMatrixCSC) +function mul!(C::SparseMatrixCSC, D::Diagonal{T, <:Vector}, A::SparseMatrixCSC) where T m, n = size(A) b = D.diag (m==length(b) && size(A)==size(C)) || throw(DimensionMismatch()) diff --git a/stdlib/SparseArrays/test/sparse.jl b/stdlib/SparseArrays/test/sparse.jl index 0c17946d7a5d8..416cbffac27cf 100644 --- a/stdlib/SparseArrays/test/sparse.jl +++ b/stdlib/SparseArrays/test/sparse.jl @@ -8,6 +8,7 @@ using LinearAlgebra using Base.Printf: @printf using Random using Test: guardseed +using InteractiveUtils: @which @testset "issparse" begin @test issparse(sparse(fill(1,5,5))) @@ -2295,4 +2296,15 @@ end @test typeof(a) === typeof(na) end +#PR #29045 +@testset "Issue #28934" begin + A = sprand(5,5,0.5) + D = Diagonal(rand(5)) + C = copy(A) + m1 = @which mul!(C,A,D) + m2 = @which mul!(C,D,A) + @test m1.module == SparseArrays + @test m2.module == SparseArrays +end + end # module