Trait std::simd::SimdUint

source ·
pub trait SimdUint: Copy + Sealed {
    type Scalar;

    // Required methods
    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;
}
🔬This is a nightly-only experimental API. (portable_simd #86656)
Expand description

对无符号整数的 SIMD vectors 的操作。

Required Associated Types§

source

type Scalar

🔬This is a nightly-only experimental API. (portable_simd #86656)

此 SIMD vector 类型包含的标量类型。

Required Methods§

source

fn saturating_add(self, second: Self) -> Self

🔬This is a nightly-only experimental API. (portable_simd #86656)

Lanewise 饱和加法。

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);
Run
source

fn saturating_sub(self, second: Self) -> Self

🔬This is a nightly-only experimental API. (portable_simd #86656)

Lanewise 饱和减法。

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));
Run
source

fn reduce_sum(self) -> Self::Scalar

🔬This is a nightly-only experimental API. (portable_simd #86656)

返回 vector 的 lane 总和,带包装加法。

source

fn reduce_product(self) -> Self::Scalar

🔬This is a nightly-only experimental API. (portable_simd #86656)

返回 vector 的 lane 的乘积,带包装乘法。

source

fn reduce_max(self) -> Self::Scalar

🔬This is a nightly-only experimental API. (portable_simd #86656)

返回 vector 中的最大 lane。

source

fn reduce_min(self) -> Self::Scalar

🔬This is a nightly-only experimental API. (portable_simd #86656)

返回 vector 中的最小 lane。

source

fn reduce_and(self) -> Self::Scalar

🔬This is a nightly-only experimental API. (portable_simd #86656)

返回跨 vector lane 的累积按位与。

source

fn reduce_or(self) -> Self::Scalar

🔬This is a nightly-only experimental API. (portable_simd #86656)

返回跨 vector lane 的累积按位或。

source

fn reduce_xor(self) -> Self::Scalar

🔬This is a nightly-only experimental API. (portable_simd #86656)

返回跨 vector lane 的累积按位异或。

Implementors§

source§

impl<const LANES: usize> SimdUint for Simd<u8, LANES>where LaneCount<LANES>: SupportedLaneCount,

§

type Scalar = u8

source§

impl<const LANES: usize> SimdUint for Simd<u16, LANES>where LaneCount<LANES>: SupportedLaneCount,

§

type Scalar = u16

source§

impl<const LANES: usize> SimdUint for Simd<u32, LANES>where LaneCount<LANES>: SupportedLaneCount,

§

type Scalar = u32

source§

impl<const LANES: usize> SimdUint for Simd<u64, LANES>where LaneCount<LANES>: SupportedLaneCount,

§

type Scalar = u64

source§

impl<const LANES: usize> SimdUint for Simd<usize, LANES>where LaneCount<LANES>: SupportedLaneCount,