Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ end
(T = promote_op(matprod, eltype(A), eltype(B)); mul!(similar(B, T, (size(A, 1), size(B, 2))), A, B))

Base.@constprop :aggressive function LinearAlgebra.generic_matmatmul!(C::StridedMatrix, tA, tB, A::DenseMatrixUnion, B::AbstractSparseMatrixCSC, _add::MulAddMul)
if !(tA in ('N', 'T', 'C') && tB in ('N', 'T', 'C'))
# redirect to most generic matmatmul code
LinearAlgebra._generic_matmatmul!(C, 'N', 'N', LinearAlgebra.wrap(A, tA), LinearAlgebra.wrap(B, tB), _add)
return C
end
transA = tA == 'N' ? identity : tA == 'T' ? transpose : adjoint
if tB == 'N'
_spmul!(C, transA(A), B, _add.alpha, _add.beta)
Expand Down
7 changes: 7 additions & 0 deletions test/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ end
end
end

@testset "Dense times symmetric/Hermitian sparse matrix multiplication" begin
A = [1 3; 2 4]
As = sparse(A)
B = [1 1; 1 1]
@test mul!(copy(B), B, Hermitian(A), true, true) == mul!(copy(B), B, Hermitian(As), true, true)
end

@testset "UniformScaling" begin
local A = sprandn(10, 10, 0.5)
@test A + I == Array(A) + I
Expand Down
Loading