MCPcopy Create free account
hub / github.com/numpy/numpy / radixsort0

Function radixsort0

numpy/core/src/npysort/radixsort.cpp:50–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48
49template <class T, class UT>
50static UT *
51radixsort0(UT *start, UT *aux, npy_intp num)
52{
53 npy_intp cnt[sizeof(UT)][1 << 8] = {{0}};
54 UT key0 = KEY_OF<T>(start[0]);
55
56 for (npy_intp i = 0; i < num; i++) {
57 UT k = KEY_OF<T>(start[i]);
58
59 for (size_t l = 0; l < sizeof(UT); l++) {
60 cnt[l][nth_byte(k, l)]++;
61 }
62 }
63
64 size_t ncols = 0;
65 npy_ubyte cols[sizeof(UT)];
66 for (size_t l = 0; l < sizeof(UT); l++) {
67 if (cnt[l][nth_byte(key0, l)] != num) {
68 cols[ncols++] = l;
69 }
70 }
71
72 for (size_t l = 0; l < ncols; l++) {
73 npy_intp a = 0;
74 for (npy_intp i = 0; i < 256; i++) {
75 npy_intp b = cnt[cols[l]][i];
76 cnt[cols[l]][i] = a;
77 a += b;
78 }
79 }
80
81 for (size_t l = 0; l < ncols; l++) {
82 UT *temp;
83 for (npy_intp i = 0; i < num; i++) {
84 UT k = KEY_OF<T>(start[i]);
85 npy_intp dst = cnt[cols[l]][nth_byte(k, cols[l])]++;
86 aux[dst] = start[i];
87 }
88
89 temp = aux;
90 aux = start;
91 start = temp;
92 }
93
94 return start;
95}
96
97template <class T, class UT>
98static int

Callers

nothing calls this directly

Calls 1

nth_byteFunction · 0.85

Tested by

no test coverage detected