Struct simd_aligned::MatrixD

source ·
pub struct MatrixD<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 MatrixD 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

#![feature(portable_simd)]
use std::simd::*;
use simd_aligned::*;

// Create a matrix of height 10x`f32` and width 5x`f32`, optimized for row access.
let mut m = MatrixD::<f32s, 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> MatrixD<T, O>where T: Simd + Default + Clone, O: AccessStrategy,

source

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

Creates a new MatrixD with the given dimension.

source

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

Returns the size as (rows, columns).

source

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

Provides a flat, immutable view of the contained data.

source

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

Provides a flat mutable view of the contained data.

source§

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

source

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

source

pub 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> MatrixD<T, Columns>where T: Simd + Default + Clone,

source

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

source

pub 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 MatrixD<T, A>where T: Simd + Default + Clone + Clone, A: AccessStrategy + Clone,

source§

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

Returns a copy 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 MatrixD<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> RefUnwindSafe for MatrixD<T, A>where A: RefUnwindSafe, T: RefUnwindSafe,

§

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

§

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

§

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

§

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

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.