Trait extendr_api::prelude::Dimension

source ·
pub trait Dimension:
    Clone
    + Eq
    + Debug
    + Send
    + Sync
    + Default
    + IndexMut<usize, Output = usize>
    + Add<Output = Self>
    + AddAssign
    + for<'x> AddAssign<&'x Self>
    + Sub<Output = Self>
    + SubAssign
    + for<'x> SubAssign<&'x Self>
    + Mul<usize, Output = Self, Output = Self>
    + Mul
    + MulAssign
    + for<'x> MulAssign<&'x Self>
    + MulAssign<usize>
    + DimMax<Dim<[usize; 0]>, Output = Self, Output = Self, Output = Dim<IxDynImpl>, Output = Self, Output = Self::Larger>
    + DimMax<Self>
    + DimMax<Dim<IxDynImpl>>
    + DimMax<Self::Smaller>
    + DimMax<Self::Larger>
    + DimAdd<Self, Output = Self, Output = Self::Larger, Output = Dim<IxDynImpl>>
    + DimAdd<Self::Smaller>
    + DimAdd<Self::Larger>
    + DimAdd<Dim<[usize; 0]>>
    + DimAdd<Dim<[usize; 1]>>
    + DimAdd<Dim<IxDynImpl>> {
    type Pattern: IntoDimension<Dim = Self> + Clone + Debug + PartialEq + Eq + Default;
    type Smaller: Dimension;
    type Larger: Dimension + RemoveAxis;

    const NDIM: Option<usize>;

    // Required methods
    fn ndim(&self) -> usize;
    fn into_pattern(self) -> Self::Pattern;
    fn zeros(ndim: usize) -> Self;

    // Provided methods
    fn size(&self) -> usize { ... }
    fn size_checked(&self) -> Option<usize> { ... }
    fn as_array_view(&self) -> ArrayBase<ViewRepr<&usize>, Dim<[usize; 1]>> { ... }
    fn as_array_view_mut(
        &mut self,
    ) -> ArrayBase<ViewRepr<&mut usize>, Dim<[usize; 1]>> { ... }
    fn into_dyn(self) -> Dim<IxDynImpl> { ... }
}
Expand description

Array shape and index trait.

This trait defines a number of methods and operations that can be used on dimensions and indices.

Note: This trait can not be implemented outside the crate

Required Associated Types§

source

type Pattern: IntoDimension<Dim = Self> + Clone + Debug + PartialEq + Eq + Default

Pattern matching friendly form of the dimension value.

  • For Ix1: usize,
  • For Ix2: (usize, usize)
  • and so on..
  • For IxDyn: IxDyn
source

type Smaller: Dimension

Next smaller dimension (if applicable)

source

type Larger: Dimension + RemoveAxis

Next larger dimension

Required Associated Constants§

source

const NDIM: Option<usize>

For fixed-size dimension representations (e.g. Ix2), this should be Some(ndim), and for variable-size dimension representations (e.g. IxDyn), this should be None.

Required Methods§

source

fn ndim(&self) -> usize

Returns the number of dimensions (number of axes).

source

fn into_pattern(self) -> Self::Pattern

Convert the dimension into a pattern matching friendly value.

source

fn zeros(ndim: usize) -> Self

Creates a dimension of all zeros with the specified ndim.

This method is useful for generalizing over fixed-size and variable-size dimension representations.

Panics if Self has a fixed size that is not ndim.

Provided Methods§

source

fn size(&self) -> usize

Compute the size of the dimension (number of elements)

source

fn size_checked(&self) -> Option<usize>

Compute the size while checking for overflow.

source

fn as_array_view(&self) -> ArrayBase<ViewRepr<&usize>, Dim<[usize; 1]>>

Borrow as a read-only array view.

source

fn as_array_view_mut( &mut self, ) -> ArrayBase<ViewRepr<&mut usize>, Dim<[usize; 1]>>

Borrow as a read-write array view.

source

fn into_dyn(self) -> Dim<IxDynImpl>

Convert the dimensional into a dynamic dimensional (IxDyn).

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Dimension for Dim<IxDynImpl>

IxDyn is a “dynamic” index, pretty hard to use when indexing, and memory wasteful, but it allows an arbitrary and dynamic number of axes.

source§

impl Dimension for Dim<[usize; 0]>

source§

impl Dimension for Dim<[usize; 1]>

source§

impl Dimension for Dim<[usize; 2]>

source§

impl Dimension for Dim<[usize; 3]>

source§

impl Dimension for Dim<[usize; 4]>

source§

impl Dimension for Dim<[usize; 5]>

source§

impl Dimension for Dim<[usize; 6]>