alloy::math::simd

Struct Float32x4

source
pub struct Float32x4(/* private fields */);
Expand description

A 128-bit SIMD vector with 4 f32 components.

Implementations§

source§

impl Float32x4

source

pub const fn new(v0: f32, v1: f32, v2: f32, v3: f32) -> Self

Create a new vector with the given components.

§Parameters
  • v0 - the first component of the vector
  • v1 - the second component of the vector
  • v2 - the third component of the vector
  • v3 - the fourth component of the vector
source

pub const fn splat(value: f32) -> Self

Create a new vector with the given value in all components.

§Parameters
  • value - the value to set all components to
source

pub const unsafe fn from_aligned_ptr(ptr: *const f32) -> Self

Load a vector from a pointer to an aligned series of f32 values.

§Safety

The pointer must be aligned to 16 bytes, and the pointer must be able to reach at least 4 f32 values.

§Parameters
  • ptr - the pointer to the slice of f32 values
source

pub const unsafe fn from_unaligned_ptr(ptr: *const f32) -> Self

Load a vector from a slice of f32 values.

§Safety

The pointer must be able to reach at least 4 f32 values.

§Parameters
  • ptr - the pointer to the slice of f32 values
source

pub unsafe fn store_aligned(&self, ptr: *mut f32)

Store the vector into a slice of f32 values.

§Safety

The the pointer must be able to reach at least 4 f32 values.

source§

impl Float32x4

source

pub const ALIGN: usize = 16usize

The alignment of the Float32x4 type.

source

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

Create a new Float32x4 from the elements within the slice, taking care to handle both aligned and unaligned slices – as well as padding slices that contain less than 4 elements with zeros.

§Parameters
  • slice - the slice of f32 values to create the vector from
source

pub unsafe fn from_aligned_slice(slice: &[f32]) -> Self

Create a new Float32x4 from the elements within the aligned slice.

§Parameters
  • slice - the aligned slice of f32 values to create the vector from
§Safety

The slice must be aligned to 16 bytes

source

pub unsafe fn from_aligned_slice_exact(slice: &[f32]) -> Self

Create a new Float32x4 from the elements within the aligned slice.

§Parameters
  • slice - the aligned slice of f32 values to create the vector from
§Safety

The slice must be aligned to 16 bytes, and the length of the slice must be a multiple of 4.

source

pub unsafe fn from_unaligned_slice_exact(slice: &[f32]) -> Self

Create a new Float32x4 from the elements within the aligned slice.

§Parameters
  • slice - the aligned slice of f32 values to create the vector from
§Safety

The slice must contain a multiple of 4 elements.

source

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

Create a new Float32x4 from the elements within the unaligned slice.

§Parameters
  • slice - the unaligned slice of f32 values to create the vector from
source

pub fn iter_slice(slice: &[f32]) -> impl Iterator<Item = Self> + '_

Returns an iterator that yields Float32x4 values from the given slice.

If the slice is not divisible by 4, the remaining elements will be padded with zeros.

§Parameters
  • slice - the slice of f32 values to create the vector from
source

pub unsafe fn iter_slice_exact(slice: &[f32]) -> impl Iterator<Item = Self> + '_

Returns an iterator that yields Float32x4 values from the given slice.

§Parameters
  • slice - the slice of f32 values to create the vector from
§Safety

The slice must contain a multiple of 4 elements.

Trait Implementations§

source§

impl Default for Float32x4

source§

fn default() -> Self

Create a new Float32x4 with all components set to zero.

source§

impl From<&[f32]> for Float32x4

source§

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

Create a new Float32x4 from the given slice of f32 values.

§Parameters
  • slice - the slice of f32 values to create the vector from
source§

impl From<[f32; 4]> for Float32x4

source§

fn from(arr: [f32; 4]) -> Self

Create a new Float32x4 from the given array of f32 values.

§Parameters
  • arr - the array of f32 values to create the vector from
source§

impl From<Float32x4> for [f32; 4]

source§

fn from(vec: Float32x4) -> Self

Create a new array of f32 values from the given Float32x4.

§Parameters
  • vec - the Float32x4 to create the array from
source§

impl FromIterator<f32> for Float32x4

source§

fn from_iter<I: IntoIterator<Item = f32>>(iter: I) -> Self

Create a new Float32x4 from the first 4 elements within the iterator.

§Parameters
  • iter - the iterator of f32 values to create the vector from

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.