Skip to content

Commit

Permalink
Added sparse*diagonal, diagonal*sparse methods and tests. Fixes #14416.
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt committed Dec 22, 2015
1 parent f0e2ec1 commit 6b607e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions base/sparse/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ function (*){TX,TvA,TiA}(X::StridedMatrix{TX}, A::SparseMatrixCSC{TvA,TiA})
Y
end

(*)(X::Diagonal, A::SparseMatrixCSC) = scale!(copy(A), X.diag, A)
(*)(A::SparseMatrixCSC, X::Diagonal) = scale!(copy(A), A, X.diag)

# Sparse matrix multiplication as described in [Gustavson, 1978]:
# http://dl.acm.org/citation.cfm?id=355796

Expand Down
3 changes: 3 additions & 0 deletions test/sparsedir/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ for i = 1:5
c = sparse(rand(Float32,5,5))
d = sparse(rand(Float64,5,5))
@test full(kron(c,d)) == kron(full(c),full(d))
f = Diagonal(rand(5))
@test full(a*f) == full(a)*f
@test full(f*b) == f*full(b)
end

# scale and scale!
Expand Down

0 comments on commit 6b607e0

Please sign in to comment.