Skip to content

Commit 476c33f

Browse files
committed
ldiv! for Diagonal and a sparse vector
1 parent 9548149 commit 476c33f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/linalg.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ function rdiv!(A::AbstractSparseMatrixCSC{T}, D::Diagonal{T}) where T
13121312
A
13131313
end
13141314

1315-
function ldiv!(D::Diagonal{T}, A::AbstractSparseMatrixCSC{T}) where {T}
1315+
function ldiv!(D::Diagonal{T}, A::Union{AbstractSparseMatrixCSC{T}, AbstractSparseVector{T}}) where {T}
13161316
# require_one_based_indexing(A)
13171317
if size(A, 1) != length(D.diag)
13181318
throw(DimensionMismatch("diagonal matrix is $(length(D.diag)) by $(length(D.diag)) but right hand side has $(size(A, 1)) rows"))

test/linalg.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,9 @@ end
338338
@test lmul!(transpose(copy(D)), copy(b)) transpose(MD)*bd
339339
@test lmul!(adjoint(copy(D)), copy(b)) MD'*bd
340340
end
341+
342+
v = sprand(eltype(D), size(D,1), 0.1)
343+
@test ldiv!(D, copy(v)) == D \ Array(v)
341344
end
342345
end
343346

0 commit comments

Comments
 (0)