Skip to content

Commit

Permalink
Remove eltype assumption from ldiv!(LowerTriangular(SparseMatrixCSC{T…
Browse files Browse the repository at this point in the history
…v,Ti), ...) (#40174)
  • Loading branch information
palday authored Mar 26, 2021
1 parent d92b0d8 commit beeb6d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
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

0 comments on commit beeb6d7

Please sign in to comment.