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

Remove eltype assumption from ldiv!(LowerTriangular(SparseMatrixCSC{Tv,Ti), ...) #40174

Merged
merged 2 commits into from
Mar 26, 2021
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
4 changes: 2 additions & 2 deletions stdlib/SparseArrays/src/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ function _ldiv!(L::LowerTriangularPlain, B::StridedVecOrMat)
for k = 1:ncolB
for j = 1:nrowB
i1 = ia[j]
i2 = ia[j + 1] - 1
i2 = ia[j + 1] - one(eltype(ia))

# find diagonal element
ii = searchsortedfirst(ja, j, i1, i2, Base.Order.Forward)
Expand Down Expand Up @@ -688,7 +688,7 @@ function _ldiv!(U::UpperTriangularPlain, B::StridedVecOrMat)
for k = 1:ncolB
for j = nrowB:-1:1
i1 = ia[j]
i2 = ia[j + 1] - 1
i2 = ia[j + 1] - one(eltype(ia))

# find diagonal element
ii = searchsortedlast(ja, j, i1, i2, Base.Order.Forward)
Expand Down
4 changes: 4 additions & 0 deletions stdlib/SparseArrays/test/sparsevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,10 @@ end
@test y == Af'x2f
end
end
@testset "ldiv with different element types (#40171)" begin
sA = sparse(Int16.(1:4), Int16.(1:4), ones(4))
@test all(ldiv!(LowerTriangular(sA), ones(4)) .≈ 1.)
end
@testset "ldiv ops with triangular matrices and sparse vecs (#14005)" begin
m = 10
sparsefloatvecs = SparseVector[sprand(m, 0.4) for k in 1:3]
Expand Down