simba/simd/
simd_partial_ord.rs1use crate::simd::SimdValue;
2
3pub trait SimdPartialOrd: SimdValue {
5 fn simd_gt(self, other: Self) -> Self::SimdBool;
7 fn simd_lt(self, other: Self) -> Self::SimdBool;
9 fn simd_ge(self, other: Self) -> Self::SimdBool;
11 fn simd_le(self, other: Self) -> Self::SimdBool;
13 fn simd_eq(self, other: Self) -> Self::SimdBool;
15 fn simd_ne(self, other: Self) -> Self::SimdBool;
17
18 fn simd_max(self, other: Self) -> Self;
20 fn simd_min(self, other: Self) -> Self;
22 fn simd_clamp(self, min: Self, max: Self) -> Self;
24
25 fn simd_horizontal_min(self) -> Self::Element;
27 fn simd_horizontal_max(self) -> Self::Element;
29}
30
31impl<T: PartialOrd + SimdValue<Element = T, SimdBool = bool>> SimdPartialOrd for T {
32 #[inline(always)]
33 fn simd_gt(self, other: Self) -> Self::SimdBool {
34 self > other
35 }
36
37 #[inline(always)]
38 fn simd_lt(self, other: Self) -> Self::SimdBool {
39 self < other
40 }
41
42 #[inline(always)]
43 fn simd_ge(self, other: Self) -> Self::SimdBool {
44 self >= other
45 }
46
47 #[inline(always)]
48 fn simd_le(self, other: Self) -> Self::SimdBool {
49 self <= other
50 }
51
52 #[inline(always)]
53 fn simd_eq(self, other: Self) -> Self::SimdBool {
54 self == other
55 }
56
57 #[inline(always)]
58 fn simd_ne(self, other: Self) -> Self::SimdBool {
59 self != other
60 }
61
62 #[inline(always)]
63 fn simd_max(self, other: Self) -> Self {
64 if self >= other {
65 self
66 } else {
67 other
68 }
69 }
70
71 #[inline(always)]
72 fn simd_min(self, other: Self) -> Self {
73 if self <= other {
74 self
75 } else {
76 other
77 }
78 }
79
80 #[inline(always)]
81 fn simd_clamp(self, min: Self, max: Self) -> Self {
82 if self < min {
83 min
84 } else if self > max {
85 max
86 } else {
87 self
88 }
89 }
90
91 #[inline(always)]
92 fn simd_horizontal_min(self) -> Self::Element {
93 self
94 }
95
96 #[inline(always)]
97 fn simd_horizontal_max(self) -> Self::Element {
98 self
99 }
100}