Skip to main content

Aligned16

Struct Aligned16 

Source
#[repr(align(16))]
pub struct Aligned16<T, const N: usize>(pub [T; N]);
Expand description

A fixed-length vector of N lanes of element type T over [T; N] with enforced 16-byte alignment; see the module docs.

Tuple Fields§

§0: [T; N]

Implementations§

Source§

impl<T, const N: usize> Aligned16<T, N>

Source

pub fn to_simd(self) -> Simd<T, N>

Returns the equivalent plain (naturally aligned) vector.

Source§

impl<T: Copy, const N: usize> Aligned16<T, N>

Source

pub fn from_slice(src: &[T]) -> Self

Loads a vector from the first N elements of src.

§Panics

Panics if src.len() < N.

Source

pub fn store_slice(&self, dst: &mut [T])

Stores all lanes to the first N elements of dst.

§Panics

Panics if dst.len() < N.

Source

pub fn store_slice_partial(&self, dst: &mut [T])

Stores at most the first min(dst.len(), N) lanes to dst.

Source§

impl<T: Zero + Copy, const N: usize> Aligned16<T, N>

Source

pub fn from_slice_pad(src: &[T]) -> Self

Loads a vector from src, zero-filling lanes past src.len().

Source§

impl<T, const N: usize> Aligned16<T, N>
where T: Mul<Output = T> + Add<Output = T> + Copy,

Source

pub fn mul_add(self, b: Self, c: Self) -> Self

Lane-wise multiply-add: self * b + c, evaluated as a separate multiply and add (two roundings per lane).

This is the fallback on targets without hardware FMA (generic x86-64, x86-64-v2), where it avoids the slow software-fused libm fma calls; it also fuses into a single hardware FMA instruction when compiled with -C llvm-args=-fp-contract=fast. Enable the use_libm_fma feature to get the single-rounding fused form on such targets instead.

Source

pub fn fma_from(&mut self, b: Self, c: Self)

Lane-wise *self = b * c + *self, by the receiver.

Note that the operand order differs from mul_add: the accumulator is the receiver, matching self += b * c. The evaluation strategy is the same as mul_add’s.

Source§

impl<T, const N: usize> Aligned16<T, N>
where T: Float + Copy,

Source

pub fn abs(self) -> Self

Lane-wise Float::abs.

Source

pub fn sqrt(self) -> Self

Lane-wise Float::sqrt.

Source

pub fn recip(self) -> Self

Lane-wise Float::recip.

Source

pub fn floor(self) -> Self

Lane-wise Float::floor.

Source

pub fn ceil(self) -> Self

Lane-wise Float::ceil.

Source

pub fn round(self) -> Self

Lane-wise Float::round.

Source

pub fn trunc(self) -> Self

Lane-wise Float::trunc.

Source

pub fn fract(self) -> Self

Lane-wise Float::fract.

Source

pub fn min(self, other: Self) -> Self

Lane-wise minimum; NaN handling follows the element’s scalar Float::min.

Source

pub fn max(self, other: Self) -> Self

Lane-wise maximum; NaN handling follows the element’s scalar Float::max.

Source

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

Lane-wise Float::copysign.

Source§

impl<const N: usize> Aligned16<f32, N>

Source

pub fn round_ties_even(self) -> Self

Lane-wise f32::round_ties_even.

Not available generically through num_traits::Float, so this is implemented only for the builtin float types.

Source§

impl<const N: usize> Aligned16<f64, N>

Source

pub fn round_ties_even(self) -> Self

Lane-wise f64::round_ties_even.

Not available generically through num_traits::Float, so this is implemented only for the builtin float types.

Source§

impl<T, const N: usize> Aligned16<T, N>
where T: PartialOrd + Copy,

Source

pub fn simd_lt(self, rhs: Self) -> Simd<bool, N>

Lane-wise self < rhs.

Source

pub fn simd_le(self, rhs: Self) -> Simd<bool, N>

Lane-wise self <= rhs.

Source

pub fn simd_gt(self, rhs: Self) -> Simd<bool, N>

Lane-wise self > rhs.

Source

pub fn simd_ge(self, rhs: Self) -> Simd<bool, N>

Lane-wise self >= rhs.

Source§

impl<T, const N: usize> Aligned16<T, N>
where T: PartialEq + Copy,

Source

pub fn simd_eq(self, rhs: Self) -> Simd<bool, N>

Lane-wise self == rhs.

Source

pub fn simd_ne(self, rhs: Self) -> Simd<bool, N>

Lane-wise self != rhs.

Source§

impl<T, const N: usize> Aligned16<T, N>
where T: Zero + Add<Output = T> + Copy,

