pub trait SimdFloat<S: Simd>:
SimdBase<S>
+ Neg<Output = Self>
+ Add<Output = Self>
+ AddAssign
+ Add<Self::Element, Output = Self>
+ AddAssign<Self::Element>
+ Sub<Output = Self>
+ SubAssign
+ Sub<Self::Element, Output = Self>
+ SubAssign<Self::Element>
+ Mul<Output = Self>
+ MulAssign
+ Mul<Self::Element, Output = Self>
+ MulAssign<Self::Element>
+ Div<Output = Self>
+ DivAssign
+ Div<Self::Element, Output = Self>
+ DivAssign<Self::Element> {
Show 27 methods
// Required methods
fn abs(self) -> Self;
fn sqrt(self) -> Self;
fn copysign(self, rhs: impl SimdInto<Self, S>) -> Self;
fn simd_eq(self, rhs: impl SimdInto<Self, S>) -> Self::Mask;
fn simd_lt(self, rhs: impl SimdInto<Self, S>) -> Self::Mask;
fn simd_le(self, rhs: impl SimdInto<Self, S>) -> Self::Mask;
fn simd_ge(self, rhs: impl SimdInto<Self, S>) -> Self::Mask;
fn simd_gt(self, rhs: impl SimdInto<Self, S>) -> Self::Mask;
fn zip_low(self, rhs: impl SimdInto<Self, S>) -> Self;
fn zip_high(self, rhs: impl SimdInto<Self, S>) -> Self;
fn unzip_low(self, rhs: impl SimdInto<Self, S>) -> Self;
fn unzip_high(self, rhs: impl SimdInto<Self, S>) -> Self;
fn interleave(self, rhs: impl SimdInto<Self, S>) -> (Self, Self);
fn deinterleave(self, rhs: impl SimdInto<Self, S>) -> (Self, Self);
fn max(self, rhs: impl SimdInto<Self, S>) -> Self;
fn min(self, rhs: impl SimdInto<Self, S>) -> Self;
fn max_precise(self, rhs: impl SimdInto<Self, S>) -> Self;
fn min_precise(self, rhs: impl SimdInto<Self, S>) -> Self;
fn mul_add(
self,
op1: impl SimdInto<Self, S>,
op2: impl SimdInto<Self, S>,
) -> Self;
fn mul_sub(
self,
op1: impl SimdInto<Self, S>,
op2: impl SimdInto<Self, S>,
) -> Self;
fn floor(self) -> Self;
fn ceil(self) -> Self;
fn round_ties_even(self) -> Self;
fn fract(self) -> Self;
fn trunc(self) -> Self;
// Provided methods
fn to_int<T: SimdCvtTruncate<Self>>(self) -> T { ... }
fn to_int_precise<T: SimdCvtTruncate<Self>>(self) -> T { ... }
}Expand description
Functionality implemented by floating-point SIMD vectors.
Required Methods§
Sourcefn sqrt(self) -> Self
fn sqrt(self) -> Self
Compute the square root of each element.
Negative elements other than -0.0 will become NaN.
Sourcefn copysign(self, rhs: impl SimdInto<Self, S>) -> Self
fn copysign(self, rhs: impl SimdInto<Self, S>) -> Self
Return a vector with the magnitude of self and the sign of rhs for each element.
This operation copies the sign bit, so if an input element is NaN, the output element will be a NaN with the same payload and a copied sign bit.
Sourcefn simd_eq(self, rhs: impl SimdInto<Self, S>) -> Self::Mask
fn simd_eq(self, rhs: impl SimdInto<Self, S>) -> Self::Mask
Compare two vectors element-wise for equality.
Returns a mask where each element is all ones if the corresponding elements are equal, and all zeroes if not.
Sourcefn simd_lt(self, rhs: impl SimdInto<Self, S>) -> Self::Mask
fn simd_lt(self, rhs: impl SimdInto<Self, S>) -> Self::Mask
Compare two vectors element-wise for less than.
Returns a mask where each element is all ones if self is less than rhs, and all zeroes if not.
Sourcefn simd_le(self, rhs: impl SimdInto<Self, S>) -> Self::Mask
fn simd_le(self, rhs: impl SimdInto<Self, S>) -> Self::Mask
Compare two vectors element-wise for less than or equal.
Returns a mask where each element is all ones if self is less than or equal to rhs, and all zeroes if not.
Sourcefn simd_ge(self, rhs: impl SimdInto<Self, S>) -> Self::Mask
fn simd_ge(self, rhs: impl SimdInto<Self, S>) -> Self::Mask
Compare two vectors element-wise for greater than or equal.
Returns a mask where each element is all ones if self is greater than or equal to rhs, and all zeroes if not.
Sourcefn simd_gt(self, rhs: impl SimdInto<Self, S>) -> Self::Mask
fn simd_gt(self, rhs: impl SimdInto<Self, S>) -> Self::Mask
Compare two vectors element-wise for greater than.
Returns a mask where each element is all ones if self is greater than rhs, and all zeroes if not.
Sourcefn zip_low(self, rhs: impl SimdInto<Self, S>) -> Self
fn zip_low(self, rhs: impl SimdInto<Self, S>) -> Self
Interleave the lower half elements of two vectors.
For vectors [a0, a1, a2, a3] and [b0, b1, b2, b3], returns [a0, b0, a1, b1].
Note: This operation is only useful if you need to discard elements a2, a3, b2, b3.
For fully interleaving two vectors prefer interleave,
which is faster than zip_low followed by zip_high on some platforms.
Sourcefn zip_high(self, rhs: impl SimdInto<Self, S>) -> Self
fn zip_high(self, rhs: impl SimdInto<Self, S>) -> Self
Interleave the upper half elements of two vectors.
For vectors [a0, a1, a2, a3] and [b0, b1, b2, b3], returns [a2, b2, a3, b3].
Note: This operation is only useful if you need to discard elements a0, a1, b0, b1.For fully interleaving two vectors prefer interleave,
which is faster than zip_low followed by zip_high on some platforms.
Sourcefn unzip_low(self, rhs: impl SimdInto<Self, S>) -> Self
fn unzip_low(self, rhs: impl SimdInto<Self, S>) -> Self
Extract even-indexed elements from two vectors.
For vectors [a0, a1, a2, a3] and [b0, b1, b2, b3], returns [a0, a2, b0, b2].
Note: This operation is only useful if you need to discard elements a1, a3, b1, b3.For fully deinterleaving two vectors prefer deinterleave,
which is faster than unzip_low followed by unzip_high on some platforms.
Sourcefn unzip_high(self, rhs: impl SimdInto<Self, S>) -> Self
fn unzip_high(self, rhs: impl SimdInto<Self, S>) -> Self
Extract odd-indexed elements from two vectors.
For vectors [a0, a1, a2, a3] and [b0, b1, b2, b3], returns [a1, a3, b1, b3].
Note: This operation is only useful if you need to discard elements a0, a2, b0, b2.For fully deinterleaving two vectors prefer deinterleave,
which is faster than unzip_low followed by unzip_high on some platforms.
Sourcefn interleave(self, rhs: impl SimdInto<Self, S>) -> (Self, Self)
fn interleave(self, rhs: impl SimdInto<Self, S>) -> (Self, Self)
Interleave two vectors.
The resulting vectors contain elements taken alternately from self and rhs, first filling the first result, and then the second.
The reverse of this operation is deinterleave.
For vectors [a0, a1, a2, a3] and [b0, b1, b2, b3], returns ([a0, b0, a1, b1], [a2, b2, a3, b3]).
Sourcefn deinterleave(self, rhs: impl SimdInto<Self, S>) -> (Self, Self)
fn deinterleave(self, rhs: impl SimdInto<Self, S>) -> (Self, Self)
Deinterleave two vectors.
The first result contains all even-indexed elements from self followed by all even-indexed elements from rhs. The second result contains all odd-indexed elements from self followed by all odd-indexed elements from rhs.
The reverse of this operation is interleave.
For vectors [a0, b0, a1, b1] and [a2, b2, a3, b3], returns ([a0, a1, a2, a3], [b0, b1, b2, b3]).
Sourcefn max(self, rhs: impl SimdInto<Self, S>) -> Self
fn max(self, rhs: impl SimdInto<Self, S>) -> Self
Return the element-wise maximum of two vectors.
If either operand is NaN, the result for that lane is implementation-defined– it could be either the first or second operand. See max_precise for a version that returns the non-NaN operand if only one is NaN.
If one operand is positive zero and the other is negative zero, the result is also implementation-defined, and it could be either one.
Sourcefn min(self, rhs: impl SimdInto<Self, S>) -> Self
fn min(self, rhs: impl SimdInto<Self, S>) -> Self
Return the element-wise minimum of two vectors.
If either operand is NaN, the result for that lane is implementation-defined– it could be either the first or second operand. See min_precise for a version that returns the non-NaN operand if only one is NaN.
If one operand is positive zero and the other is negative zero, the result is also implementation-defined, and it could be either one.
Sourcefn max_precise(self, rhs: impl SimdInto<Self, S>) -> Self
fn max_precise(self, rhs: impl SimdInto<Self, S>) -> Self
Return the element-wise maximum of two vectors.
If one operand is a quiet NaN and the other is not, this operation will choose the non-NaN operand.
If one operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.
If an operand is a signaling NaN, the result is not just implementation-defined, but fully non-deterministic: it may be either NaN or the non-NaN operand. Signaling NaN values are not produced by floating-point math operations, only from manual initialization with specific bit patterns. You probably don’t need to worry about them.
Sourcefn min_precise(self, rhs: impl SimdInto<Self, S>) -> Self
fn min_precise(self, rhs: impl SimdInto<Self, S>) -> Self
Return the element-wise minimum of two vectors.
If one operand is a quiet NaN and the other is not, this operation will choose the non-NaN operand.
If one operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.
If an operand is a signaling NaN, the result is not just implementation-defined, but fully non-deterministic: it may be either NaN or the non-NaN operand. Signaling NaN values are not produced by floating-point math operations, only from manual initialization with specific bit patterns. You probably don’t need to worry about them.
Sourcefn mul_add(
self,
op1: impl SimdInto<Self, S>,
op2: impl SimdInto<Self, S>,
) -> Self
fn mul_add( self, op1: impl SimdInto<Self, S>, op2: impl SimdInto<Self, S>, ) -> Self
Compute (self * op1) + op2 (fused multiply-add) for each element.
Depending on hardware support, the result may be computed with only one rounding error, or may be implemented as a regular multiply followed by an add, which will result in two rounding errors.
Sourcefn mul_sub(
self,
op1: impl SimdInto<Self, S>,
op2: impl SimdInto<Self, S>,
) -> Self
fn mul_sub( self, op1: impl SimdInto<Self, S>, op2: impl SimdInto<Self, S>, ) -> Self
Compute (self * op1) - op2 (fused multiply-subtract) for each element.
Depending on hardware support, the result may be computed with only one rounding error, or may be implemented as a regular multiply followed by a subtract, which will result in two rounding errors.
Sourcefn floor(self) -> Self
fn floor(self) -> Self
Return the largest integer less than or equal to each element, that is, round towards negative infinity.
Sourcefn ceil(self) -> Self
fn ceil(self) -> Self
Return the smallest integer greater than or equal to each element, that is, round towards positive infinity.
Sourcefn round_ties_even(self) -> Self
fn round_ties_even(self) -> Self
Round each element to the nearest integer, with ties rounding to the nearest even integer.
There is no corresponding round operation. Rust’s round operation rounds ties away from zero, a behavior it inherited from C. That behavior is not implemented across all platforms, whereas round-ties-even is.
Provided Methods§
Sourcefn to_int<T: SimdCvtTruncate<Self>>(self) -> T
fn to_int<T: SimdCvtTruncate<Self>>(self) -> T
Convert this floating-point type to an integer. This is a convenience method that
delegates to SimdCvtTruncate::truncate_from, and can only be called if there
actually exists a target type of the same bit width (currently, only u32 and
i32).
For more information about the semantics of this specific conversion, see the
concrete SimdCvtTruncate implementations for integer types.
Sourcefn to_int_precise<T: SimdCvtTruncate<Self>>(self) -> T
fn to_int_precise<T: SimdCvtTruncate<Self>>(self) -> T
Convert this floating-point type to an integer, saturating on overflow and returning
0 for NaN. This is a convenience method that delegates to
SimdCvtTruncate::truncate_from_precise, and can only be called if there actually
exists a target type of the same bit width (currently, only u32 and i32).
For more information about the semantics of this specific conversion, see the
concrete SimdCvtTruncate implementations for integer types.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.