Skip to main content

ElementOp

Trait ElementOp 

Source
pub trait ElementOp<T: Scalar>:
    Sealed
    + Copy
    + 'static {
    // Required methods
    unsafe fn apply<Arch: SimdKernel<T>>(
        self,
        a: Arch::Vector,
        b: Arch::Vector,
    ) -> Arch::Vector;
    fn apply_scalar(self, a: T, b: T) -> T;
}
Expand description

Sealed ZST trait for pairwise SIMD elementwise operations.

Used by zip_reduce, zip_cow, and transform_in_place to parameterize binary vector operations without code duplication.

§Scalar Tail

apply_scalar(a, b) handles elements that do not fill a complete SIMD vector. Implementations use direct T: Scalar arithmetic so no vector load/store boundary conditions apply. The default does NOT exist — every impl must provide both apply (vector) and apply_scalar (scalar element).

Required Methods§

Source

unsafe fn apply<Arch: SimdKernel<T>>( self, a: Arch::Vector, b: Arch::Vector, ) -> Arch::Vector

Apply the operation to two vectors lane-wise.

Takes self by value — for ZSTs this is free; for Clamp it captures the bounds.

§Safety

Processor must support the target feature of Arch.

Source

fn apply_scalar(self, a: T, b: T) -> T

Apply the operation to two individual scalar elements.

Used for the SIMD tail (elements that do not fill a complete vector). Takes self by value — for ZSTs this is free; for Clamp it captures the bounds.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T: Scalar + Copy> ElementOp<T> for Clamp<T>

Source§

impl<T: Scalar> ElementOp<T> for Add

Source§

impl<T: Scalar> ElementOp<T> for BitAnd

Source§

impl<T: Scalar> ElementOp<T> for BitOr

Source§

impl<T: Scalar> ElementOp<T> for BitXor

Source§

impl<T: Scalar> ElementOp<T> for Div

Source§

impl<T: Scalar> ElementOp<T> for FmaAdd

Source§

impl<T: Scalar> ElementOp<T> for Mul

Source§

impl<T: Scalar> ElementOp<T> for Sub