Trait mdarray::Shape

source ·
pub trait Shape:
    Copy
    + Debug
    + Default
    + Send
    + Sync {
    type Head: Dim;
    type Tail: Shape;
    type Reverse: Shape;
    type Prepend<D: Dim>: Shape;
    type Merge<S: Shape>: Shape;
    type FromExpr<T>: FromExpression<T, Self>;
    type Layout<L: Layout, M: Layout>: Layout;
    type Dims: Dims;
    type Strides: Strides;

    const RANK: usize;

    // Required methods
    fn dims(self) -> Self::Dims;
    fn from_dims(dims: Self::Dims) -> Self;

    // Provided methods
    fn dim(self, index: usize) -> usize { ... }
    fn is_empty(self) -> bool { ... }
    fn len(self) -> usize { ... }
    fn rank(self) -> usize { ... }
}
Expand description

Array shape trait.

Required Associated Types§

source

type Head: Dim

First dimension.

source

type Tail: Shape

Shape excluding the first dimension.

source

type Reverse: Shape

Shape with the reverse ordering of dimensions.

source

type Prepend<D: Dim>: Shape

Prepend the dimension to the shape.

source

type Merge<S: Shape>: Shape

Merge each dimension pair, where constant size is preferred over dynamic. The result has dynamic rank if at least one of the inputs has dynamic rank.

source

type FromExpr<T>: FromExpression<T, Self>

The resulting type after conversion from an expression.

source

type Layout<L: Layout, M: Layout>: Layout

Select layout Dense, L, or M for rank 0, 1, or >1 respectively.

source

type Dims: Dims

Array dimensions type.

source

type Strides: Strides

Array strides type.

Required Associated Constants§

source

const RANK: usize

Array rank, i.e. the number of dimensions.

Required Methods§

source

fn dims(self) -> Self::Dims

Returns the number of elements in each dimension.

source

fn from_dims(dims: Self::Dims) -> Self

Creates an array shape with the given dimensions.

§Panics

Panics if the dimensions are not matching constant-sized dimensions.

Provided Methods§

source

fn dim(self, index: usize) -> usize

Returns the number of elements in the specified dimension.

§Panics

Panics if the dimension is out of bounds.

source

fn is_empty(self) -> bool

Returns true if the array contains no elements.

source

fn len(self) -> usize

Returns the number of elements in the array.

source

fn rank(self) -> usize

Returns the array rank, i.e. the number of dimensions.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Shape for ()

§

type Head = Dyn

§

type Tail = ()

§

type Reverse = ()

§

type Prepend<D: Dim> = D

§

type Merge<S: Shape> = S

§

type FromExpr<T> = Array<T, ()>

§

type Layout<L: Layout, M: Layout> = Dense

§

type Dims = [usize; 0]

§

type Strides = [isize; 0]

source§

const RANK: usize = 0usize

source§

fn dims(self) -> [usize; 0]

source§

fn from_dims(_: [usize; 0]) -> Self

source§

impl<X: Dim, Y: Dim> Shape for (X, Y)

§

type Head = X

§

type Tail = Y

§

type Reverse = (Y, X)

§

type Prepend<D: Dim> = (D, X, Y)

§

type Merge<S: Shape> = <<<(X, Y) as Shape>::Tail as Shape>::Merge<<S as Shape>::Tail> as Shape>::Prepend<<X as Dim>::Merge<<S as Shape>::Head>>

§

type FromExpr<T> = <X as Dim>::FromExpr<T, <(X, Y) as Shape>::Tail>

§

type Layout<L: Layout, M: Layout> = M

§

type Dims = [usize; 2]

§

type Strides = [isize; 2]

source§

const RANK: usize = 2usize

source§

fn dims(self) -> [usize; 2]

source§

fn from_dims(dims: [usize; 2]) -> Self

source§

impl<X: Dim, Y: Dim, Z: Dim> Shape for (X, Y, Z)

§

type Head = X

§

type Tail = (Y, Z)

§

type Reverse = (Z, Y, X)

§

type Prepend<D: Dim> = (D, X, Y, Z)

§