Source

pub fn reduce_sum(self) -> T

Sums all lanes, accumulating in lane order.

Source

pub fn reduce_sum_n(self, n: usize) -> T

Sums the first n lanes.

§Panics

Panics if n > N.

Source§

impl<T, const N: usize> Aligned16<T, N>
where T: One + Mul<Output = T> + Copy,

Source

pub fn reduce_product(self) -> T

Multiplies all lanes, accumulating in lane order.

Source

pub fn reduce_product_n(self, n: usize) -> T

Multiplies the first n lanes.

§Panics

Panics if n > N.

Source§

impl<T, const N: usize> Aligned16<T, N>

Source

pub fn from_fn<F>(f: F) -> Self
where F: FnMut(usize) -> T,

Returns a vector whose lane i is f(i).

Source

pub fn map<F>(self, f: F) -> Self
where F: FnMut(T) -> T,

Applies f to each lane, returning a new vector.

This is the generic escape hatch for operations the crate does not provide (e.g. transcendental functions: v.map(f64::exp)).

Source

pub const fn as_array(&self) -> &[T; N]

Returns the underlying array by reference.

Source

pub fn as_array_mut(&mut self) -> &mut [T; N]

Returns the underlying array by mutable reference.

Source

pub fn to_array(self) -> [T; N]

Returns the underlying array by value.

Source§

impl<T: Copy, const N: usize> Aligned16<T, N>

Source

pub const fn splat(val: T) -> Self

Returns a vector with all lanes set to val.

Source

pub fn fill(&mut self, val: T)

Sets all lanes to val.

Source

pub fn mask_select(self, mask: Simd<bool, N>, other: Self) -> Self

Per-lane select: keeps lanes of self where mask is true and lanes of other where it is false. This value-side form is available on every vector type; the mask-side select applies to plain vectors.

Source

pub unsafe fn uninit() -> Self

Returns an uninitialized vector, intended for scratch buffers whose lanes are fully written before being read.

§Safety

The caller must initialize all lanes before any read. The element type must additionally admit arbitrary bit patterns (true for floats and integers; not for types with niches such as references).

Source§

impl<T: Zero + Copy, const N: usize> Aligned16<T, N>

Source

pub fn zero() -> Self

Returns a vector with all lanes set to zero.

Source§

impl<T: One + Copy, const N: usize> Aligned16<T, N>

Source

pub fn one() -> Self

Returns a vector with all lanes set to one.

Trait Implementations§

Source§

impl<T, const N: usize> Add for Aligned16<T, N>
where T: Num + Copy,

Source§

type Output = Aligned16<T, N>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
Source§

impl<T, const N: usize> Add<T> for Aligned16<T, N>
where T: Num + Copy,

Source§

type Output = Aligned16<T, N>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> Self

Performs the + operation. Read more
Source§

impl<T, const N: usize> AddAssign for Aligned16<T, N>
where T: NumAssignOps + Copy,

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<T, const N: usize> AddAssign<T> for Aligned16<T, N>
where T: NumAssignOps + Copy,

Source§

fn add_assign(&mut self, rhs: T)

Performs the += operation. Read more
Source§

impl<T, const N: usize> BitAnd for Aligned16<T, N>
where T: BitAnd<Output = T> + Copy,

Source§

type Output = Aligned16<T, N>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self

Performs the & operation. Read more
Source§

impl<T, const N: usize> BitAndAssign for Aligned16<T, N>
where T: BitAndAssign + Copy,

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl<T, const N: usize> BitOr for Aligned16<T, N>
where T: BitOr<Output = T> + Copy,

Source§

type Output = Aligned16<T, N>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self

Performs the | operation. Read more
Source§

impl<T, const N: usize> BitOrAssign for Aligned16<T, N>
where T: BitOrAssign + Copy,

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl<T, const N: usize> BitXor for Aligned16<T, N>
where T: BitXor<Output = T> + Copy,

Source§

type Output = Aligned16<T, N>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self

Performs the ^ operation. Read more
Source§

impl<T, const N: usize> BitXorAssign for Aligned16<T, N>
where T: BitXorAssign + Copy,

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl<T: Clone, const N: usize> Clone for Aligned16<T, N>

Source§

fn clone(&self) -> Aligned16<T, N>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Copy, const N: usize> Copy for Aligned16<T, N>

Source§

impl<T: Debug, const N: usize> Debug for Aligned16<T, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default, const N: usize> Default for Aligned16<T, N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T, const N: usize> Div for Aligned16<T, N>
where T: Num + Copy,

Source§

type Output = Aligned16<T, N>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self

Performs the / operation. Read more
Source§

