Trait lav::SimdReal

source ·
pub trait SimdReal<R: Real, const N: usize>
where LaneCount<N>: SupportedLaneCount, for<'a> Self: Send + Sync + Clone + Copy + Default + ApproxEq<R, Self> + PartialEq + PartialOrd + Debug + From<Simd<R, N>> + Into<Simd<R, N>> + From<[R; N]> + Into<[R; N]> + AsRef<[R; N]> + AsMut<[R; N]> + Product<Self> + Sum<Self> + Product<&'a Self> + Sum<&'a Self> + Index<usize, Output = R> + IndexMut<usize, Output = R> + Select<Self::Mask> + Add<Output = Self> + AddAssign + Sub<Output = Self> + SubAssign + Mul<Output = Self> + MulAssign + Div<Output = Self> + DivAssign + Rem<Output = Self> + RemAssign + Add<&'a Self, Output = Self> + AddAssign<&'a Self> + Sub<&'a Self, Output = Self> + SubAssign<&'a Self> + Mul<&'a Self, Output = Self> + MulAssign<&'a Self> + Div<&'a Self, Output = Self> + DivAssign<&'a Self> + Rem<&'a Self, Output = Self> + RemAssign<&'a Self> + Neg<Output = Self>,
{ type Bits: SimdBits<R::Bits, N, Mask = Self::Mask>; type Mask: SimdMask<N>; const N: usize = N;
Show 59 methods // Required methods fn splat(value: R) -> Self; fn as_array(&self) -> &[R; N]; fn as_mut_array(&mut self) -> &mut [R; N]; fn from_array(array: [R; N]) -> Self; fn to_array(self) -> [R; N]; fn from_slice(slice: &[R]) -> Self; fn gather_or(slice: &[R], idxs: Simd<usize, N>, or: Self) -> Self where LaneCount<N>: SupportedLaneCount; fn gather_or_default(slice: &[R], idxs: Simd<usize, N>) -> Self where R: Default, LaneCount<N>: SupportedLaneCount; fn gather_select( slice: &[R], enable: Mask<isize, N>, idxs: Simd<usize, N>, or: Self ) -> Self where LaneCount<N>: SupportedLaneCount; fn scatter(self, slice: &mut [R], idxs: Simd<usize, N>) where LaneCount<N>: SupportedLaneCount; fn scatter_select( self, slice: &mut [R], enable: Mask<isize, N>, idxs: Simd<usize, N> ) where LaneCount<N>: SupportedLaneCount; fn from_bits(bits: Self::Bits) -> Self; fn to_bits(self) -> Self::Bits; fn reduce_sum(self) -> R; fn reduce_product(self) -> R; fn reduce_min(self) -> R; fn reduce_max(self) -> R; fn reverse(self) -> Self; fn simd_rotate_left<const OFFSET: usize>(self) -> Self; fn simd_rotate_right<const OFFSET: usize>(self) -> Self; fn interleave(self, other: Self) -> (Self, Self); fn deinterleave(self, other: Self) -> (Self, Self); fn swizzle<T: Swizzle<N>>(self) -> Self; fn concat_swizzle<T: Swizzle<N>>(self, other: Self) -> Self; fn simd_eq(self, other: Self) -> Self::Mask; fn simd_ne(self, other: Self) -> Self::Mask; fn simd_lt(self, other: Self) -> Self::Mask; fn simd_gt(self, other: Self) -> Self::Mask; fn simd_le(self, other: Self) -> Self::Mask; fn simd_ge(self, other: Self) -> Self::Mask; 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 abs(self) -> Self; 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 recip(self) -> Self; fn to_degrees(self) -> Self; fn to_radians(self) -> Self; fn mul_add(self, a: Self, b: Self) -> Self; fn sqrt(self) -> Self; fn floor(self) -> Self; fn ceil(self) -> Self; fn round(self) -> Self; fn trunc(self) -> Self; fn fract(self) -> Self; // Provided methods fn len(&self) -> usize { ... } fn insert(self, lane: usize, value: R) -> Self { ... } fn simd_approx_eq( self, other: Self, epsilon: Self, ulp: Self::Bits ) -> Self::Mask { ... } fn simd_approx_ne( self, other: Self, epsilon: Self, ulp: Self::Bits ) -> Self::Mask { ... } fn mask_from_array(array: [bool; N]) -> Self::Mask { ... } fn mask_flag(lane: usize, value: bool) -> Self::Mask { ... }
}
Expand description

Real number vector of Simd<f32, N> or Simd<f64, N> with associated SimdBits and SimdMask vector.

Required Associated Types§

source

type Bits: SimdBits<R::Bits, N, Mask = Self::Mask>

