Struct MultiArray

Source
pub struct MultiArray<T, A>
where A: LayoutHelper,
{ /* private fields */ }
Expand description

Type for multi-dimensional arrays that are organized linearly in memory much like a C array but with dynamically determined sizes.

§Example

use multiarray::*;

let mut matrix = Array2D::new([3, 2], 0);
matrix[[0,0]] = 1; matrix[[0,1]] = 2;
matrix[[1,0]] = 3; matrix[[1,1]] = 4;
matrix[[2,0]] = 5; matrix[[2,1]] = 6;

Implementations§

Source§

impl<T, A> MultiArray<T, A>
where T: Clone, A: LayoutHelper,

Source

pub fn new<X>(extents: X, fill: T) -> Self
where X: Into<A::U>,

Create new multi-dimensiopnal array with the given extents (one per dimension)

Source§

impl<T, A> MultiArray<T, A>
where A: LayoutHelper,

Source

pub fn extents(&self) -> &[usize]

get the array’s extents (one item per dimension)

Source

pub fn borrow(&self) -> MultiArrayRef<'_, T, A>

create a shared view that allows further manipulations of the view

Source

pub fn borrow_mut(&mut self) -> MultiArrayRefMut<'_, T, A>

create a mutable view that allows further manipulations of the view

Source

pub fn reversed_dim(&self, dim: usize) -> MultiArrayRef<'_, T, A>

Create a shared view where one given dimension is reversed

Source

pub fn reversed_dim_mut(&mut self, dim: usize) -> MultiArrayRefMut<'_, T, A>

Create a mutable view where one given dimension is reversed

Source

pub fn subsampled_dim( &self, dim: usize, factor: usize, ) -> MultiArrayRef<'_, T, A>

Create a shared view where one given dimension is subsampled by a given factor

Source

pub fn subsampled_dim_mut( &mut self, dim: usize, factor: usize, ) -> MultiArrayRefMut<'_, T, A>

Create a shared view where one given dimension is subsampled by a given factor

Source

pub fn sliced_dim<R>(&self, dim: usize, range: R) -> MultiArrayRef<'_, T, A>
where R: AnyRange<usize>,

Create a shared view where one given dimension is sliced

Source

pub fn sliced_dim_mut<R>( &mut self, dim: usize, range: R, ) -> MultiArrayRefMut<'_, T, A>
where R: AnyRange<usize>,

Create a mutable view where one given dimension is sliced

Source

pub fn swapped_dims(&self, d1: usize, d2: usize) -> MultiArrayRef<'_, T, A>

Create a shared view where the order of two dimensions are swapped

Source

pub fn swapped_dims_mut( &mut self, d1: usize, d2: usize, ) -> MultiArrayRefMut<'_, T, A>

Create a mutable view where the order of two dimensions are swapped

Source§

impl<T, A> MultiArray<T, A>
where A: LayoutHelperExt,

Source

pub fn eliminated_dim( &self, dim: usize, coord: usize, ) -> MultiArrayRef<'_, T, A::OneLess>

Create a lower-dimensional shared view where one dimension is fixed at the given coordinate.

Source

pub fn eliminated_dim_mut( &mut self, dim: usize, coord: usize, ) -> MultiArrayRefMut<'_, T, A::OneLess>

Create a lower-dimensional mutable view where one dimension is fixed at the given coordinate.

Trait Implementations§

Source§

impl<'a, T, A: LayoutHelper> From<&'a MultiArray<T, A>> for MultiArrayRef<'a, T, A>

Source§

fn from(ma: &'a MultiArray<T, A>) -> Self

Converts to this type from the input type.
Source§

impl<'a, T, A: LayoutHelper> From<&'a mut MultiArray<T, A>> for MultiArrayRef<'a, T, A>

Source§

fn from(ma: &'a mut MultiArray<T, A>) -> Self

Converts to this type from the input type.
Source§

impl<'a, T, A: LayoutHelper> From<&'a mut MultiArray<T, A>> for MultiArrayRefMut<'a, T, A>

Source§

fn from(ma: &'a mut MultiArray<T, A>) -> Self

Converts to this type from the input type.
Source§

impl<T, A, I> Index<I> for MultiArray<T, A>
where A: LayoutHelper, I: Into<A::U>,

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: I) -> &T

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

impl<T, A, I> IndexMut<I> for MultiArray<T, A>
where A: LayoutHelper, I: Into<A::U>,

Source§

fn index_mut(&mut self, index: I) -> &mut T

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

Auto Trait Implementations§

§

impl<T, A> Freeze for MultiArray<T, A>
where <A as LayoutHelper>::U: Freeze, <A as LayoutHelper>::I: Freeze,

§

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

§

impl<T, A> Send for MultiArray<T, A>
where <A as LayoutHelper>::U: Send, <A as LayoutHelper>::I: Send, T: Send,

§

impl<T, A> Sync for MultiArray<T, A>
where <A as LayoutHelper>::U: Sync, <A as LayoutHelper>::I: Sync, T: Sync,

§

impl<T, A> Unpin for MultiArray<T, A>
where <A as LayoutHelper>::U: Unpin, <A as LayoutHelper>::I: Unpin,

§

impl<T, A> UnwindSafe for MultiArray<T, A>

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.