Skip to content

Commit 53b9aca

Browse files
Merge pull request #250 from JuliaDiffEq/sparsemat
fix sparse matmul
2 parents 6421450 + 7289e0f commit 53b9aca

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/operations.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,11 @@ Base.convert(::Type{Expr},x::Operation) = Expr(x)
7070
# promotion
7171
Base.promote_rule(::Type{<:Constant}, ::Type{<:Operation}) = Operation
7272
Base.promote_rule(::Type{<:Operation}, ::Type{<:Constant}) = Operation
73+
74+
# Fix Sparse MatMul
75+
Base.:*(A::SparseMatrixCSC{Operation,S}, x::StridedVector{Operation}) where {S} =
76+
(T = Operation; mul!(similar(x, T, A.m), A, x, true, false))
77+
Base.:*(A::SparseMatrixCSC{Tx,S}, x::StridedVector{Operation}) where {Tx,S} =
78+
(T = LinearAlgebra.promote_op(LinearAlgebra.matprod, Operation, Tx); mul!(similar(x, T, A.m), A, x, true, false))
79+
Base.:*(A::SparseMatrixCSC{Operation,S}, x::StridedVector{Tx}) where {Tx,S} =
80+
(T = LinearAlgebra.promote_op(LinearAlgebra.matprod, Operation, Tx); mul!(similar(x, T, A.m), A, x, true, false))

0 commit comments

Comments
 (0)