type Merge<S: Shape> = <<<(X, Y, Z) as Shape>::Tail as Shape>::Merge<<S as Shape>::Tail> as Shape>::Prepend<<X as Dim>::Merge<<S as Shape>::Head>>

§

type FromExpr<T> = <X as Dim>::FromExpr<T, <(X, Y, Z) as Shape>::Tail>

§

type Layout<L: Layout, M: Layout> = M

§

type Dims = [usize; 3]

§

type Strides = [isize; 3]

source§

const RANK: usize = 3usize

source§

fn dims(self) -> [usize; 3]

source§

fn from_dims(dims: [usize; 3]) -> Self

source§

impl<X: Dim, Y: Dim, Z: Dim, W: Dim> Shape for (X, Y, Z, W)

§

type Head = X

§

type Tail = (Y, Z, W)

§

type Reverse = (W, Z, Y, X)

§

type Prepend<D: Dim> = (D, X, Y, Z, W)

§

type Merge<S: Shape> = <<<(X, Y, Z, W) as Shape>::Tail as Shape>::Merge<<S as Shape>::Tail> as Shape>::Prepend<<X as Dim>::Merge<<S as Shape>::Head>>

§

type FromExpr<T> = <X as Dim>::FromExpr<T, <(X, Y, Z, W) as Shape>::Tail>

§

type Layout<L: Layout, M: Layout> = M

§

type Dims = [usize; 4]

§

type Strides = [isize; 4]

source§

const RANK: usize = 4usize

source§

fn dims(self) -> [usize; 4]

source§

fn from_dims(dims: [usize; 4]) -> Self

source§

impl<X: Dim, Y: Dim, Z: Dim, W: Dim, U: Dim> Shape for (X, Y, Z, W, U)

§

type Head = X

§

type Tail = (Y, Z, W, U)

§

type Reverse = (U, W, Z, Y, X)

§

type Prepend<D: Dim> = (D, X, Y, Z, W, U)

§

type Merge<S: Shape> = <<<(X, Y, Z, W, U) as Shape>::Tail as Shape>::Merge<<S as Shape>::Tail> as Shape>::Prepend<<X as Dim>::Merge<<S as Shape>::Head>>

§

type FromExpr<T> = <X as Dim>::FromExpr<T, <(X, Y, Z, W, U) as Shape>::Tail>

§

type Layout<L: Layout, M: Layout> = M

§

type Dims = [usize; 5]

§

type Strides = [isize; 5]

source§

const RANK: usize = 5usize

source§

fn dims(self) -> [usize; 5]

source§

fn from_dims(dims: [usize; 5]) -> Self

source§

impl<X: Dim, Y: Dim, Z: Dim, W: Dim, U: Dim, V: Dim> Shape for (X, Y, Z, W, U, V)

§

type Head = X

§

type Tail = (Y, Z, W, U, V)

§

type Reverse = (V, U, W, Z, Y, X)

§

type Prepend<D: Dim> = (D, X, Y, Z, W, U)

§

type Merge<S: Shape> = <<<(X, Y, Z, W, U, V) as Shape>::Tail as Shape>::Merge<<S as Shape>::Tail> as Shape>::Prepend<<X as Dim>::Merge<<S as Shape>::Head>>

§

type FromExpr<T> = <X as Dim>::FromExpr<T, <(X, Y, Z, W, U, V) as Shape>::Tail>

§

type Layout<L: Layout, M: Layout> = M

§

type Dims = [usize; 6]

§

type Strides = [isize; 6]

source§

const RANK: usize = 6usize

source§

fn dims(self) -> [usize; 6]

source§

fn from_dims(dims: [usize; 6]) -> Self

Implementors§

source§

impl<X: Dim> Shape for X

§

type Head = X

§

type Tail = ()

§

type Reverse = X

§

type Prepend<D: Dim> = (D, X)

§

type Merge<S: Shape> = <<S as Shape>::Tail as Shape>::Prepend<<X as Dim>::Merge<<S as Shape>::Head>>

§

type FromExpr<T> = <X as Dim>::FromExpr<T, ()>

§

type Layout<L: Layout, M: Layout> = L

§

type Dims = [usize; 1]

§

type Strides = [isize; 1]

source§

const RANK: usize = 1usize