pub struct MatSimd<T, A>{ /* 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>
impl<T, O> MatSimd<T, O>
Sourcepub fn with_dimension(width: usize, height: usize) -> Self
pub fn with_dimension(width: usize, height: usize) -> Self
Creates a new MatSimd with the given dimension.
Sourcepub const fn flat(&self) -> MatFlat<'_, T, O>
pub const fn flat(&self) -> MatFlat<'_, T, O>
Provides a flat, immutable view of the contained data.
Sourcepub fn flat_mut(&mut self) -> MatFlatMut<'_, T, O>
pub fn flat_mut(&mut self) -> MatFlatMut<'_, T, O>
Provides a flat mutable view of the contained data.
Source§impl<T> MatSimd<T, Columns>
impl<T> MatSimd<T, Columns>
pub fn column(&self, i: usize) -> &[T]
pub const fn column_iter(&self) -> Matrix2DIter<'_, T, Columns>
pub fn column_mut(&mut self, i: usize) -> &mut [T]
pub fn column_as_flat(&self, i: usize) -> &[T::Element]
pub fn column_as_flat_mut(&mut self, i: usize) -> &mut [T::Element]
Trait Implementations§
Auto Trait Implementations§
impl<T, A> Freeze for MatSimd<T, A>
impl<T, A> RefUnwindSafe for MatSimd<T, A>where
A: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, A> Send for MatSimd<T, A>
impl<T, A> Sync for MatSimd<T, A>
impl<T, A> Unpin for MatSimd<T, A>
impl<T, A> UnwindSafe for MatSimd<T, A>where
A: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more