Skip to content

Commit

Permalink
fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilith Hafner authored and Lilith Hafner committed Sep 5, 2023
1 parent 508e754 commit cf4aac5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ function LinearAlgebra.generic_trimatdiv!(C::StridedVecOrMat, uploc, isunitc, tf
i2 = ia[j + 1] - one(eltype(ia))

# find diagonal element
ii = searchsortedfirst(view(ja, i1:i2), j) - i1 + 1
ii = searchsortedfirst(view(ja, i1:i2), j) + i1 - 1
jai = ii > i2 ? zero(eltype(ja)) : ja[ii]

cj = C[j,k]
Expand Down Expand Up @@ -723,7 +723,7 @@ function LinearAlgebra.generic_trimatdiv!(C::StridedVecOrMat, uploc, isunitc, tf
i2 = ia[j + 1] - one(eltype(ia))

# find diagonal element
ii = searchsortedlast(view(ja, i1:i2), j) - i1 + 1
ii = searchsortedlast(view(ja, i1:i2), j) + i1 - 1
jai = ii < i1 ? zero(eltype(ja)) : ja[ii]

cj = C[j,k]
Expand Down Expand Up @@ -801,7 +801,7 @@ function LinearAlgebra.generic_trimatdiv!(C::StridedVecOrMat, uploc, isunitc, ::
i2 = ia[j + 1] - one(eltype(ia))

# find diagonal element
ii = searchsortedfirst(view(ja, i1:i2), j) - i1 + 1
ii = searchsortedfirst(view(ja, i1:i2), j) + i1 - 1
jai = ii > i2 ? zero(eltype(ja)) : ja[ii]

cj = C[j,k]
Expand Down Expand Up @@ -830,7 +830,7 @@ function LinearAlgebra.generic_trimatdiv!(C::StridedVecOrMat, uploc, isunitc, ::
i2 = ia[j + 1] - one(eltype(ia))

# find diagonal element
ii = searchsortedlast(view(ja, i1:i2), j) - i1 + 1
ii = searchsortedlast(view(ja, i1:i2), j) + i1 - 1
jai = ii < i1 ? zero(eltype(ja)) : ja[ii]

cj = C[j,k]
Expand Down
10 changes: 5 additions & 5 deletions src/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,7 @@ function _sparse_findprevnz(m::AbstractSparseMatrixCSC, ij::CartesianIndex{2})
iszero(col) && return nothing

lo, hi = getcolptr(m)[col], getcolptr(m)[col+1]
n = searchsortedlast(view(rowvals(m), lo:hi-1), row) - lo + 1
n = searchsortedlast(view(rowvals(m), lo:hi-1), row) + lo - 1
if lo <= n <= hi-1
return CartesianIndex(rowvals(m)[n], col)
end
Expand Down Expand Up @@ -3491,7 +3491,7 @@ function setindex!(A::AbstractSparseMatrixCSC, x::AbstractArray, I::AbstractMatr
xidx += 1

if r1 <= r2
copylen = searchsortedfirst(view(rowvalA, r1:r2), row) - 2r1 + 1
copylen = searchsortedfirst(view(rowvalA, r1:r2), row) - 1
if (copylen > 0)
if (nadd > 0)
copyto!(rowvalB, bidx, rowvalA, r1, copylen)
Expand Down Expand Up @@ -3621,7 +3621,7 @@ function setindex!(A::AbstractSparseMatrixCSC, x::AbstractArray, Ix::AbstractVec
end

if r1 <= r2
copylen = searchsortedfirst(view(rowvalA, r1:r2), row) - 2r1 + 1
copylen = searchsortedfirst(view(rowvalA, r1:r2), row) - 1
if (copylen > 0)
if (nadd > 0)
copyto!(rowvalB, bidx, rowvalA, r1, copylen)
Expand Down Expand Up @@ -3705,7 +3705,7 @@ function dropstored!(A::AbstractSparseMatrixCSC, i::Integer, j::Integer)
end
coljfirstk = Int(getcolptr(A)[j])
coljlastk = Int(getcolptr(A)[j+1] - 1)
searchk = searchsortedfirst(view(rowvals(A), coljfirstk:coljlastk), i) - coljfirstk + 1
searchk = searchsortedfirst(view(rowvals(A), coljfirstk:coljlastk), i) + coljfirstk - 1
if searchk <= coljlastk && rowvals(A)[searchk] == i
# Entry A[i,j] is stored. Drop and return.
deleteat!(rowvals(A), searchk)
Expand Down Expand Up @@ -4222,7 +4222,7 @@ function diag(A::AbstractSparseMatrixCSC{Tv,Ti}, d::Integer=0) where {Tv,Ti}
r1 = Int(getcolptr(A)[c])
r2 = Int(getcolptr(A)[c+1]-1)
r1 > r2 && continue
r1 += searchsortedfirst(view(rowvals(A), r1:r2), r) + 1
r1 += searchsortedfirst(view(rowvals(A), r1:r2), r) - 1
((r1 > r2) || (rowvals(A)[r1] != r)) && continue
push!(ind, i)
push!(val, nonzeros(A)[r1])
Expand Down

0 comments on commit cf4aac5

Please sign in to comment.