Skip to content

Commit

Permalink
Merge pull request #14461 from JuliaLang/ksh/sparsediag
Browse files Browse the repository at this point in the history
Added sparse*diagonal, diagonal*sparse methods and tests. Fixes #14416.
  • Loading branch information
tkelman committed Dec 23, 2015
2 parents 65937f4 + 6b607e0 commit 3642c96
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 3642c96

Please sign in to comment.