@@ -970,93 +970,93 @@ end
970970
971971# Base interface implementation
972972
973- using . BitonicSortImpl
974- using . QuickSortImpl
975-
976-
977- abstract type SortingAlgorithm end
978- struct QuickSortAlg <: SortingAlgorithm end
979- struct BitonicSortAlg <: SortingAlgorithm end
980-
981- const QuickSort = QuickSortAlg ()
982- const BitonicSort = BitonicSortAlg ()
983-
984-
985- function Base. sort! (c:: AnyCuVector , alg:: QuickSortAlg ; lt= isless, by= identity, rev= false )
986- # for reverse sorting, invert the less-than function
987- if rev
988- lt = ! lt
989- end
990-
991- quicksort! (c; lt, by, dims= 1 )
992- return c
993- end
994-
995- function Base. sort! (c:: AnyCuArray , alg:: BitonicSortAlg ; kwargs... )
996- return bitonic_sort! (c; kwargs... )
997- end
998-
999- function Base. sort! (c:: AnyCuArray ; alg:: SortingAlgorithm = BitonicSort, kwargs... )
1000- return sort! (c, alg; kwargs... )
1001- end
1002-
1003- function Base. sort (c:: AnyCuArray ; kwargs... )
1004- return sort! (copy (c); kwargs... )
1005- end
1006-
1007- function Base. partialsort! (c:: AnyCuVector , k:: Union{Integer, OrdinalRange} ,
1008- alg:: BitonicSortAlg ; lt= isless, by= identity, rev= false )
1009-
1010- sort! (c, alg; lt, by, rev)
1011- return @allowscalar copy (c[k])
1012- end
1013-
1014- function Base. partialsort! (c:: AnyCuVector , k:: Union{Integer, OrdinalRange} ,
1015- alg:: QuickSortAlg ; lt= isless, by= identity, rev= false )
1016- # for reverse sorting, invert the less-than function
1017- if rev
1018- lt = ! lt
1019- end
1020-
1021- function out (k:: OrdinalRange )
1022- return copy (c[k])
1023- end
1024-
1025- # work around disallowed scalar index
1026- function out (k:: Integer )
1027- return Array (c[k: k])[1 ]
1028- end
1029-
1030- quicksort! (c; lt, by, dims= 1 , partial_k= k)
1031- return out (k)
1032- end
1033-
1034- function Base. partialsort! (c:: AnyCuArray , k:: Union{Integer, OrdinalRange} ;
1035- alg:: SortingAlgorithm = BitonicSort, kwargs... )
1036- return partialsort! (c, k, alg; kwargs... )
1037- end
1038-
1039- function Base. partialsort (c:: AnyCuArray , k:: Union{Integer, OrdinalRange} ; kwargs... )
1040- return partialsort! (copy (c), k; kwargs... )
1041- end
1042-
1043- function Base. sortperm! (ix:: AnyCuArray , A:: AnyCuArray ; initialized= false , kwargs... )
1044- if axes (ix) != axes (A)
1045- throw (ArgumentError (" index array must have the same size/axes as the source array, $(axes (ix)) != $(axes (A)) " ))
1046- end
1047-
1048- if ! initialized
1049- ix .= LinearIndices (A)
1050- end
1051- bitonic_sort! ((A, ix); kwargs... )
1052- return ix
1053- end
1054-
1055- function Base. sortperm (c:: AnyCuVector ; kwargs... )
1056- sortperm! (CuArray (1 : length (c)), c; initialized= true , kwargs... )
1057- end
1058-
1059- function Base. sortperm (c:: AnyCuArray ; dims, kwargs... )
1060- # Base errors for Matrices without dims arg, we should too
1061- sortperm! (reshape (CuArray (1 : length (c)), size (c)), c; initialized= true , dims, kwargs... )
1062- end
973+ # using .BitonicSortImpl
974+ # using .QuickSortImpl
975+
976+
977+ # abstract type SortingAlgorithm end
978+ # struct QuickSortAlg <: SortingAlgorithm end
979+ # struct BitonicSortAlg <: SortingAlgorithm end
980+
981+ # const QuickSort = QuickSortAlg()
982+ # const BitonicSort = BitonicSortAlg()
983+
984+
985+ # function Base.sort!(c::AnyCuVector, alg::QuickSortAlg; lt=isless, by=identity, rev=false)
986+ # # for reverse sorting, invert the less-than function
987+ # if rev
988+ # lt = !lt
989+ # end
990+
991+ # quicksort!(c; lt, by, dims=1)
992+ # return c
993+ # end
994+
995+ # function Base.sort!(c::AnyCuArray, alg::BitonicSortAlg; kwargs...)
996+ # return bitonic_sort!(c; kwargs...)
997+ # end
998+
999+ # function Base.sort!(c::AnyCuArray; alg::SortingAlgorithm = BitonicSort, kwargs...)
1000+ # return sort!(c, alg; kwargs...)
1001+ # end
1002+
1003+ # function Base.sort(c::AnyCuArray; kwargs...)
1004+ # return sort!(copy(c); kwargs...)
1005+ # end
1006+
1007+ # function Base.partialsort!(c::AnyCuVector, k::Union{Integer, OrdinalRange},
1008+ # alg::BitonicSortAlg; lt=isless, by=identity, rev=false)
1009+
1010+ # sort!(c, alg; lt, by, rev)
1011+ # return @allowscalar copy(c[k])
1012+ # end
1013+
1014+ # function Base.partialsort!(c::AnyCuVector, k::Union{Integer, OrdinalRange},
1015+ # alg::QuickSortAlg; lt=isless, by=identity, rev=false)
1016+ # # for reverse sorting, invert the less-than function
1017+ # if rev
1018+ # lt = !lt
1019+ # end
1020+
1021+ # function out(k::OrdinalRange)
1022+ # return copy(c[k])
1023+ # end
1024+
1025+ # # work around disallowed scalar index
1026+ # function out(k::Integer)
1027+ # return Array(c[k:k])[1]
1028+ # end
1029+
1030+ # quicksort!(c; lt, by, dims=1, partial_k=k)
1031+ # return out(k)
1032+ # end
1033+
1034+ # function Base.partialsort!(c::AnyCuArray, k::Union{Integer, OrdinalRange};
1035+ # alg::SortingAlgorithm=BitonicSort, kwargs...)
1036+ # return partialsort!(c, k, alg; kwargs...)
1037+ # end
1038+
1039+ # function Base.partialsort(c::AnyCuArray, k::Union{Integer, OrdinalRange}; kwargs...)
1040+ # return partialsort!(copy(c), k; kwargs...)
1041+ # end
1042+
1043+ # function Base.sortperm!(ix::AnyCuArray, A::AnyCuArray; initialized=false, kwargs...)
1044+ # if axes(ix) != axes(A)
1045+ # throw(ArgumentError("index array must have the same size/axes as the source array, $(axes(ix)) != $(axes(A))"))
1046+ # end
1047+
1048+ # if !initialized
1049+ # ix .= LinearIndices(A)
1050+ # end
1051+ # bitonic_sort!((A, ix); kwargs...)
1052+ # return ix
1053+ # end
1054+
1055+ # function Base.sortperm(c::AnyCuVector; kwargs...)
1056+ # sortperm!(CuArray(1:length(c)), c; initialized=true, kwargs...)
1057+ # end
1058+
1059+ # function Base.sortperm(c::AnyCuArray; dims, kwargs...)
1060+ # # Base errors for Matrices without dims arg, we should too
1061+ # sortperm!(reshape(CuArray(1:length(c)), size(c)), c; initialized=true, dims, kwargs...)
1062+ # end
0 commit comments