Skip to content

Commit

Permalink
additional test cases and bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KlausC committed Aug 8, 2018
1 parent 4307da6 commit 21592db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 2 additions & 4 deletions stdlib/SparseArrays/src/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,7 @@ function _ldiv!(L::LowerTriangularPlain, B::StridedVecOrMat)

# find diagonal element
ii = searchsortedfirst(ja, j, i1, i2, Base.Order.Forward)
ii > i2 && ( ii = i1)
jai = ja[ii]
jai = ii > i2 ? zero(eltype(ja)) : ja[ii]

bj = B[joff + j]
# check for zero pivot and divide with pivot
Expand Down Expand Up @@ -515,8 +514,7 @@ function _ldiv!(U::UpperTriangularPlain, B::StridedVecOrMat)

# find diagonal element
ii = searchsortedlast(ja, j, i1, i2, Base.Order.Forward)
ii < i1 && ( ii = i2)
jai = ja[ii]
jai = ii < i1 ? zero(eltype(ja)) : ja[ii]

bj = B[joff + j]
# check for zero pivot and divide with pivot
Expand Down
7 changes: 7 additions & 0 deletions stdlib/SparseArrays/test/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2312,6 +2312,13 @@ end
@test AW \ B MAW \ B
end
end

A = LowerTriangular(sparse([0 2.0;0 1]))
@test_throws SingularException(1) A \ ones(2)
A = UpperTriangular(sparse([1.0 0;0 0]))
@test_throws SingularException(2) A \ ones(2)


end

end # module

0 comments on commit 21592db

Please sign in to comment.