pub trait SimdUint: Copy + Sealed {
type Scalar;
type Cast<T: SimdElement>;
Show 20 methods
// Required methods
fn cast<T: SimdCast>(self) -> Self::Cast<T>;
fn wrapping_neg(self) -> Self;
fn saturating_add(self, second: Self) -> Self;
fn saturating_sub(self, second: Self) -> Self;
fn abs_diff(self, second: Self) -> Self;
fn reduce_sum(self) -> Self::Scalar;
fn reduce_product(self) -> Self::Scalar;
fn reduce_max(self) -> Self::Scalar;
fn reduce_min(self) -> Self::Scalar;
fn reduce_and(self) -> Self::Scalar;
fn reduce_or(self) -> Self::Scalar;
fn reduce_xor(self) -> Self::Scalar;
fn swap_bytes(self) -> Self;
fn reverse_bits(self) -> Self;
fn count_ones(self) -> Self;
fn count_zeros(self) -> Self;
fn leading_zeros(self) -> Self;
fn trailing_zeros(self) -> Self;
fn leading_ones(self) -> Self;
fn trailing_ones(self) -> Self;
}
portable_simd
)Expand description
Operations on SIMD vectors of unsigned integers.
Required Associated Types§
sourcetype Scalar
🔬This is a nightly-only experimental API. (portable_simd
)
type Scalar
portable_simd
)Scalar type contained by this SIMD vector type.
sourcetype Cast<T: SimdElement>
🔬This is a nightly-only experimental API. (portable_simd
)
type Cast<T: SimdElement>
portable_simd
)A SIMD vector with a different element type.
Required Methods§
sourcefn cast<T: SimdCast>(self) -> Self::Cast<T>
🔬This is a nightly-only experimental API. (portable_simd
)
fn cast<T: SimdCast>(self) -> Self::Cast<T>
portable_simd
)Performs elementwise conversion of this vector’s elements to another SIMD-valid type.
This follows the semantics of Rust’s as
conversion for casting integers (wrapping to
other integer types, and saturating to float types).
sourcefn wrapping_neg(self) -> Self
🔬This is a nightly-only experimental API. (portable_simd
)
fn wrapping_neg(self) -> Self
portable_simd
)Wrapping negation.
Like u32::wrapping_neg
, all applications of this function will wrap, with the exception
of -0
.
sourcefn saturating_add(self, second: Self) -> Self
🔬This is a nightly-only experimental API. (portable_simd
)
fn saturating_add(self, second: Self) -> Self
portable_simd
)Lanewise saturating add.
§Examples
use core::u32::MAX;
let x = Simd::from_array([2, 1, 0, MAX]);
let max = Simd::splat(MAX);
let unsat = x + max;
let sat = x.saturating_add(max);
assert_eq!(unsat, Simd::from_array([1, 0, MAX, MAX - 1]));
assert_eq!(sat, max);
sourcefn saturating_sub(self, second: Self) -> Self
🔬This is a nightly-only experimental API. (portable_simd
)
fn saturating_sub(self, second: Self) -> Self
portable_simd
)Lanewise saturating subtract.
§Examples
use core::u32::MAX;
let x = Simd::from_array([2, 1, 0, MAX]);
let max = Simd::splat(MAX);
let unsat = x - max;
let sat = x.saturating_sub(max);
assert_eq!(unsat, Simd::from_array([3, 2, 1, 0]));
assert_eq!(sat, Simd::splat(0));
sourcefn abs_diff(self, second: Self) -> Self
🔬This is a nightly-only experimental API. (portable_simd
)
fn abs_diff(self, second: Self) -> Self
portable_simd
)Lanewise absolute difference.
Every element becomes the absolute difference of self
and second
.
§Examples
use core::u32::MAX;
let a = Simd::from_array([0, MAX, 100, 20]);
let b = Simd::from_array([MAX, 0, 80, 200]);
assert_eq!(a.abs_diff(b), Simd::from_array([MAX, MAX, 20, 180]));
sourcefn reduce_sum(self) -> Self::Scalar
🔬This is a nightly-only experimental API. (portable_simd
)
fn reduce_sum(self) -> Self::Scalar
portable_simd
)Returns the sum of the elements of the vector, with wrapping addition.
sourcefn reduce_product(self) -> Self::Scalar
🔬This is a nightly-only experimental API. (portable_simd
)
fn reduce_product(self) -> Self::Scalar
portable_simd
)Returns the product of the elements of the vector, with wrapping multiplication.
sourcefn reduce_max(self) -> Self::Scalar
🔬This is a nightly-only experimental API. (portable_simd
)
fn reduce_max(self) -> Self::Scalar
portable_simd
)Returns the maximum element in the vector.
sourcefn reduce_min(self) -> Self::Scalar
🔬This is a nightly-only experimental API. (portable_simd
)
fn reduce_min(self) -> Self::Scalar
portable_simd
)Returns the minimum element in the vector.
sourcefn reduce_and(self) -> Self::Scalar
🔬This is a nightly-only experimental API. (portable_simd
)
fn reduce_and(self) -> Self::Scalar
portable_simd
)Returns the cumulative bitwise “and” across the elements of the vector.
sourcefn reduce_or(self) -> Self::Scalar
🔬This is a nightly-only experimental API. (portable_simd
)
fn reduce_or(self) -> Self::Scalar
portable_simd
)Returns the cumulative bitwise “or” across the elements of the vector.
sourcefn reduce_xor(self) -> Self::Scalar
🔬This is a nightly-only experimental API. (portable_simd
)
fn reduce_xor(self) -> Self::Scalar
portable_simd
)Returns the cumulative bitwise “xor” across the elements of the vector.
sourcefn swap_bytes(self) -> Self
🔬This is a nightly-only experimental API. (portable_simd
)
fn swap_bytes(self) -> Self
portable_simd
)Reverses the byte order of each element.
sourcefn reverse_bits(self) -> Self
🔬This is a nightly-only experimental API. (portable_simd
)
fn reverse_bits(self) -> Self
portable_simd
)Reverses the order of bits in each elemnent. The least significant bit becomes the most significant bit, second least-significant bit becomes second most-significant bit, etc.
sourcefn count_ones(self) -> Self
🔬This is a nightly-only experimental API. (portable_simd
)
fn count_ones(self) -> Self
portable_simd
)Returns the number of ones in the binary representation of each element.
sourcefn count_zeros(self) -> Self
🔬This is a nightly-only experimental API. (portable_simd
)
fn count_zeros(self) -> Self
portable_simd
)Returns the number of zeros in the binary representation of each element.
sourcefn leading_zeros(self) -> Self
🔬This is a nightly-only experimental API. (portable_simd
)
fn leading_zeros(self) -> Self
portable_simd
)Returns the number of leading zeros in the binary representation of each element.
sourcefn trailing_zeros(self) -> Self
🔬This is a nightly-only experimental API. (portable_simd
)
fn trailing_zeros(self) -> Self
portable_simd
)Returns the number of trailing zeros in the binary representation of each element.
sourcefn leading_ones(self) -> Self
🔬This is a nightly-only experimental API. (portable_simd
)
fn leading_ones(self) -> Self
portable_simd
)Returns the number of leading ones in the binary representation of each element.
sourcefn trailing_ones(self) -> Self
🔬This is a nightly-only experimental API. (portable_simd
)
fn trailing_ones(self) -> Self
portable_simd
)Returns the number of trailing ones in the binary representation of each element.