@@ -205,6 +205,27 @@ const SparseOrTri{Tv,Ti} = Union{SparseMatrixCSCUnion{Tv,Ti},SparseTriangular{Tv
205205* (A:: AdjOrTrans{<:Any,<:AbstractSparseMatrixCSC} , B:: SparseOrTri ) = spmatmul (copy (A), B)
206206* (A:: AdjOrTrans{<:Any,<:AbstractSparseMatrixCSC} , B:: AdjOrTrans{<:Any,<:AbstractSparseMatrixCSC} ) = spmatmul (copy (A), copy (B))
207207
208+ (* )(Da:: Diagonal , A:: Union{SparseMatrixCSCUnion, AdjOrTrans{<:Any,<:AbstractSparseMatrixCSC}} , Db:: Diagonal ) = Da * (A * Db)
209+ function (* )(Da:: Diagonal , A:: SparseMatrixCSC , Db:: Diagonal )
210+ (size (Da, 2 ) == size (A,1 ) && size (A,2 ) == size (Db,1 )) ||
211+ throw (DimensionMismatch (" incompatible sizes" ))
212+ T = promote_op (matprod, eltype (Da), promote_op (matprod, eltype (A), eltype (Db)))
213+ dest = similar (A, T)
214+ vals_dest = nonzeros (dest)
215+ rows = rowvals (A)
216+ vals = nonzeros (A)
217+ da, db = map (parent, (Da, Db))
218+ for col in axes (A,2 )
219+ dbcol = db[col]
220+ for i in nzrange (A, col)
221+ row = rows[i]
222+ val = vals[i]
223+ vals_dest[i] = da[row] * val * dbcol
224+ end
225+ end
226+ dest
227+ end
228+
208229# Gustavson's matrix multiplication algorithm revisited.
209230# The result rowval vector is already sorted by construction.
210231# The auxiliary Vector{Ti} xb is replaced by a Vector{Bool} of same length.
0 commit comments