Skip to main content

DimOffset

Trait DimOffset 

Source
pub trait DimOffset<const N: usize>: Collection {
    // Required method
    fn offset<V2>(&self, md_index: &V2) -> Self::Scalar
       where V2: ArrayRef<Self::Scalar, N> + Collection<Scalar = Self::Scalar> + Debug + ?Sized;
}
Expand description

Trait for converting a multidimensional index into a flat offset.

This trait is implemented for arrays of any dimension, allowing conversion of a multidimensional index into a single linear offset. It is useful for mapping coordinates in a multidimensional space to a flat array.

Required Methods§

Source

fn offset<V2>(&self, md_index: &V2) -> Self::Scalar
where V2: ArrayRef<Self::Scalar, N> + Collection<Scalar = Self::Scalar> + Debug + ?Sized,

Converts a multidimensional index into a flat offset.

§Arguments
  • md_index: A reference to a vector representing the multidimensional index.
§Returns

A scalar value representing the flat offset.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<E, V, const N: usize> DimOffset<N> for V
where Self: Collection<Scalar = E> + Debug, E: Mul<E, Output = E> + Add<E, Output = E> + PartialOrd + Copy + Default + From<u8>, V: ArrayRef<E, N> + Collection<Scalar = E> + Debug + ?Sized,

Implementation of DimOffset for arrays of any dimension.

This implementation calculates the flat offset by iterating over the dimensions in reverse order, ensuring that the most significant dimension is processed last.