Skip to main content

NumOps

Trait NumOps 

Source
pub unsafe trait NumOps<T: Elem>: BitOps<T> {
Show 15 methods // Required methods fn add(self, x: Self::Simd, y: Self::Simd) -> Self::Simd; fn sub(self, x: Self::Simd, y: Self::Simd) -> Self::Simd; fn mul(self, x: Self::Simd, y: Self::Simd) -> Self::Simd; fn eq(self, x: Self::Simd, y: Self::Simd) -> <Self::Simd as Simd>::Mask; fn ge(self, x: Self::Simd, y: Self::Simd) -> <Self::Simd as Simd>::Mask; fn gt(self, x: Self::Simd, y: Self::Simd) -> <Self::Simd as Simd>::Mask; // Provided methods fn one(self) -> Self::Simd { ... } fn mul_add(self, a: Self::Simd, b: Self::Simd, c: Self::Simd) -> Self::Simd { ... } fn poly_eval(self, x: Self::Simd, coeffs: &[Self::Simd]) -> Self::Simd { ... } fn lt(self, x: Self::Simd, y: Self::Simd) -> <Self::Simd as Simd>::Mask { ... } fn le(self, x: Self::Simd, y: Self::Simd) -> <Self::Simd as Simd>::Mask { ... } fn min(self, x: Self::Simd, y: Self::Simd) -> Self::Simd { ... } fn max(self, x: Self::Simd, y: Self::Simd) -> Self::Simd { ... } fn clamp( self, x: Self::Simd, min: Self::Simd, max: Self::Simd, ) -> Self::Simd { ... } fn sum(self, x: Self::Simd) -> T { ... }
}
Expand description

Arithmetic operations available on all numeric SIMD vector types.

This trait extends BitOps with operations which interpret the bits of a SIMD vector as numbers of type T:

  • Add, subtract and multiply
  • Comparison (equality, less than, greater than etc.)

§Safety

Implementations must ensure they can only be constructed if the instruction set is supported on the current system.

Required Methods§

Source

fn add(self, x: Self::Simd, y: Self::Simd) -> Self::Simd

Compute x + y.

Source

fn sub(self, x: Self::Simd, y: Self::Simd) -> Self::Simd

Compute x - y.

Source

fn mul(self, x: Self::Simd, y: Self::Simd) -> Self::Simd

Compute x * y.

Source

fn eq(self, x: Self::Simd, y: Self::Simd) -> <Self::Simd as Simd>::Mask

Return a mask indicating whether elements in x are equal to y.

Source

fn ge(self, x: Self::Simd, y: Self::Simd) -> <Self::Simd as Simd>::Mask

Return a mask indicating whether elements in x are greater or equal to y.

Source

fn gt(self, x: Self::Simd, y: Self::Simd) -> <Self::Simd as Simd>::Mask

Return a mask indicating whether elements in x are greater than y.

Provided Methods§

Source

fn one(self) -> Self::Simd

Create a new vector with all lanes set to one.

Source

fn mul_add(self, a: Self::Simd, b: Self::Simd, c: Self::Simd) -> Self::Simd

Compute a * b + c.

This will use fused multiply-add instructions if available. For float element types, this may use one or two roundings.

Source

fn poly_eval(self, x: Self::Simd, coeffs: &[Self::Simd]) -> Self::Simd

Evaluate a polynomial using Horner’s method.

Computes x * coeffs[0] + x^2 * coeffs[1] ... x^n * coeffs[N]

Source

fn lt(self, x: Self::Simd, y: Self::Simd) -> <Self::Simd as Simd>::Mask

Return a mask indicating whether elements in x are less than y.

Source

fn le(self, x: Self::Simd, y: Self::Simd) -> <Self::Simd as Simd>::Mask

Return a mask indicating whether elements in x are less or equal to y.

Source

fn min(self, x: Self::Simd, y: Self::Simd) -> Self::Simd

Return the minimum of x and y for each lane.

Source

fn max(self, x: Self::Simd, y: Self::Simd) -> Self::Simd

Return the maximum of x and y for each lane.

Source

fn clamp(self, x: Self::Simd, min: Self::Simd, max: Self::Simd) -> Self::Simd

Clamp values in x to minimum and maximum values from corresponding lanes in min and max.

Source

fn sum(self, x: Self::Simd) -> T

Horizontally sum the elements in a vector.

If the sum overflows, it will wrap. This choice was made to enable consistency between native intrinsics for horizontal addition and the generic implementation.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§