pub trait SimdFloat:Copy + Sealed { typeMask; typeScalar; typeBits; typeCast<T:SimdElement>;Show 24 methods
// Required methods fncast<T>(self) -> Self::Cast<T>where T:SimdCast; unsafe fnto_int_unchecked<I>(self) -> Self::Cast<I>where I:SimdCast, Self::Scalar:FloatToInt<I>; fnto_bits(self) -> Self::Bits; fnfrom_bits(bits: Self::Bits) -> Self; fnabs(self) -> Self; fnrecip(self) -> Self; fnto_degrees(self) -> Self; fnto_radians(self) -> Self; fnis_sign_positive(self) -> Self::Mask; fnis_sign_negative(self) -> Self::Mask; fnis_nan(self) -> Self::Mask; fnis_infinite(self) -> Self::Mask; fnis_finite(self) -> Self::Mask; fnis_subnormal(self) -> Self::Mask; fnis_normal(self) -> Self::Mask; fnsignum(self) -> Self; fncopysign(self, sign: Self) -> Self; fnsimd_min(self, other: Self) -> Self; fnsimd_max(self, other: Self) -> Self; fnsimd_clamp(self, min: Self, max: Self) -> Self; fnreduce_sum(self) -> Self::Scalar; fnreduce_product(self) -> Self::Scalar; fnreduce_max(self) -> Self::Scalar; fnreduce_min(self) -> Self::Scalar;}portable_simd #86656)Expand description
Operations on SIMD vectors of floats.
Required Associated Types§
SourcetypeMask
🔬This is a nightly-only experimental API. (portable_simd #86656)
typeMask
portable_simd #86656)Mask type used for manipulating this SIMD vector type.
SourcetypeScalar
🔬This is a nightly-only experimental API. (portable_simd #86656)
typeScalar
portable_simd #86656)Scalar type contained by this SIMD vector type.
SourcetypeBits
🔬This is a nightly-only experimental API. (portable_simd #86656)
typeBits
portable_simd #86656)Bit representation of this SIMD vector type.
SourcetypeCast<T:SimdElement>
🔬This is a nightly-only experimental API. (portable_simd #86656)
typeCast<T:SimdElement>
portable_simd #86656)A SIMD vector with a different element type.
Required Methods§
Sourcefncast<T>(self) -> Self::Cast<T>where T:SimdCast,
🔬This is a nightly-only experimental API. (portable_simd #86656)
fncast<T>(self) -> Self::Cast<T>where T:SimdCast,
portable_simd #86656)Performs elementwise conversion of this vector’s elements to another SIMD-valid type.
This follows the semantics of Rust’sas conversion for floats (truncating or saturatingat the limits) for each element.
§Example
letfloats: Simd<f32,4> = Simd::from_array([1.9, -4.5, f32::INFINITY, f32::NAN]);letints = floats.cast::<i32>();assert_eq!(ints, Simd::from_array([1, -4, i32::MAX,0]));// Formally equivalent, but `Simd::cast` can optimize better.assert_eq!(ints, Simd::from_array(floats.to_array().map(|x| xasi32)));// The float conversion does not round-trip.letfloats_again = ints.cast();assert_ne!(floats, floats_again);assert_eq!(floats_again, Simd::from_array([1.0, -4.0,2147483647.0,0.0]));Sourceunsafe fnto_int_unchecked<I>(self) -> Self::Cast<I>
🔬This is a nightly-only experimental API. (portable_simd #86656)
unsafe fnto_int_unchecked<I>(self) -> Self::Cast<I>
portable_simd #86656)Rounds toward zero and converts to the same-width integer type, assuming thatthe value is finite and fits in that type.
§Safety
The value must:
- Not be NaN
- Not be infinite
- Be representable in the return type, after truncating off its fractional part
If these requirements are infeasible or costly, consider using the safe functioncast,which saturates on conversion.
Sourcefnto_bits(self) -> Self::Bits
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnto_bits(self) -> Self::Bits
portable_simd #86656)Raw transmutation to an unsigned integer vector type with thesame size and number of elements.
Sourcefnfrom_bits(bits: Self::Bits) -> Self
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnfrom_bits(bits: Self::Bits) -> Self
portable_simd #86656)Raw transmutation from an unsigned integer vector type with thesame size and number of elements.
Sourcefnabs(self) -> Self
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnabs(self) -> Self
portable_simd #86656)Produces a vector where every element has the absolute value of theequivalently-indexed element inself.
Sourcefnrecip(self) -> Self
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnrecip(self) -> Self
portable_simd #86656)Takes the reciprocal (inverse) of each element,1/x.
Sourcefnto_degrees(self) -> Self
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnto_degrees(self) -> Self
portable_simd #86656)Converts each element from radians to degrees.
Sourcefnto_radians(self) -> Self
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnto_radians(self) -> Self
portable_simd #86656)Converts each element from degrees to radians.
Sourcefnis_sign_positive(self) -> Self::Mask
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnis_sign_positive(self) -> Self::Mask
portable_simd #86656)Returns true for each element if it has a positive sign, including+0.0,NaNs with positive sign bit and positive infinity.
Sourcefnis_sign_negative(self) -> Self::Mask
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnis_sign_negative(self) -> Self::Mask
portable_simd #86656)Returns true for each element if it has a negative sign, including-0.0,NaNs with negative sign bit and negative infinity.
Sourcefnis_nan(self) -> Self::Mask
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnis_nan(self) -> Self::Mask
portable_simd #86656)Returns true for each element if its value isNaN.
Sourcefnis_infinite(self) -> Self::Mask
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnis_infinite(self) -> Self::Mask
portable_simd #86656)Returns true for each element if its value is positive infinity or negative infinity.
Sourcefnis_finite(self) -> Self::Mask
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnis_finite(self) -> Self::Mask
portable_simd #86656)Returns true for each element if its value is neither infinite norNaN.
Sourcefnis_subnormal(self) -> Self::Mask
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnis_subnormal(self) -> Self::Mask
portable_simd #86656)Returns true for each element if its value is subnormal.
Sourcefnis_normal(self) -> Self::Mask
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnis_normal(self) -> Self::Mask
portable_simd #86656)Returns true for each element if its value is neither zero, infinite,subnormal, norNaN.
Sourcefnsignum(self) -> Self
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnsignum(self) -> Self
portable_simd #86656)Replaces each element with a number that represents its sign.
1.0if the number is positive,+0.0, orINFINITY-1.0if the number is negative,-0.0, orNEG_INFINITYNANif the number isNAN
Sourcefncopysign(self, sign: Self) -> Self
🔬This is a nightly-only experimental API. (portable_simd #86656)
fncopysign(self, sign: Self) -> Self
portable_simd #86656)Returns each element with the magnitude ofself and the sign ofsign.
For any element containing aNAN, aNAN with the sign ofsign is returned.
Sourcefnsimd_min(self, other: Self) -> Self
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnsimd_min(self, other: Self) -> Self
portable_simd #86656)Returns the minimum of each element.
If one of the values isNAN, then the other value is returned.
Sourcefnsimd_max(self, other: Self) -> Self
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnsimd_max(self, other: Self) -> Self
portable_simd #86656)Returns the maximum of each element.
If one of the values isNAN, then the other value is returned.
Sourcefnsimd_clamp(self, min: Self, max: Self) -> Self
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnsimd_clamp(self, min: Self, max: Self) -> Self
portable_simd #86656)Restrict each element to a certain interval unless it is NaN.
For each element inself, returns the corresponding element inmax if the element isgreater thanmax, and the corresponding element inmin if the element is lessthanmin. Otherwise returns the element inself.
Sourcefnreduce_sum(self) -> Self::Scalar
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnreduce_sum(self) -> Self::Scalar
portable_simd #86656)Returns the sum of the elements of the vector.
§Examples
Sourcefnreduce_product(self) -> Self::Scalar
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnreduce_product(self) -> Self::Scalar
portable_simd #86656)Reducing multiply. Returns the product of the elements of the vector.
§Examples
Sourcefnreduce_max(self) -> Self::Scalar
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnreduce_max(self) -> Self::Scalar
portable_simd #86656)Returns the maximum element in the vector.
Returns values based on equality, so a vector containing both0. and-0. mayreturn either.
This function will not returnNaN unless all elements areNaN.
§Examples
Sourcefnreduce_min(self) -> Self::Scalar
🔬This is a nightly-only experimental API. (portable_simd #86656)
fnreduce_min(self) -> Self::Scalar
portable_simd #86656)Returns the minimum element in the vector.
Returns values based on equality, so a vector containing both0. and-0. mayreturn either.
This function will not returnNaN unless all elements areNaN.
§Examples
Dyn Compatibility§
This trait isnotdyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.