Associated bits representation vector.

source

type Mask: SimdMask<N>

Associated mask vector.

Provided Associated Constants§

source

const N: usize = N

Number of lanes in this vector.

Required Methods§

source

fn splat(value: R) -> Self

Constructs a SIMD vector by setting all lanes to the given value.

source

fn as_array(&self) -> &[R; N]

Returns an array reference containing the entire SIMD vector.

source

fn as_mut_array(&mut self) -> &mut [R; N]

Returns a mutable array reference containing the entire SIMD vector.

source

fn from_array(array: [R; N]) -> Self

Converts an array to a SIMD vector.

source

fn to_array(self) -> [R; N]

Converts a SIMD vector to an array.

source

fn from_slice(slice: &[R]) -> Self

Converts a slice to a SIMD vector containing slice[..N]

Panics

Panics if the slice’s len is less than the vector’s Simd::N.

source

fn gather_or(slice: &[R], idxs: Simd<usize, N>, or: Self) -> Self

Reads from potentially discontiguous indices in slice to construct a SIMD vector.

If an index is out-of-bounds, the lane is instead selected from the or vector.

source

fn gather_or_default(slice: &[R], idxs: Simd<usize, N>) -> Self

Reads from potentially discontiguous indices in slice to construct a SIMD vector.

If an index is out-of-bounds, the lane is set to the default value for the type.

source

fn gather_select( slice: &[R], enable: Mask<isize, N>, idxs: Simd<usize, N>, or: Self ) -> Self

Reads from potentially discontiguous indices in slice to construct a SIMD vector.

The mask enables all true lanes and disables all false lanes. If an index is disabled or is out-of-bounds, the lane is selected from the or vector.

source

fn scatter(self, slice: &mut [R], idxs: Simd<usize, N>)

Writes the values in a SIMD vector to potentially discontiguous indices in slice.

If two lanes in the scattered vector would write to the same index only the last lane is guaranteed to actually be written.

source

fn scatter_select( self, slice: &mut [R], enable: Mask<isize, N>, idxs: Simd<usize, N> )

Writes the values in a SIMD vector to multiple potentially discontiguous indices in slice.

The mask enables all true lanes and disables all false lanes. If an enabled index is out-of-bounds, the lane is not written. If two enabled lanes in the scattered vector would write to the same index, only the last lane is guaranteed to actually be written.

source

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

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

source

fn to_bits(self) -> Self::Bits

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

source

fn reduce_sum(self) -> R

Reducing wrapping add. Returns the sum of the lanes of the vector, with wrapping addition.

source

fn reduce_product(self) -> R

Reducing wrapping multiply. Returns the product of the lanes of the vector, with wrapping multiplication.

source

fn reduce_min(self) -> R

Reducing minimum. Returns the minimum lane in the vector.

Returns values based on equality, so a vector containing both 0.0 and -0.0 may return either. This function will not return NaN unless all lanes are NaN.

source

fn reduce_max(self) -> R

Reducing maximum. Returns the maximum lane in the vector.

Returns values based on equality, so a vector containing both 0.0 and -0.0 may return either. This function will not return NaN unless all lanes are NaN.

source

fn reverse(self) -> Self

Reverse the order of the lanes in the vector.

source

fn simd_rotate_left<const OFFSET: usize>(self) -> Self

Rotates the vector such that the first OFFSET lanes of the slice move to the end while the last Self::N - OFFSET lanes move to the front. The lane previously in lane OFFSET will become the first lane in the slice.

source

fn simd_rotate_right<const OFFSET: usize>(self) -> Self

Rotates the vector such that the first Self::N - OFFSET lanes of the vector move to the end while the last OFFSET lanes move to the front. The lane previously at index Self::N - OFFSET will become the first lane in the slice.

source

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

Interleaves two vectors.

Produces two vectors with lanes taken alternately from self and other.

The first result contains the first Self::N / 2 lanes from self and other, alternating, starting with the first lane of self.

The second result contains the last Self::N / 2 lanes from self and other, alternating, starting with the lane Self::N / 2 from the start of self.

source

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

Deinterleaves two vectors.

The first result takes every other lane of self and then other, starting with the first lane.

The second result takes every other lane of self and then other, starting with the second lane.

source

fn swizzle<T: Swizzle<N>>(self) -> Self

Creates new vector by copying lanes from selected lanes of self.

source

fn concat_swizzle<T: Swizzle<N>>(self, other: Self) -> Self

Creates new vector by copying lanes from selected lanes of self and other.

source

fn simd_eq(self, other: Self) -> Self::Mask

Test if each lane is equal to the corresponding lane in other.

source

fn simd_ne(self, other: Self) -> Self::Mask