impl<T, const N: usize> Div<T> for Aligned16<T, N>
where T: Num + Copy,

Source§

type Output = Aligned16<T, N>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self

Performs the / operation. Read more
Source§

impl<T, const N: usize> DivAssign for Aligned16<T, N>
where T: NumAssignOps + Copy,

Source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
Source§

impl<T, const N: usize> DivAssign<T> for Aligned16<T, N>
where T: NumAssignOps + Copy,

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl<T: Eq, const N: usize> Eq for Aligned16<T, N>

Source§

impl<T, const N: usize> From<Aligned16<T, N>> for Simd<T, N>

Source§

fn from(v: Aligned16<T, N>) -> Self

Converts to this type from the input type.
Source§

impl<T, const N: usize> From<Simd<T, N>> for Aligned16<T, N>

Source§

fn from(v: Simd<T, N>) -> Self

Converts to this type from the input type.
Source§

impl<T, const N: usize> From<[T; N]> for Aligned16<T, N>

Source§

fn from(array: [T; N]) -> Self

Converts to this type from the input type.
Source§

impl<T: Hash, const N: usize> Hash for Aligned16<T, N>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T, const N: usize> Index<usize> for Aligned16<T, N>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T, const N: usize> IndexMut<usize> for Aligned16<T, N>

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T, const N: usize> Mul for Aligned16<T, N>
where T: Num + Copy,

Source§

type Output = Aligned16<T, N>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self

Performs the * operation. Read more
Source§

impl<T, const N: usize> Mul<T> for Aligned16<T, N>
where T: Num + Copy,

Source§

type Output = Aligned16<T, N>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Self

Performs the * operation. Read more
Source§

impl<T, const N: usize> MulAssign for Aligned16<T, N>
where T: NumAssignOps + Copy,

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl<T, const N: usize> MulAssign<T> for Aligned16<T, N>
where T: NumAssignOps + Copy,

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl<T, const N: usize> Neg for Aligned16<T, N>
where T: Neg<Output = T> + Copy,

Source§

type Output = Aligned16<T, N>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<T, const N: usize> Not for Aligned16<T, N>
where T: Not<Output = T> + Copy,

Source§

type Output = Aligned16<T, N>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self

Performs the unary ! operation. Read more
Source§

impl<T: Num + Copy, const N: usize> One for Aligned16<T, N>

Source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

fn is_one(&self) -> bool
where Self: PartialEq,

Returns true if self is equal to the multiplicative identity. Read more
Source§

impl<T: PartialEq, const N: usize> PartialEq for Aligned16<T, N>

Source§

fn eq(&self, other: &Aligned16<T, N>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T, const N: usize> Shl<usize> for Aligned16<T, N>
where T: Shl<usize, Output = T> + Copy,

Source§

type Output = Aligned16<T, N>

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: usize) -> Self

Performs the << operation. Read more
Source§

impl<T, const N: usize> Shr<usize> for Aligned16<T, N>
where T: Shr<usize, Output = T> + Copy,

Source§

type Output = Aligned16<T, N>

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: usize) -> Self

Performs the >> operation. Read more
Source§

impl<T: PartialEq, const N: usize> StructuralPartialEq for Aligned16<T, N>

Source§

impl<T, const N: usize> Sub for Aligned16<T, N>
where T: Num + Copy,

Source§

type Output = Aligned16<T, N>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more
Source§

impl<T, const N: usize> Sub<T> for Aligned16<T, N>
where T: Num + Copy,

Source§

type Output = Aligned16<T, N>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> Self

Performs the - operation. Read more
Source§

impl<T, const N: usize> SubAssign for Aligned16<T, N>
where T: NumAssignOps + Copy,

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl<T, const N: usize> SubAssign<T> for Aligned16<T, N>
where T: NumAssignOps + Copy,

Source§

fn sub_assign(&mut self, rhs: T)

Performs the -= operation. Read more
Source§

impl<T: Num + Copy, const N: usize> Zero for Aligned16<T, N>

Source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.

Auto Trait Implementations§

§

impl<T, const N: usize> Freeze for Aligned16<T, N>
where [T; N]: Freeze,

§

impl<T, const N: usize> RefUnwindSafe for Aligned16<T, N>

§

impl<T, const N: usize> Send for Aligned16<T, N>
where [T; N]: Send,

§

impl<T, const N: usize> Sync for Aligned16<T, N>
where [T; N]: Sync,

§

impl<T, const N: usize> Unpin for Aligned16<T, N>
where [T; N]: Unpin,

§

impl<T, const N: usize> UnsafeUnpin for Aligned16<T, N>

§

impl<T, const N: usize> UnwindSafe for Aligned16<T, N>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.