51
51
uint_mapping (:: ForwardOrdering , x:: Float32 ) = (y = reinterpret (Int32, x); reinterpret (UInt32, ifelse (y < 0 , ~ y, xor (y, typemin (Int32)))))
52
52
uint_mapping (:: ForwardOrdering , x:: Float64 ) = (y = reinterpret (Int64, x); reinterpret (UInt64, ifelse (y < 0 , ~ y, xor (y, typemin (Int64)))))
53
53
54
+ uint_mapping (:: Sort.Float.Left , x:: Float16 ) = ~ reinterpret (Int16, x)
55
+ uint_mapping (:: Sort.Float.Right , x:: Float16 ) = reinterpret (Int16, x)
56
+ uint_mapping (:: Sort.Float.Left , x:: Float32 ) = ~ reinterpret (Int32, x)
57
+ uint_mapping (:: Sort.Float.Right , x:: Float32 ) = reinterpret (Int32, x)
58
+ uint_mapping (:: Sort.Float.Left , x:: Float64 ) = ~ reinterpret (Int64, x)
59
+ uint_mapping (:: Sort.Float.Right , x:: Float64 ) = reinterpret (Int64, x)
60
+
54
61
uint_mapping (rev:: ReverseOrdering , x) = ~ uint_mapping (rev. fwd, x)
55
62
uint_mapping (:: ReverseOrdering{ForwardOrdering} , x:: Real ) = ~ uint_mapping (Forward, x) # maybe unnecessary; needs benchmark
56
63
@@ -61,18 +68,18 @@ uint_mapping(o::Lt, x ) = error("uint_mapping does not work with general L
61
68
const RADIX_SIZE = 11
62
69
const RADIX_MASK = 0x7FF
63
70
64
- function sort! (vs:: AbstractVector , lo:: Int , hi:: Int , :: RadixSortAlg , o:: Ordering , ts= similar (vs))
71
+ function sort! (vs:: AbstractVector{T} , lo:: Int , hi:: Int , :: RadixSortAlg , o:: Ordering , ts:: AbstractVector{T} = similar (vs)) where T
65
72
# Input checking
66
73
if lo >= hi; return vs; end
67
74
68
75
# Make sure we're sorting a bits type
69
- T = Base. Order. ordtype (o, vs)
70
- if ! isbitstype (T )
71
- error (" Radix sort only sorts bits types (got $T )" )
76
+ OT = Base. Order. ordtype (o, vs)
77
+ if ! isbitstype (OT )
78
+ error (" Radix sort only sorts bits types (got $OT )" )
72
79
end
73
80
74
81
# Init
75
- iters = ceil (Integer, sizeof (T )* 8 / RADIX_SIZE)
82
+ iters = ceil (Integer, sizeof (OT )* 8 / RADIX_SIZE)
76
83
bin = zeros (UInt32, 2 ^ RADIX_SIZE, iters)
77
84
if lo > 1 ; bin[1 ,:] .= lo- 1 ; end
78
85
0 commit comments