Test if each lane is not equal to the corresponding lane in other.

source

fn simd_lt(self, other: Self) -> Self::Mask

Test if each lane is less than the corresponding lane in other.

source

fn simd_gt(self, other: Self) -> Self::Mask

Test if each lane is greater than the corresponding lane in other.

source

fn simd_le(self, other: Self) -> Self::Mask

Test if each lane is less than or equal to the corresponding lane in other.

source

fn simd_ge(self, other: Self) -> Self::Mask

Test if each lane is greater than or equal to the corresponding lane in other.

source

fn is_sign_positive(self) -> Self::Mask

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

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

Returns true for each lane if its value is NaN.

source

fn is_infinite(self) -> Self::Mask

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

source

fn is_finite(self) -> Self::Mask

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

source

fn is_subnormal(self) -> Self::Mask

Returns true for each lane if its value is subnormal.

source

fn is_normal(self) -> Self::Mask

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

source

fn abs(self) -> Self

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

source

fn signum(self) -> Self

Replaces each lane with a number that represents its sign.

source

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

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

If any lane is a Real::NAN, then a Real::NAN with the sign of sign is returned.

source

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

Returns the minimum of each lane.

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

source

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

Returns the maximum of each lane.

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

source

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

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 recip(self) -> Self

Takes the reciprocal (inverse) of each lane, ${1 \over x}$.

source

fn to_degrees(self) -> Self

Converts each lane from radians to degrees.

source

fn to_radians(self) -> Self

Converts each lane from degrees to radians.

source

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

Fused multiply-add. Computes (self * a) + b with only one rounding error, yielding a more accurate result than an unfused multiply-add.

Using mul_add may be more performant than an unfused multiply-add if the target architecture has a dedicated fma CPU instruction. However, this is not always true, and will be heavily dependant on designing algorithms with specific target hardware in mind.

source

fn sqrt(self) -> Self

Produces a vector where every lane has the square root value of the equivalently-indexed lane in self

source

fn floor(self) -> Self

Returns the largest integer value less than or equal to each lane.

source

fn ceil(self) -> Self

Returns the smallest integer greater than or equal to each lane.

source

fn round(self) -> Self

Rounds to the nearest integer value. Ties round toward zero.

source

fn trunc(self) -> Self

Returns the floating point’s integer value, with its fractional part removed.

source

fn fract(self) -> Self

Returns the floating point’s fractional value, with its integer part removed.

Provided Methods§

source

fn len(&self) -> usize

Get the number of lanes in this vector.

source

fn insert(self, lane: usize, value: R) -> Self

Inserts value at lane.

source

fn simd_approx_eq( self, other: Self, epsilon: Self, ulp: Self::Bits ) -> Self::Mask

Tests lanes for approximate equality wrt epsilon or ulp, “or” in the sense of ||.

source

fn simd_approx_ne( self, other: Self, epsilon: Self, ulp: Self::Bits ) -> Self::Mask

Tests lanes for approximate inequality wrt epsilon and ulp, “and” in the sense of &&.

source

fn mask_from_array(array: [bool; N]) -> Self::Mask

Converts an array to a SIMD vector mask.

source

fn mask_flag(lane: usize, value: bool) -> Self::Mask

Constructs a mask with lane set to value and all the other lanes set to !value.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<const N: usize> SimdReal<f32, N> for Simd<f32, N>

§

type Bits = Simd<u32, N>

§

type Mask = Mask<i32, N>

source§

fn splat(value: f32) -> Self

source§

fn as_array(&self) -> &[f32; N]

source§

fn as_mut_array(&mut self) -> &mut [f32; N]

source§

fn from_array(array: [f32; N]) -> Self

source§

fn to_array(self) -> [f32; N]

source§

fn from_slice(slice: &[f32]) -> Self

source§

fn gather_or(slice: &[f32], idxs: Simd<usize, N>, or: Self) -> Self

source§

fn gather_or_default(slice: &[f32], idxs: Simd<usize, N>) -> Self

source§

fn gather_select( slice: &[f32], enable: Mask<isize, N>, idxs: Simd<usize, N>, or: Self ) -> Self

source§

fn scatter(self, slice: &mut [f32], idxs: Simd<usize, N>)

source§

fn scatter_select( self, slice: &mut [f32], enable: Mask<isize, N>, idxs: Simd<usize, N> )

source§

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

source§

fn to_bits(self) -> Self::Bits

source§

fn reduce_sum(self) -> f32

source§

fn reduce_product(self) -> f32

source§

fn reduce_min(self) -> f32

source§

fn reduce_max(self) -> f32

source§

fn reverse(self) -> Self

source§

