diff --git a/stdlib/SparseArrays/src/sparsematrix.jl b/stdlib/SparseArrays/src/sparsematrix.jl index 42cf6b89f8f02d..c6589e0587c977 100644 --- a/stdlib/SparseArrays/src/sparsematrix.jl +++ b/stdlib/SparseArrays/src/sparsematrix.jl @@ -3509,8 +3509,8 @@ end ## circular shift -#swaps blocks start:split and split+1:fin in col -function swap!(col::AbstractVector, start::Integer, fin::Integer, split::Integer) +# thius helper in-place swaps blocks start:split and split+1:fin in col +function _swap!(col::AbstractVector, start::Integer, fin::Integer, split::Integer) split == fin && return reverse!(col, start, split) reverse!(col, split + 1, fin) @@ -3519,8 +3519,8 @@ function swap!(col::AbstractVector, start::Integer, fin::Integer, split::Integer end -#this helper shifts a column by r -function shifter!(R::AbstractVector, V::AbstractVector, start::Integer, fin::Integer, m::Integer, r::Integer) +# this helper shifts a column by r. Used also by sparsevector.jl +function subvector_shifter!(R::AbstractVector, V::AbstractVector, start::Integer, fin::Integer, m::Integer, r::Integer) split = fin @inbounds for j = start:fin # shift in the vertical direction... @@ -3532,8 +3532,8 @@ function shifter!(R::AbstractVector, V::AbstractVector, start::Integer, fin::Int end end # ...but rowval should be sorted within columns - swap!(R, start, fin, split) - swap!(V, start, fin, split) + _swap!(R, start, fin, split) + _swap!(V, start, fin, split) end @@ -3567,7 +3567,7 @@ function circshift!(O::SparseMatrixCSC, X::SparseMatrixCSC, (r,c)::Base.DimsInte ##### vertical shift r = mod(r, X.m) @inbounds for i=1:O.n - shifter!(O.rowval, O.nzval, O.colptr[i], O.colptr[i+1]-1, O.m, r) + subvector_shifter!(O.rowval, O.nzval, O.colptr[i], O.colptr[i+1]-1, O.m, r) end return O end diff --git a/stdlib/SparseArrays/src/sparsevector.jl b/stdlib/SparseArrays/src/sparsevector.jl index 73d14f16e2cfca..432fceb24b485c 100644 --- a/stdlib/SparseArrays/src/sparsevector.jl +++ b/stdlib/SparseArrays/src/sparsevector.jl @@ -1980,7 +1980,7 @@ end function circshift!(O::SparseVector, X::SparseVector, (r,)::Base.DimsInteger{1}) O .= X - shifter!(O.nzind, O.nzval, 1, length(O.nzind), O.n, mod(r, X.n)) + subvector_shifter!(O.nzind, O.nzval, 1, length(O.nzind), O.n, mod(r, X.n)) return O end