Skip to main content

HasShape

Trait HasShape 

Source
pub trait HasShape {
    // Required methods
    fn num_dims(&self) -> usize;
    fn num_elements(&self) -> usize;
    fn get_dim(&self, total_dims: usize, i: usize) -> usize;
    fn shape(&self) -> &Shape;
}

Required Methods§

Source

fn num_dims(&self) -> usize

Return the number of dimensions

Source

fn num_elements(&self) -> usize

Return the number of elements

Source

fn get_dim(&self, total_dims: usize, i: usize) -> usize

Return the size of a given dimension within a larger space.

Assumes the defined shape are the inner dimensions and will return 1 when the specified dimension is out of the defined shape.

For example, a shape of the form [2, 4, 5] with calls: shape.get_dim(4, 0) will return 1 (dimension outside of defined shape) shape.get_dim(4, 1) will return 2 shape.get_dim(4, 2) will return 4 shape.get_dim(4, 3) will return 5

Source

fn shape(&self) -> &Shape

Get access to the underlying shape

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> HasShape for &T
where T: HasShape,

Source§

fn num_dims(&self) -> usize

Source§

fn num_elements(&self) -> usize

Source§

fn get_dim(&self, total_dims: usize, i: usize) -> usize

Source§

fn shape(&self) -> &Shape

Implementors§