Skip to content

Commit

Permalink
improved find diagonal part
Browse files Browse the repository at this point in the history
  • Loading branch information
KlausC committed Aug 8, 2018
1 parent 88f364c commit 70c8b73
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions stdlib/SparseArrays/src/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -464,13 +464,10 @@ function fwdTriSolve!(A::SparseMatrixCSCUnion, B::AbstractVecOrMat, unit::UnitDi
i1 = ia[j]
i2 = ia[j + 1] - 1

# loop through the structural zeros
ii = i1
# find diagonal element
ii = searchsortedfirst(ja, j, i1, i2, Base.Order.Forward)
ii > i2 && ( ii = i1)
jai = ja[ii]
while ii <= i2 && jai < j
ii += 1
jai = ja[ii]
end

bj = B[joff + j]
# check for zero pivot and divide with pivot
Expand Down Expand Up @@ -507,13 +504,10 @@ function bwdTriSolve!(A::SparseMatrixCSCUnion, B::AbstractVecOrMat, unit::UnitDi
i1 = ia[j]
i2 = ia[j + 1] - 1

# loop through the structural zeros
ii = i2
# find diagonal element
ii = searchsortedlast(ja, j, i1, i2, Base.Order.Forward)
ii < i1 && ( ii = i2)
jai = ja[ii]
while ii >= i1 && jai > j
ii -= 1
jai = ja[ii]
end

bj = B[joff + j]
# check for zero pivot and divide with pivot
Expand Down

0 comments on commit 70c8b73

Please sign in to comment.