Tensor

Trait Tensor 

Source
pub trait Tensor<T, V: Copy + Unit + Add<Output = V> + Sub<Output = V> + PartialOrd, A: Address<V, DIMENSION>, const DIMENSION: usize>: IndexMut<A, Output = T> {
    // Required methods
    fn range(&self) -> Range<A>;
    fn get(&self, address: A) -> Option<&T>;
    fn get_mut(&mut self, address: A) -> Option<&mut T>;

    // Provided method
    fn contains(&self, address: A) -> bool { ... }
}
Expand description

Tensor is a generic multidimensional data store trait. Think of it as a shared interface for a vector, a matrix, a cube, and a hypercube.

Required Methods§

Source

fn range(&self) -> Range<A>

range provides the bounds of the address space for the Tensor. The lower (inclusive bound) is the origin, conceptually placed at the left of a vector, the upper left of a matrix, and so on. That lower bound is conventionally zero-based, but does not have to be. The upper bound (exclusive) is the right side of the vector, the lower right of the matrix, etc. Be aware that while Range provides iterator functionality, once you move beyond single-dimension Tensors, that iterator does not provide the correct iteration of available addresses.

Source

fn get(&self, address: A) -> Option<&T>

An out-of-range-safe version of the Index trait.

Source

fn get_mut(&mut self, address: A) -> Option<&mut T>

An out-of-range-safe version of the IndexMut trait.

Provided Methods§

Source

fn contains(&self, address: A) -> bool

contains is true if the given address is within the Tensor’s bounds for all dimensions.

Implementors§

Source§

impl<'a, T: 'a, I> Tensor<T, I, MatrixAddress<I>, 2> for DenseMatrix<T, I>
where I: Coordinate,