pub struct f32x4<S: Simd> {
pub simd: S,
/* private fields */
}Expand description
A SIMD vector of 4 f32 elements.
This type’s memory layout is identical to that of [f32; 4], except that it is aligned to 16 bytes.
You may construct this vector type using the Self::splat, Self::from_slice, Self::simd_from, Self::from_fn, and Self::block_splat methods.
fn construct_simd<S: Simd>(simd: S) {
// From a single scalar value:
let a = f32x4::splat(simd, 1.0);
let b = f32x4::simd_from(simd, 1.0);
// From a slice:
let c = f32x4::from_slice(simd, &[1.0, 2.0, 3.0, 4.0]);
// From an array:
let d = f32x4::simd_from(simd, [1.0, 2.0, 3.0, 4.0]);
// From an element-wise function:
let e = f32x4::from_fn(simd, |i| i as f32);
}Fields§
§simd: STrait Implementations§
Source§impl<S: Simd> AddAssign for f32x4<S>
impl<S: Simd> AddAssign for f32x4<S>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Add two vectors element-wise.
Source§impl<S: Simd> AddAssign<f32> for f32x4<S>
impl<S: Simd> AddAssign<f32> for f32x4<S>
Source§fn add_assign(&mut self, rhs: f32)
fn add_assign(&mut self, rhs: f32)
+= operation. Read moreSource§impl<S: Simd> Bytes for f32x4<S>
impl<S: Simd> Bytes for f32x4<S>
impl<S: Copy + Simd> Copy for f32x4<S>where
S::f32x4: Copy,
Source§impl<S: Simd> DivAssign for f32x4<S>
impl<S: Simd> DivAssign for f32x4<S>
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Divide two vectors element-wise.
Source§impl<S: Simd> DivAssign<f32> for f32x4<S>
impl<S: Simd> DivAssign<f32> for f32x4<S>
Source§fn div_assign(&mut self, rhs: f32)
fn div_assign(&mut self, rhs: f32)
/= operation. Read moreSource§impl<S: Simd> ExtractToken for f32x4<S>
impl<S: Simd> ExtractToken for f32x4<S>
Source§impl<S: Simd> MulAssign for f32x4<S>
impl<S: Simd> MulAssign for f32x4<S>
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Multiply two vectors element-wise.
Source§impl<S: Simd> MulAssign<f32> for f32x4<S>
impl<S: Simd> MulAssign<f32> for f32x4<S>
Source§fn mul_assign(&mut self, rhs: f32)
fn mul_assign(&mut self, rhs: f32)
*= operation. Read moreSource§impl<S: Simd> SimdBase<S> for f32x4<S>
impl<S: Simd> SimdBase<S> for f32x4<S>
Source§const LEN: usize = 4
const LEN: usize = 4
Simd::f32s) and
want to process data in native-width chunks.Source§type ByteVector = u8x16<S>
type ByteVector = u8x16<S>
u8 lanes used as the byte representation. Read moreSource§type Array = [f32; 4]
type Array = [f32; 4]
[Self::Element; Self::LEN]. It has the same layout as
this vector type, but likely has a lower alignment.fn as_slice(&self) -> &[f32]
fn as_mut_slice(&mut self) -> &mut [f32]
Source§fn from_slice(simd: S, slice: &[f32]) -> Self
fn from_slice(simd: S, slice: &[f32]) -> Self
Source§fn store_slice(&self, slice: &mut [f32])
fn store_slice(&self, slice: &mut [f32])
Source§fn splat(simd: S, val: f32) -> Self
fn splat(simd: S, val: f32) -> Self
Source§fn block_splat(block: Self::Block) -> Self
fn block_splat(block: Self::Block) -> Self
Source§fn from_fn(simd: S, f: impl FnMut(usize) -> f32) -> Self
fn from_fn(simd: S, f: impl FnMut(usize) -> f32) -> Self
f with that element’s lane index (from 0 to
SimdBase::LEN - 1).Source§fn slide_within_blocks<const SHIFT: usize>(
self,
rhs: impl SimdInto<Self, S>,
) -> Self
fn slide_within_blocks<const SHIFT: usize>( self, rhs: impl SimdInto<Self, S>, ) -> Self
slide, but operates independently on each 128-bit block.Source§fn swizzle_dyn_within_blocks(
self,
indices: impl SimdInto<Self::Bytes, S>,
) -> Self
fn swizzle_dyn_within_blocks( self, indices: impl SimdInto<Self::Bytes, S>, ) -> Self
Source§fn swizzle_dyn(self, indices: impl SimdInto<Self::Bytes, S>) -> Self
fn swizzle_dyn(self, indices: impl SimdInto<Self::Bytes, S>) -> Self
Source§fn swizzle_dyn_precise(self, indices: impl SimdInto<Self::Bytes, S>) -> Self
fn swizzle_dyn_precise(self, indices: impl SimdInto<Self::Bytes, S>) -> Self
Source§fn reduce_max(self) -> Self::Element
fn reduce_max(self) -> Self::Element
Source§fn reduce_min(self) -> Self::Element
fn reduce_min(self) -> Self::Element
Source§fn reduce_max_precise(self) -> Self::Element
fn reduce_max_precise(self) -> Self::Element
Source§fn reduce_min_precise(self) -> Self::Element
fn reduce_min_precise(self) -> Self::Element
Source§fn reduce_sum(self) -> Self::Element
fn reduce_sum(self) -> Self::Element
Source§fn reduce_product(self) -> Self::Element
fn reduce_product(self) -> Self::Element
Source§fn max(self, rhs: impl SimdInto<Self, S>) -> Self
fn max(self, rhs: impl SimdInto<Self, S>) -> Self
Source§fn min(self, rhs: impl SimdInto<Self, S>) -> Self
fn min(self, rhs: impl SimdInto<Self, S>) -> Self
Source§fn max_precise(self, rhs: impl SimdInto<Self, S>) -> Self
fn max_precise(self, rhs: impl SimdInto<Self, S>) -> Self
Source§fn min_precise(self, rhs: impl SimdInto<Self, S>) -> Self
fn min_precise(self, rhs: impl SimdInto<Self, S>) -> Self
Source§fn simd_eq(self, rhs: impl SimdInto<Self, S>) -> Self::Mask
fn simd_eq(self, rhs: impl SimdInto<Self, S>) -> Self::Mask
Source§fn simd_lt(self, rhs: impl SimdInto<Self, S>) -> Self::Mask
fn simd_lt(self, rhs: impl SimdInto<Self, S>) -> Self::Mask
Source§fn simd_le(self, rhs: impl SimdInto<Self, S>) -> Self::Mask
fn simd_le(self, rhs: impl SimdInto<Self, S>) -> Self::Mask
Source§fn simd_ge(self, rhs: impl SimdInto<Self, S>) -> Self::Mask
fn simd_ge(self, rhs: impl SimdInto<Self, S>) -> Self::Mask
Source§fn simd_gt(self, rhs: impl SimdInto<Self, S>) -> Self::Mask
fn simd_gt(self, rhs: impl SimdInto<Self, S>) -> Self::Mask
Source§fn zip_low(self, rhs: impl SimdInto<Self, S>) -> Self
fn zip_low(self, rhs: impl SimdInto<Self, S>) -> Self
Source§fn zip_high(self, rhs: impl SimdInto<Self, S>) -> Self
fn zip_high(self, rhs: impl SimdInto<Self, S>) -> Self
Source§fn unzip_low(self, rhs: impl SimdInto<Self, S>) -> Self
fn unzip_low(self, rhs: impl SimdInto<Self, S>) -> Self
Source§fn unzip_high(self, rhs: impl SimdInto<Self, S>) -> Self
fn unzip_high(self, rhs: impl SimdInto<Self, S>) -> Self
Source§fn interleave(self, rhs: impl SimdInto<Self, S>) -> (Self, Self)
fn interleave(self, rhs: impl SimdInto<Self, S>) -> (Self, Self)
Source§fn deinterleave(self, rhs: impl SimdInto<Self, S>) -> (Self, Self)
fn deinterleave(self, rhs: impl SimdInto<Self, S>) -> (Self, Self)
Source§fn load_array(simd: S, val: Self::Array) -> Self
fn load_array(simd: S, val: Self::Array) -> Self
Source§fn load_array_ref(simd: S, val: &Self::Array) -> Self
fn load_array_ref(simd: S, val: &Self::Array) -> Self
Source§fn as_array(&self) -> &Self::Array
fn as_array(&self) -> &Self::Array
Source§fn as_mut_array(&mut self) -> &mut Self::Array
fn as_mut_array(&mut self) -> &mut Self::Array
Source§fn store_array(self, dest: &mut Self::Array)
fn store_array(self, dest: &mut Self::Array)
Source§fn rotate_elements_left<const OFFSET: usize>(self) -> Self
fn rotate_elements_left<const OFFSET: usize>(self) -> Self
OFFSET. Read moreSource§fn rotate_elements_right<const OFFSET: usize>(self) -> Self
fn rotate_elements_right<const OFFSET: usize>(self) -> Self
OFFSET. Read moreSource§fn shift_elements_left<const OFFSET: usize>(
self,
padding: Self::Element,
) -> Self
fn shift_elements_left<const OFFSET: usize>( self, padding: Self::Element, ) -> Self
Source§impl<S: Simd> SimdCombine<S> for f32x4<S>
impl<S: Simd> SimdCombine<S> for f32x4<S>
Source§impl<S: Simd> SimdCvtFloat<i32x4<S>> for f32x4<S>
impl<S: Simd> SimdCvtFloat<i32x4<S>> for f32x4<S>
Source§fn float_from(x: i32x4<S>) -> Self
fn float_from(x: i32x4<S>) -> Self
Convert each signed 32-bit integer element to a floating-point value.
Values that cannot be exactly represented are rounded to the nearest representable value.
Source§impl<S: Simd> SimdCvtFloat<u32x4<S>> for f32x4<S>
impl<S: Simd> SimdCvtFloat<u32x4<S>> for f32x4<S>
Source§fn float_from(x: u32x4<S>) -> Self
fn float_from(x: u32x4<S>) -> Self
Convert each unsigned 32-bit integer element to a floating-point value.
Values that cannot be exactly represented are rounded to the nearest representable value.
Source§impl<S: Simd> SimdCvtTruncate<f32x4<S>> for i32x4<S>
impl<S: Simd> SimdCvtTruncate<f32x4<S>> for i32x4<S>
Source§fn truncate_from(x: f32x4<S>) -> Self
fn truncate_from(x: f32x4<S>) -> Self
Convert each floating-point element to a signed 32-bit integer, truncating towards zero.
Out-of-range values or NaN will produce implementation-defined results.
Source§fn truncate_from_precise(x: f32x4<S>) -> Self
fn truncate_from_precise(x: f32x4<S>) -> Self
Convert each floating-point element to a signed 32-bit integer, truncating towards zero.
Out-of-range values are saturated to the closest in-range value. NaN becomes 0.
Source§impl<S: Simd> SimdCvtTruncate<f32x4<S>> for u32x4<S>
impl<S: Simd> SimdCvtTruncate<f32x4<S>> for u32x4<S>
Source§fn truncate_from(x: f32x4<S>) -> Self
fn truncate_from(x: f32x4<S>) -> Self
Convert each floating-point element to an unsigned 32-bit integer, truncating towards zero.
Out-of-range values or NaN will produce implementation-defined results.
On x86 platforms below AVX-512, this operation will still be slower than converting to i32, because there is no native instruction for converting to u32.
If you know your values fit within range of an i32, you should convert to an i32 and cast to your desired datatype afterwards.
Source§fn truncate_from_precise(x: f32x4<S>) -> Self
fn truncate_from_precise(x: f32x4<S>) -> Self
Convert each floating-point element to an unsigned 32-bit integer, truncating towards zero.
Out-of-range values are saturated to the closest in-range value. NaN becomes 0.
Source§impl<S: Simd> SimdFloat<S> for f32x4<S>
impl<S: Simd> SimdFloat<S> for f32x4<S>
Source§fn approximate_recip(self) -> Self
fn approximate_recip(self) -> Self
1. / x) for each element. Read moreSource§fn 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
(self * op1) + op2 (fused multiply-add) for each element. Read moreSource§fn mul_add_precise(
self,
op1: impl SimdInto<Self, S>,
op2: impl SimdInto<Self, S>,
) -> Self
fn mul_add_precise( self, op1: impl SimdInto<Self, S>, op2: impl SimdInto<Self, S>, ) -> Self
(self * op1) + op2 for each element, with a single rounding at the end. Read moreSource§fn 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
(self * op1) - op2 (fused multiply-subtract) for each element. Read moreSource§fn mul_sub_precise(
self,
op1: impl SimdInto<Self, S>,
op2: impl SimdInto<Self, S>,
) -> Self
fn mul_sub_precise( self, op1: impl SimdInto<Self, S>, op2: impl SimdInto<Self, S>, ) -> Self
(self * op1) - op2 for each element, with a single rounding at the end. Read moreSource§fn floor(self) -> Self
fn floor(self) -> Self
Source§fn ceil(self) -> Self
fn ceil(self) -> Self
Source§fn round_ties_even(self) -> Self
fn round_ties_even(self) -> Self
Source§fn to_int<T: SimdCvtTruncate<Self>>(self) -> T
fn to_int<T: SimdCvtTruncate<Self>>(self) -> T
SimdCvtTruncate::truncate_from, and can only be called if there
actually exists a target type of the same bit width (u32/i32 for f32, or
u64/i64 for f64). Read moreSource§fn to_int_precise<T: SimdCvtTruncate<Self>>(self) -> T
fn to_int_precise<T: SimdCvtTruncate<Self>>(self) -> T
SimdCvtTruncate::truncate_from_precise, and can only be called if there actually
exists a target type of the same bit width (u32/i32 for f32, or u64/i64
for f64). Read more