Trait std::simd::SimdFloat

source ·
pub trait SimdFloat: Copy + Sealed {
    type Mask;
    type Scalar;
    type Bits;

Show 22 methods // Required methods fn to_bits(self) -> Self::Bits; fn from_bits(bits: Self::Bits) -> Self; fn abs(self) -> Self; fn recip(self) -> Self; fn to_degrees(self) -> Self; fn to_radians(self) -> Self; fn is_sign_positive(self) -> Self::Mask; fn is_sign_negative(self) -> Self::Mask; fn is_nan(self) -> Self::Mask; fn is_infinite(self) -> Self::Mask; fn is_finite(self) -> Self::Mask; fn is_subnormal(self) -> Self::Mask; fn is_normal(self) -> Self::Mask; fn signum(self) -> Self; fn copysign(self, sign: Self) -> Self; fn simd_min(self, other: Self) -> Self; fn simd_max(self, other: Self) -> Self; fn simd_clamp(self, min: Self, max: Self) -> Self; fn reduce_sum(self) -> Self::Scalar; fn reduce_product(self) -> Self::Scalar; fn reduce_max(self) -> Self::Scalar; fn reduce_min(self) -> Self::Scalar;
}
🔬This is a nightly-only experimental API. (portable_simd #86656)
Expand description

Operations on SIMD vectors of floats.

Required Associated Types§

source

type Mask

🔬This is a nightly-only experimental API. (portable_simd #86656)

Mask type used for manipulating this SIMD vector type.

source

type Scalar

🔬This is a nightly-only experimental API. (portable_simd #86656)

Scalar type contained by this SIMD vector type.

source

type Bits

🔬This is a nightly-only experimental API. (portable_simd #86656)

Bit representation of this SIMD vector type.

Required Methods§

source

fn to_bits(self) -> Self::Bits

🔬This is a nightly-only experimental API. (portable_simd #86656)

Raw transmutation to an unsigned integer vector type with the same size and number of lanes.

source

fn from_bits(bits: Self::Bits) -> Self

🔬This is a nightly-only experimental API. (portable_simd #86656)

Raw transmutation from an unsigned integer vector type with the same size and number of lanes.

source

fn abs(self) -> Self

🔬This is a nightly-only experimental API. (portable_simd #86656)

Produces a vector where every lane has the absolute value of the equivalently-indexed lane in self.

source

fn recip(self) -> Self

🔬This is a nightly-only experimental API. (portable_simd #86656)

Takes the reciprocal (inverse) of each lane, 1/x.

source

fn to_degrees(self) -> Self

🔬This is a nightly-only experimental API. (portable_simd #86656)

Converts each lane from radians to degrees.

source

fn to_radians(self) -> Self

🔬This is a nightly-only experimental API. (portable_simd #86656)

Converts each lane from degrees to radians.

source

fn is_sign_positive(self) -> Self::Mask

🔬This is a nightly-only experimental API. (portable_simd #86656)

Returns true for each lane if it has a positive sign, including +0.0, NaNs with positive sign bit and positive infinity.

source

fn is_sign_negative(self) -> Self::Mask

🔬This is a nightly-only experimental API. (portable_simd #86656)

Returns true for each lane if it has a negative sign, including -0.0, NaNs with negative sign bit and negative infinity.

source

fn is_nan(self) -> Self::Mask

🔬This is a nightly-only experimental API. (portable_simd #86656)

Returns true for each lane if its value is NaN.

source

fn is_infinite(self) -> Self::Mask

🔬This is a nightly-only experimental API. (portable_simd #86656)

Returns true for each lane if its value is positive infinity or negative infinity.

source

fn is_finite(self) -> Self::Mask

🔬This is a nightly-only experimental API. (portable_simd #86656)

Returns true for each lane if its value is neither infinite nor NaN.

source

fn is_subnormal(self) -> Self::Mask

🔬This is a nightly-only experimental API. (portable_simd #86656)

Returns true for each lane if its value is subnormal.

source

fn is_normal(self) -> Self::Mask

🔬This is a nightly-only experimental API. (portable_simd #86656)

Returns true for each lane if its value is neither zero, infinite, subnormal, nor NaN.

source

fn signum(self) -> Self

🔬This is a nightly-only experimental API. (portable_simd #86656)

Replaces each lane with a number that represents its sign.

  • 1.0 if the number is positive, +0.0, or INFINITY
  • -1.0 if the number is negative, -0.0, or NEG_INFINITY
  • NAN if the number is NAN
source

fn copysign(self, sign: Self) -> Self

🔬This is a nightly-only experimental API. (portable_simd #86656)

Returns each lane with the magnitude of self and the sign of sign.

For any lane containing a NAN, a NAN with the sign of sign is returned.

source

fn simd_min(self, other: Self) -> Self

🔬This is a nightly-only experimental API. (portable_simd #86656)

Returns the minimum of each lane.

If one of the values is NAN, then the other value is returned.

source

fn simd_max(self, other: Self) -> Self

🔬This is a nightly-only experimental API. (portable_simd #86656)

Returns the maximum of each lane.

If one of the values is NAN, then the other value is returned.

source

fn simd_clamp(self, min: Self, max: Self) -> Self

🔬This is a nightly-only experimental API. (portable_simd #86656)

Restrict each lane to a certain interval unless it is NaN.

For each lane in self, returns the corresponding lane in max if the lane is greater than max, and the corresponding lane in min if the lane is less than min. Otherwise returns the lane in self.

source

fn reduce_sum(self) -> Self::Scalar

🔬This is a nightly-only experimental API. (portable_simd #86656)

Returns the sum of the lanes of the vector.

Examples
let v = f32x2::from_array([1., 2.]);
assert_eq!(v.reduce_sum(), 3.);
Run
source

fn reduce_product(self) -> Self::Scalar

🔬This is a nightly-only experimental API. (portable_simd #86656)

Reducing multiply. Returns the product of the lanes of the vector.

Examples
let v = f32x2::from_array([3., 4.]);
assert_eq!(v.reduce_product(), 12.);
Run
source

fn reduce_max(self) -> Self::Scalar

🔬This is a nightly-only experimental API. (portable_simd #86656)

Returns the maximum lane in the vector.

Returns values based on equality, so a vector containing both 0. and -0. may return either.

This function will not return NaN unless all lanes are NaN.

Examples
let v = f32x2::from_array([1., 2.]);
assert_eq!(v.reduce_max(), 2.);

// NaN values are skipped...
let v = f32x2::from_array([1., f32::NAN]);
assert_eq!(v.reduce_max(), 1.);

// ...unless all values are NaN
let v = f32x2::from_array([f32::NAN, f32::NAN]);
assert!(v.reduce_max().is_nan());
Run
source

fn reduce_min(self) -> Self::Scalar

🔬This is a nightly-only experimental API. (portable_simd #86656)

Returns the minimum lane in the vector.

Returns values based on equality, so a vector containing both 0. and -0. may return either.

This function will not return NaN unless all lanes are NaN.

Examples
let v = f32x2::from_array([3., 7.]);
assert_eq!(v.reduce_min(), 3.);

// NaN values are skipped...
let v = f32x2::from_array([1., f32::NAN]);
assert_eq!(v.reduce_min(), 1.);

// ...unless all values are NaN
let v = f32x2::from_array([f32::NAN, f32::NAN]);
assert!(v.reduce_min().is_nan());
Run

Implementors§

source§

impl<const LANES: usize> SimdFloat for Simd<f32, LANES>where LaneCount<LANES>: SupportedLaneCount,

§

type Mask = Mask<<i32 as SimdElement>::Mask, LANES>

§

type Scalar = f32

§

type Bits = Simd<u32, LANES>

source§

impl<const LANES: usize> SimdFloat for Simd<f64, LANES>where LaneCount<LANES>: SupportedLaneCount,

§

type Mask = Mask<<i64 as SimdElement>::Mask, LANES>

§

type Scalar = f64

§

type Bits = Simd<u64, LANES>