Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ldiv! for Diagonal and a sparse vector #613

Merged
merged 1 commit into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ function rdiv!(A::AbstractSparseMatrixCSC{T}, D::Diagonal{T}) where T
A
end

function ldiv!(D::Diagonal{T}, A::AbstractSparseMatrixCSC{T}) where {T}
function ldiv!(D::Diagonal{T}, A::Union{AbstractSparseMatrixCSC{T}, AbstractSparseVector{T}}) where {T}
# require_one_based_indexing(A)
if size(A, 1) != length(D.diag)
throw(DimensionMismatch("diagonal matrix is $(length(D.diag)) by $(length(D.diag)) but right hand side has $(size(A, 1)) rows"))
Expand Down
3 changes: 3 additions & 0 deletions test/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ end
@test lmul!(transpose(copy(D)), copy(b)) ≈ transpose(MD)*bd
@test lmul!(adjoint(copy(D)), copy(b)) ≈ MD'*bd
end

v = sprand(eltype(D), size(D,1), 0.1)
@test ldiv!(D, copy(v)) == D \ Array(v)
end
end

Expand Down
Loading