MatSimd

Struct MatSimd 

Source
pub struct MatSimd<T, A>
where T: Simd + Default + Clone, A: AccessStrategy,
{ /* private fields */ }
Expand description

A dynamic (heap allocated) matrix with one axis aligned for fast and safe SIMD access that also provides a flat view on its data.

You can use MatSimd when you need to deal with multiple SIMD vectors, but want them arranged in a compact cache-friendly manner. Internally this struct is backed by a continuous vector of aligned vectors, and dynamically sliced according to row / column access.

§Example

use simd_aligned::{MatSimd, arch::f32x4, Rows};

// Create a matrix of height 10x`f32` and width 5x`f32`, optimized for row access.
let mut m = MatSimd::<f32x4, Rows>::with_dimension(10, 5);

// A `RowOptimized` matrix provides `row` access. In this example, you could query
// rows `0` to `9` and receive vectors that can hold a total of at least `5` elements.
let _ = m.row(4);

// But accessing columns doesn't work, as there is no continuous view in memory.
// m.column(3); --> panic!

// However, you can always get a flat view of the matrix, for "scalar-speed"
// query and update all elements:
let mut m_flat = m.flat_mut();

m_flat[(2, 4)] = 42_f32;

Implementations§

Source§

impl<T, O> MatSimd<T, O>
where T: Simd + Default + Clone, O: AccessStrategy,

Source

pub fn with_dimension(width: usize, height: usize) -> Self

Creates a new MatSimd with the given dimension.

Source

pub fn dimension(&self) -> (usize, usize)

Returns the size as (rows, columns).

Source

pub const fn flat(&self) -> MatFlat<'_, T, O>

Provides a flat, immutable view of the contained data.

Source

pub fn flat_mut(&mut self) -> MatFlatMut<'_, T, O>

Provides a flat mutable view of the contained data.

Source§

impl<T> MatSimd<T, Rows>
where T: Simd + Default + Clone,

Source

pub fn row(&self, i: usize) -> &[T]

Source

pub const fn row_iter(&self) -> Matrix2DIter<'_, T, Rows>

Source

pub fn row_mut(&mut self, i: usize) -> &mut [T]

Source

pub fn row_as_flat(&self, i: usize) -> &[T::Element]

Source

pub fn row_as_flat_mut(&mut self, i: usize) -> &mut [T::Element]

Source§

impl<T> MatSimd<T, Columns>
where T: Simd + Default + Clone,

Source

pub fn column(&self, i: usize) -> &[T]

Source

pub const fn column_iter(&self) -> Matrix2DIter<'_, T, Columns>

Source

pub fn column_mut(&mut self, i: usize) -> &mut [T]

Source

pub fn column_as_flat(&self, i: usize) -> &[T::Element]

Source

pub fn column_as_flat_mut(&mut self, i: usize) -> &mut [T::Element]

Trait Implementations§

Source§

impl<T, A> Clone for MatSimd<T, A>
where T: Simd + Default + Clone + Clone, A: AccessStrategy + Clone,

Source§

fn clone(&self) -> MatSimd<T, A>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T, A> Debug for MatSimd<T, A>
where T: Simd + Default + Clone + Debug, A: AccessStrategy + Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, A> Freeze for MatSimd<T, A>

§

impl<T, A> RefUnwindSafe for MatSimd<T, A>

§

impl<T, A> Send for MatSimd<T, A>
where A: Send, T: Send,

§

impl<T, A> Sync for MatSimd<T, A>
where A: Sync, T: Sync,

§

impl<T, A> Unpin for MatSimd<T, A>
where A: Unpin, T: Unpin,

§

impl<T, A> UnwindSafe for MatSimd<T, A>
where A: UnwindSafe, T: UnwindSafe,

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 = 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.