Trait SimdInt
pub trait SimdInt: Copy
Operations on SIMD vectors of signed integers.
Associated Types
type Mask;Mask type used for manipulating this SIMD vector type.
type Scalar;Scalar type contained by this SIMD vector type.
type Unsigned;A SIMD vector of unsigned integers with the same element size.
type Cast<T: SimdElement>;A SIMD vector with a different element type.
Required Methods
fn cast<T: SimdCast>(self) -> Self::Cast<T>Performs elementwise conversion of this vector's elements to another SIMD-valid type.
This follows the semantics of Rust's
asconversion for casting integers (wrapping to other integer types, and saturating to float types).fn saturating_add(self, second: Self) -> SelfLanewise saturating add.
Examples
# # use simd; # use simd; # use *; use ; let x = from_array; let max = splat; let unsat = x + max; let sat = x.saturating_add; assert_eq!; assert_eq!;fn saturating_sub(self, second: Self) -> SelfLanewise saturating subtract.
Examples
# # use simd; # use simd; # use *; use ; let x = from_array; let max = splat; let unsat = x - max; let sat = x.saturating_sub; assert_eq!; assert_eq!;fn abs(self) -> SelfLanewise absolute value, implemented in Rust. Every element becomes its absolute value.
Examples
# # use simd; # use simd; # use *; use ; let xs = from_array; assert_eq!;fn abs_diff(self, second: Self) -> Self::UnsignedLanewise absolute difference. Every element becomes the absolute difference of
selfandsecond.Examples
# # use simd; # use simd; # use *; use ; let a = from_array; let b = from_array; assert_eq!;fn saturating_abs(self) -> SelfLanewise saturating absolute value, implemented in Rust. As abs(), except the MIN value becomes MAX instead of itself.
Examples
# # use simd; # use simd; # use *; use ; let xs = from_array; let unsat = xs.abs; let sat = xs.saturating_abs; assert_eq!; assert_eq!;fn saturating_neg(self) -> SelfLanewise saturating negation, implemented in Rust. As neg(), except the MIN value becomes MAX instead of itself.
Examples
# # use simd; # use simd; # use *; use ; let x = from_array; let unsat = -x; let sat = x.saturating_neg; assert_eq!; assert_eq!;fn is_positive(self) -> Self::MaskReturns true for each positive element and false if it is zero or negative.
fn is_negative(self) -> Self::MaskReturns true for each negative element and false if it is zero or positive.
fn signum(self) -> SelfReturns numbers representing the sign of each element.
0if the number is zero1if the number is positive-1if the number is negative
fn reduce_sum(self) -> Self::ScalarReturns the sum of the elements of the vector, with wrapping addition.
Examples
# # use simd; # use simd; # use *; let v = from_array; assert_eq!; // SIMD integer addition is always wrapping let v = from_array; assert_eq!;fn reduce_product(self) -> Self::ScalarReturns the product of the elements of the vector, with wrapping multiplication.
Examples
# # use simd; # use simd; # use *; let v = from_array; assert_eq!; // SIMD integer multiplication is always wrapping let v = from_array; assert!;fn reduce_max(self) -> Self::ScalarReturns the maximum element in the vector.
Examples
# # use simd; # use simd; # use *; let v = from_array; assert_eq!;fn reduce_min(self) -> Self::ScalarReturns the minimum element in the vector.
Examples
# # use simd; # use simd; # use *; let v = from_array; assert_eq!;fn reduce_and(self) -> Self::ScalarReturns the cumulative bitwise "and" across the elements of the vector.
fn reduce_or(self) -> Self::ScalarReturns the cumulative bitwise "or" across the elements of the vector.
fn reduce_xor(self) -> Self::ScalarReturns the cumulative bitwise "xor" across the elements of the vector.
fn swap_bytes(self) -> SelfReverses the byte order of each element.
fn reverse_bits(self) -> SelfReverses 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.
fn count_ones(self) -> Self::UnsignedReturns the number of ones in the binary representation of each element.
fn count_zeros(self) -> Self::UnsignedReturns the number of zeros in the binary representation of each element.
fn leading_zeros(self) -> Self::UnsignedReturns the number of leading zeros in the binary representation of each element.
fn trailing_zeros(self) -> Self::UnsignedReturns the number of trailing zeros in the binary representation of each element.
fn leading_ones(self) -> Self::UnsignedReturns the number of leading ones in the binary representation of each element.
fn trailing_ones(self) -> Self::UnsignedReturns the number of trailing ones in the binary representation of each element.