1use crate::simd::SimdValue;
2use num::Signed;
34/// A lane-wise generalization of [`num::Signed`](https://rust-num.github.io/num/num/trait.Signed.html) for SIMD values.
5pub trait SimdSigned: SimdValue {
6/// The absolute value of each lane of `self`.
7fn simd_abs(&self) -> Self;
8/// The absolute difference of each lane of `self`.
9 ///
10 /// For each lane, this zero if the lane of self is less than or equal to the corresponding lane of other
11 /// otherwise the difference between the lane of self and the lane of other is returned.
12fn simd_abs_sub(&self, other: &Self) -> Self;
13/// The signum of each lane of `Self`.
14fn simd_signum(&self) -> Self;
15/// Tests which lane is positive.
16fn is_simd_positive(&self) -> Self::SimdBool;
17/// Tests which lane is negative.
18fn is_simd_negative(&self) -> Self::SimdBool;
19}
2021impl<T: Signed + SimdValue<SimdBool = bool>> SimdSigned for T {
22#[inline(always)]
23fn simd_abs(&self) -> Self {
24self.abs()
25 }
2627#[inline(always)]
28fn simd_abs_sub(&self, other: &Self) -> Self {
29self.abs_sub(other)
30 }
3132#[inline(always)]
33fn simd_signum(&self) -> Self {
34self.signum()
35 }
3637#[inline(always)]
38fn is_simd_positive(&self) -> Self::SimdBool {
39self.is_positive()
40 }
4142#[inline(always)]
43fn is_simd_negative(&self) -> Self::SimdBool {
44self.is_negative()
45 }
46}