Skip to main content

TensorIndex

Trait TensorIndex 

Source
pub trait TensorIndex<const N: usize, const R: usize> {
    type Indices: IndexIterator<R>;

    // Required methods
    fn offset_from_index(index: [usize; R]) -> usize;
    fn indices() -> Self::Indices;

    // Provided methods
    fn count() -> usize { ... }
    fn for_each_index(f: impl FnMut([usize; R])) { ... }
}

Required Associated Types§

Source

type Indices: IndexIterator<R>

Type of iterator over valid tensor indices.

Required Methods§

Source

fn offset_from_index(index: [usize; R]) -> usize

Converts a valid index into a buffer offset for tensor storage.

Source

fn indices() -> Self::Indices

Iterates over all (unique) indices in the tensor. This must index the tensor in the same order as Self::offset_from_index.

Provided Methods§

Source

fn count() -> usize

Counts all unique indices used to store the tensor.

Source

fn for_each_index(f: impl FnMut([usize; R]))

Calls a function for each index in the tensor. Must index over the tensor in the same order as Self::indices.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<const N: usize, const R: usize> TensorIndex<N, R> for Gen

Source§

impl<const N: usize, const T: usize, const L: usize, const R: usize, Left, Right> TensorIndex<N, T> for Compound<T, L, R, Left, Right>
where Left: TensorIndex<N, L>, Right: TensorIndex<N, R>, CSum: CompoundSum<T, L, R>,

Source§

type Indices = CompoundIndices<N, T, L, R, <Left as TensorIndex<N, L>>::Indices, <Right as TensorIndex<N, R>>::Indices>

Source§

impl<const N: usize> TensorIndex<N, 2> for Sym