On this page
Trait std::simd::SimdUint
pub trait SimdUint: Copy + Sealed {
type Scalar;
type Cast<T: SimdElement>;
// Required methods
fn cast<T>(self) -> Self::Cast<T>
where T: SimdCast;
fn saturating_add(self, second: Self) -> Self;
fn saturating_sub(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;
}
portable_simd
#86656)
Operations on SIMD vectors of unsigned integers.
Required Associated Types
type Scalar
portable_simd
#86656)
Scalar type contained by this SIMD vector type.
type Cast<T: SimdElement>
portable_simd
#86656)
A SIMD vector with a different element type.
Required Methods
fn cast<T>(self) -> Self::Cast<T>
where
T: SimdCast,
portable_simd
#86656)
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).
fn saturating_add(self, second: Self) -> Self
portable_simd
#86656)
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);
fn saturating_sub(self, second: Self) -> Self
portable_simd
#86656)
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));
fn reduce_sum(self) -> Self::Scalar
portable_simd
#86656)
Returns the sum of the lanes of the vector, with wrapping addition.
fn reduce_product(self) -> Self::Scalar
portable_simd
#86656)
Returns the product of the lanes of the vector, with wrapping multiplication.
fn reduce_max(self) -> Self::Scalar
portable_simd
#86656)
Returns the maximum lane in the vector.
fn reduce_min(self) -> Self::Scalar
portable_simd
#86656)
Returns the minimum lane in the vector.
fn reduce_and(self) -> Self::Scalar
portable_simd
#86656)
Returns the cumulative bitwise “and” across the lanes of the vector.
fn reduce_or(self) -> Self::Scalar
portable_simd
#86656)
Returns the cumulative bitwise “or” across the lanes of the vector.
fn reduce_xor(self) -> Self::Scalar
portable_simd
#86656)
Returns the cumulative bitwise “xor” across the lanes of the vector.
Object Safety
Implementors
impl<const LANES: usize> SimdUint for Simd<u8, LANES>
where
LaneCount<LANES>: SupportedLaneCount,
type Scalar = u8
type Cast<T: SimdElement> = Simd<T, LANES>
impl<const LANES: usize> SimdUint for Simd<u16, LANES>
where
LaneCount<LANES>: SupportedLaneCount,
type Scalar = u16
type Cast<T: SimdElement> = Simd<T, LANES>
impl<const LANES: usize> SimdUint for Simd<u32, LANES>
where
LaneCount<LANES>: SupportedLaneCount,
type Scalar = u32
type Cast<T: SimdElement> = Simd<T, LANES>
impl<const LANES: usize> SimdUint for Simd<u64, LANES>
where
LaneCount<LANES>: SupportedLaneCount,
type Scalar = u64
type Cast<T: SimdElement> = Simd<T, LANES>
impl<const LANES: usize> SimdUint for Simd<usize, LANES>
where
LaneCount<LANES>: SupportedLaneCount,
type Scalar = usize
type Cast<T: SimdElement> = Simd<T, LANES>
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/simd/trait.SimdUint.html