Skip to content

Commit c075d00

Browse files
committed
remove unused method sortSparseMatrixCSC!, rename sortBuffers! -> _sort_buffers!
1 parent 48ab6f2 commit c075d00

File tree

2 files changed

+4
-73
lines changed

2 files changed

+4
-73
lines changed

stdlib/SparseArrays/src/sparsematrix.jl

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -3708,74 +3708,6 @@ function tr(A::AbstractSparseMatrixCSC{Tv}) where Tv
37083708
return s
37093709
end
37103710

3711-
3712-
# Sort all the indices in each column of a CSC sparse matrix
3713-
# sortSparseMatrixCSC!(A, sortindices = :sortcols) # Sort each column with sort()
3714-
# sortSparseMatrixCSC!(A, sortindices = :doubletranspose) # Sort with a double transpose
3715-
function sortSparseMatrixCSC!(A::AbstractSparseMatrixCSC{Tv,Ti}; sortindices::Symbol = :sortcols) where {Tv,Ti}
3716-
if sortindices === :doubletranspose
3717-
nB, mB = size(A)
3718-
B = SparseMatrixCSC(mB, nB, Vector{Ti}(undef, nB+1), similar(rowvals(A)), similar(nonzeros(A)))
3719-
transpose!(B, A)
3720-
transpose!(A, B)
3721-
return A
3722-
end
3723-
3724-
m, n = size(A)
3725-
colptr = getcolptr(A); rowval = rowvals(A); nzval = nonzeros(A)
3726-
3727-
index = zeros(Ti, m)
3728-
row = zeros(Ti, m)
3729-
val = zeros(Tv, m)
3730-
3731-
perm = Base.Perm(Base.ord(isless, identity, false, Base.Order.Forward), row)
3732-
3733-
@inbounds for i = 1:n
3734-
nzr = nzrange(A, i)
3735-
numrows = length(nzr)
3736-
if numrows <= 1
3737-
continue
3738-
elseif numrows == 2
3739-
f = first(nzr)
3740-
s = f+1
3741-
if rowval[f] > rowval[s]
3742-
rowval[f], rowval[s] = rowval[s], rowval[f]
3743-
nzval[f], nzval[s] = nzval[s], nzval[f]
3744-
end
3745-
continue
3746-
end
3747-
resize!(row, numrows)
3748-
resize!(index, numrows)
3749-
3750-
jj = 1
3751-
@simd for j = nzr
3752-
row[jj] = rowval[j]
3753-
val[jj] = nzval[j]
3754-
jj += 1
3755-
end
3756-
3757-
if numrows <= 16
3758-
alg = Base.Sort.InsertionSort
3759-
else
3760-
alg = Base.Sort.QuickSort
3761-
end
3762-
3763-
# Reset permutation
3764-
index .= 1:numrows
3765-
3766-
sort!(index, alg, perm)
3767-
3768-
jj = 1
3769-
@simd for j = nzr
3770-
rowval[j] = row[index[jj]]
3771-
nzval[j] = val[index[jj]]
3772-
jj += 1
3773-
end
3774-
end
3775-
3776-
return A
3777-
end
3778-
37793711
## rotations
37803712

37813713
function rot180(A::AbstractSparseMatrixCSC)

stdlib/SuiteSparse/src/cholmod.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,15 +1117,15 @@ function SparseMatrixCSC{Tv,SuiteSparse_long}(A::Sparse{Tv}) where Tv
11171117
"with stype == 0 before converting to SparseMatrixCSC"))
11181118
end
11191119
args = _extract_args(s)
1120-
s.sorted == 0 && sortBuffers!(args...);
1120+
s.sorted == 0 && _sort_buffers!(args...);
11211121
return _trim_nz_builder!(args...)
11221122
end
11231123

11241124
function Symmetric{Float64,SparseMatrixCSC{Float64,SuiteSparse_long}}(A::Sparse{Float64})
11251125
s = unsafe_load(pointer(A))
11261126
issymmetric(A) || throw(ArgumentError("matrix is not symmetric"))
11271127
args = _extract_args(s)
1128-
s.sorted == 0 && sortBuffers!(args...)
1128+
s.sorted == 0 && _sort_buffers!(args...)
11291129
Symmetric(_trim_nz_builder!(args...), s.stype > 0 ? :U : :L)
11301130
end
11311131
convert(T::Type{Symmetric{Float64,SparseMatrixCSC{Float64,SuiteSparse_long}}}, A::Sparse{Float64}) = T(A)
@@ -1134,7 +1134,7 @@ function Hermitian{Tv,SparseMatrixCSC{Tv,SuiteSparse_long}}(A::Sparse{Tv}) where
11341134
s = unsafe_load(pointer(A))
11351135
ishermitian(A) || throw(ArgumentError("matrix is not Hermitian"))
11361136
args = _extract_args(s)
1137-
s.sorted == 0 && sortBuffers!(args...)
1137+
s.sorted == 0 && _sort_buffers!(args...)
11381138
Hermitian(_trim_nz_builder!(args...), s.stype > 0 ? :U : :L)
11391139
end
11401140
convert(T::Type{Hermitian{Tv,SparseMatrixCSC{Tv,SuiteSparse_long}}}, A::Sparse{Tv}) where {Tv<:VTypes} = T(A)
@@ -1958,8 +1958,7 @@ end
19581958
B::Hermitian{Float64,SparseMatrixCSC{Float64,Ti}}) where {Ti} = sparse(Sparse(A)*Sparse(B))
19591959

19601960
# Sort all the indices in each column for the construction of a CSC sparse matrix
1961-
# sortBuffers!(A, sortindices = :sortcols) # Sort each column with sort()
1962-
function sortBuffers!(m, n, colptr::Vector{Ti}, rowval::Vector{Ti}, nzval::Vector{Tv}) where {Ti <: Integer, Tv}
1961+
function _sort_buffers!(m, n, colptr::Vector{Ti}, rowval::Vector{Ti}, nzval::Vector{Tv}) where {Ti <: Integer, Tv}
19631962
index = Base.zeros(Ti, m)
19641963
row = Base.zeros(Ti, m)
19651964
val = Base.zeros(Tv, m)

0 commit comments

Comments
 (0)