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§
Sourcefn eq(self, x: Self::Simd, y: Self::Simd) -> <Self::Simd as Simd>::Mask
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.
Provided Methods§
Sourcefn mul_add(self, a: Self::Simd, b: Self::Simd, c: Self::Simd) -> Self::Simd
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.
Sourcefn poly_eval(self, x: Self::Simd, coeffs: &[Self::Simd]) -> Self::Simd
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]
Sourcefn lt(self, x: Self::Simd, y: Self::Simd) -> <Self::Simd as Simd>::Mask
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.
Sourcefn le(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
Return a mask indicating whether elements in x are less or equal to y.
Sourcefn min(self, x: Self::Simd, y: Self::Simd) -> Self::Simd
fn min(self, x: Self::Simd, y: Self::Simd) -> Self::Simd
Return the minimum of x and y for each lane.
Sourcefn max(self, x: Self::Simd, y: Self::Simd) -> Self::Simd
fn max(self, x: Self::Simd, y: Self::Simd) -> Self::Simd
Return the maximum of x and y for each lane.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".