Skip to content

Commit

Permalink
Remove temporary circshift direction workaround (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarrasch committed Nov 5, 2022
1 parent bdd0197 commit 311b4b4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
4 changes: 0 additions & 4 deletions src/SparseArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ using Base.Sort: Forward
using LinearAlgebra
using LinearAlgebra: AdjOrTrans, matprod

# Temporary workaround for simplifying SparseArrays.jl upgrade in JuliaLang/julia
# to workaround circshift! bug, see https://github.com/JuliaLang/julia/pull/46759
const CIRCSHIFT_WRONG_DIRECTION = circshift!([1, 2, 3], 1) != circshift([1, 2, 3], 1)


import Base: +, -, *, \, /, &, |, xor, ==, zero, @propagate_inbounds
import LinearAlgebra: mul!, ldiv!, rdiv!, cholesky, adjoint!, diag, eigen, dot,
Expand Down
8 changes: 4 additions & 4 deletions src/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4216,16 +4216,16 @@ function Base.swaprows!(A::AbstractSparseMatrixCSC, i, j)
rows[rr[iidx]] = j
jidx == 0 && continue
rotate_range = rr[iidx]:jrange[jidx]
circshift!(@view(vals[rotate_range]), CIRCSHIFT_WRONG_DIRECTION ? -1 : 1)
circshift!(@view(rows[rotate_range]), CIRCSHIFT_WRONG_DIRECTION ? -1 : 1)
circshift!(@view(vals[rotate_range]), 1)
circshift!(@view(rows[rotate_range]), 1)
else
# Same as i, but in the opposite direction
@assert has_j
rows[jrange[jidx]] = i
iidx > length(rr) && continue
rotate_range = rr[iidx]:jrange[jidx]
circshift!(@view(vals[rotate_range]), CIRCSHIFT_WRONG_DIRECTION ? 1 : -1)
circshift!(@view(rows[rotate_range]), CIRCSHIFT_WRONG_DIRECTION ? 1 : -1)
circshift!(@view(vals[rotate_range]), -1)
circshift!(@view(rows[rotate_range]), -1)
end
end
return nothing
Expand Down
4 changes: 2 additions & 2 deletions src/sparsevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2274,8 +2274,8 @@ function subvector_shifter!(R::AbstractVector, V::AbstractVector, start::Integer
end
end
# ...but rowval should be sorted within columns
circshift!(@view(R[start:fin]), (CIRCSHIFT_WRONG_DIRECTION ? (+) : (-))(split-start+1))
circshift!(@view(V[start:fin]), (CIRCSHIFT_WRONG_DIRECTION ? (+) : (-))(split-start+1))
circshift!(@view(R[start:fin]), -split+start-1)
circshift!(@view(V[start:fin]), -split+start-1)
end

function circshift!(O::SparseVector, X::SparseVector, (r,)::Base.DimsInteger{1})
Expand Down

0 comments on commit 311b4b4

Please sign in to comment.