| 16 | // Reference: https://github.com/eloj/radix-sorting#-key-derivation |
| 17 | template <class T, class UT> |
| 18 | UT |
| 19 | KEY_OF(UT x) |
| 20 | { |
| 21 | // Floating-point is currently disabled. |
| 22 | // Floating-point tests succeed for double and float on macOS but not on |
| 23 | // Windows/Linux. Basic sorting tests succeed but others relying on sort |
| 24 | // fail. Possibly related to floating-point normalisation or multiple NaN |
| 25 | // reprs? Not sure. |
| 26 | if (std::is_floating_point<T>::value) { |
| 27 | // For floats, we invert the key if the sign bit is set, else we invert |
| 28 | // the sign bit. |
| 29 | return ((x) ^ (-((x) >> (sizeof(T) * 8 - 1)) | |
| 30 | ((UT)1 << (sizeof(T) * 8 - 1)))); |
| 31 | } |
| 32 | else if (std::is_signed<T>::value) { |
| 33 | // For signed ints, we flip the sign bit so the negatives are below the |
| 34 | // positives. |
| 35 | return ((x) ^ ((UT)1 << (sizeof(UT) * 8 - 1))); |
| 36 | } |
| 37 | else { |
| 38 | return x; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | template <class T> |
| 43 | static inline npy_ubyte |
nothing calls this directly
no outgoing calls
no test coverage detected