fn simd_rotate_left<const OFFSET: usize>(self) -> Self

source§

fn simd_rotate_right<const OFFSET: usize>(self) -> Self

source§

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

source§

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

source§

fn swizzle<T: Swizzle<N>>(self) -> Self

source§

fn concat_swizzle<T: Swizzle<N>>(self, other: Self) -> Self

source§

fn simd_eq(self, other: Self) -> Self::Mask

source§

fn simd_ne(self, other: Self) -> Self::Mask

source§

fn simd_lt(self, other: Self) -> Self::Mask

source§

fn simd_gt(self, other: Self) -> Self::Mask

source§

fn simd_le(self, other: Self) -> Self::Mask

source§

fn simd_ge(self, other: Self) -> Self::Mask

source§

fn is_sign_positive(self) -> Self::Mask

source§

fn is_sign_negative(self) -> Self::Mask

source§

fn is_nan(self) -> Self::Mask

source§

fn is_infinite(self) -> Self::Mask

source§

fn is_finite(self) -> Self::Mask

source§

fn is_subnormal(self) -> Self::Mask

source§

fn is_normal(self) -> Self::Mask

source§

fn abs(self) -> Self

source§

fn signum(self) -> Self

source§

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

source§

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

source§

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

source§

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

source§

fn recip(self) -> Self

source§

fn to_degrees(self) -> Self

source§

fn to_radians(self) -> Self

source§

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

source§

fn sqrt(self) -> Self

source§

fn floor(self) -> Self

source§

fn ceil(self) -> Self

source§

fn round(self) -> Self

source§

fn trunc(self) -> Self

source§

fn fract(self) -> Self

source§

impl<const N: usize> SimdReal<f64, N> for Simd<f64, N>

§

type Bits = Simd<u64, N>

§

type Mask = Mask<i64, N>

source§

fn splat(value: f64) -> Self

source§

fn as_array(&self) -> &[f64; N]

source§

fn as_mut_array(&mut self) -> &mut [f64; N]

source§

fn from_array(array: [f64; N]) -> Self

source§

fn to_array(self) -> [f64; N]

source§

fn from_slice(slice: &[f64]) -> Self

source§

fn gather_or(slice: &[f64], idxs: Simd<usize, N>, or: Self) -> Self

source§

fn gather_or_default(slice: &[f64], idxs: Simd<usize, N>) -> Self

source§

fn gather_select( slice: &[f64], enable: Mask<isize, N>, idxs: Simd<usize, N>, or: Self ) -> Self

source§

fn scatter(self, slice: &mut [f64], idxs: Simd<usize, N>)

source§

fn scatter_select( self, slice: &mut [f64], enable: Mask<isize, N>, idxs: Simd<usize, N> )

source§

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

source§

fn to_bits(self) -> Self::Bits

source§

fn reduce_sum(self) -> f64

source§

fn reduce_product(self) -> f64

source§

fn reduce_min(self) -> f64

source§

fn reduce_max(self) -> f64

source§

fn reverse(self) -> Self

source§

fn simd_rotate_left<const OFFSET: usize>(self) -> Self

source§

fn simd_rotate_right<const OFFSET: usize>(self) -> Self

source§

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

source§

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

source§

fn swizzle<T: Swizzle<N>>(self) -> Self

source§

fn concat_swizzle<T: Swizzle<N>>(self, other: Self) -> Self

source§

fn simd_eq(self, other: Self) -> Self::Mask

source§

fn simd_ne(self, other: Self) -> Self::Mask

source§

fn simd_lt(self, other: Self) -> Self::Mask

source§

fn simd_gt(self, other: Self) -> Self::Mask

source§

fn simd_le(self, other: Self) -> Self::Mask

source§

fn simd_ge(self, other: Self) -> Self::Mask

source§

fn is_sign_positive(self) -> Self::Mask

source§

fn is_sign_negative(self) -> Self::Mask

source§

fn is_nan(self) -> Self::Mask

source§

fn is_infinite(self) -> Self::Mask

source§

fn is_finite(self) -> Self::Mask

source§

fn is_subnormal(self) -> Self::Mask

source§

fn is_normal(self) -> Self::Mask

source§

fn abs(self) -> Self

source§

fn signum(self) -> Self

source§

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

source§

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

source§

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

source§

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

source§

fn recip(self) -> Self

source§

fn to_degrees(self) -> Self

source§

fn to_radians(self) -> Self

source§

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

source§

fn sqrt(self) -> Self

source§

fn floor(self) -> Self

source§

fn ceil(self) -> Self

source§

fn round(self) -> Self

source§

fn trunc(self) -> Self

source§

fn fract(self) -> Self

Implementors§