Trait container_broadcast::broadcast::Broadcastable[][src]

pub trait Broadcastable<const DIM: usize>: TensorSize<DIM> + Sized {
    type Element;
    fn bget(&self, index: [usize; DIM]) -> Option<Self::Element>;

    fn mod_bget(&self, index: [isize; DIM]) -> Self::Element { ... }
fn feedto(
        &self,
        receiver: &mut impl BroadcastReceiver<DIM, Element = Self::Element>
    ) -> Option<()> { ... }
fn lazy_updim<const NEWDIM: usize>(
        &self,
        size: [usize; NEWDIM]
    ) -> LazyUpdim<'_, Self, DIM, NEWDIM> { ... }
fn reshaped<const NEWDIM: usize>(
        self,
        size: [usize; NEWDIM]
    ) -> ReShaped<Self, NEWDIM, DIM> { ... }
fn mapindex<F: Fn([usize; M], [usize; M]) -> [usize; DIM], const M: usize>(
        &self,
        indexclosure: F,
        sizeclosure: impl Fn([usize; DIM]) -> [usize; M]
    ) -> MapIndex<'_, Self, F, DIM, M> { ... }
fn offset_mod(&self, offset: [isize; DIM]) -> OffsetBroadcast<'_, Self, DIM> { ... }
fn bmap<T, F: Fn(Self::Element) -> T>(
        &self,
        foo: F
    ) -> BMap<'_, T, Self, F, DIM> { ... }
fn bcloned(self) -> BCloned<Self, DIM> { ... }
fn broadcast2<'a, 'b, T: Broadcastable<N>, const N: usize>(
        &'a self,
        foo: &'b T
    ) -> Broadcast2<LazyUpdim<'a, Self, DIM, DIM>, LazyUpdim<'b, T, N, DIM>, DIM> { ... }
fn bc_iter(&self) -> BroadcastIterator<'_, Self, DIM>

Notable traits for BroadcastIterator<'a, T, DIM>

impl<'a, T: Broadcastable<DIM>, const DIM: usize> Iterator for BroadcastIterator<'a, T, DIM> type Item = T::Element;
{ ... } }

The main trait of this crate. Somehat like iterator, is effectively a lazy multidimensional array-like object instead of a lazy sequence. You can map over functions, zip them, take cartesian products, etc etc in a way that does not erase structure, and produces another object with random access indexing unlike iterators.

Associated Types

Loading content...

Required methods

fn bget(&self, index: [usize; DIM]) -> Option<Self::Element>[src]

This should return none iff the default inbounds method returns false.

Loading content...

Provided methods

fn mod_bget(&self, index: [isize; DIM]) -> Self::Element[src]

Takes indices modulo size. Useful for periodic shifts of indices.

fn feedto(
    &self,
    receiver: &mut impl BroadcastReceiver<DIM, Element = Self::Element>
) -> Option<()>
[src]

Writes the contents of the Broadcastable to a receiver, such as an actual (multidimensional) array.

fn lazy_updim<const NEWDIM: usize>(
    &self,
    size: [usize; NEWDIM]
) -> LazyUpdim<'_, Self, DIM, NEWDIM>
[src]

Returns an object with the provided size. If NEWDIM > Self::DIM, the additional indices are ignored. All entries of size input must be either equal to the size of input, except for entries where the original size was 1.

fn reshaped<const NEWDIM: usize>(
    self,
    size: [usize; NEWDIM]
) -> ReShaped<Self, NEWDIM, DIM>
[src]

The main way to create multidimensional arrays with this crate, but can resize any broadcastable. Resized broadcastables must have the same number of elements as the old one. Preserves iteration order. Reshapes a broadcastable by linearizing and delinearizing indices.

fn mapindex<F: Fn([usize; M], [usize; M]) -> [usize; DIM], const M: usize>(
    &self,
    indexclosure: F,
    sizeclosure: impl Fn([usize; DIM]) -> [usize; M]
) -> MapIndex<'_, Self, F, DIM, M>
[src]

Provides a more flexible but less safe way to reshape a broadcastable. Useful for slicing and dicing arrays and broadcastables, taking diagonals, etc etc.

fn offset_mod(&self, offset: [isize; DIM]) -> OffsetBroadcast<'_, Self, DIM>[src]

Returns a new broadcast which is periodically offset by offset.

fn bmap<T, F: Fn(Self::Element) -> T>(
    &self,
    foo: F
) -> BMap<'_, T, Self, F, DIM>
[src]

Elements of returned broadcastable are the output of the provided closure, applied to the input broadcastable.

fn bcloned(self) -> BCloned<Self, DIM>[src]

For inputs whose elements are references, clones them.

fn broadcast2<'a, 'b, T: Broadcastable<N>, const N: usize>(
    &'a self,
    foo: &'b T
) -> Broadcast2<LazyUpdim<'a, Self, DIM, DIM>, LazyUpdim<'b, T, N, DIM>, DIM>
[src]

Unique operation not found in Iterators. If the dimensions of the two broadcastable, zips them. If not, will lazy_updim all inputs to the same size. As such, can also provide cartesian or tensor products depending on input. NEW CONSTRAINT IN v0.0.6: N must be smaller than DIM, CHECKED AT RUNTIME. The argument with higher Self::DIM must be first. This is partly to eliminate use of nightly features, and because the Rust type system often cannot prove equality.

fn bc_iter(&self) -> BroadcastIterator<'_, Self, DIM>

Notable traits for BroadcastIterator<'a, T, DIM>

impl<'a, T: Broadcastable<DIM>, const DIM: usize> Iterator for BroadcastIterator<'a, T, DIM> type Item = T::Element;
[src]

Takes a broadcastable and returns an iterator over its elements.

Loading content...

Implementations on Foreign Types

impl<'a, T> Broadcastable<1_usize> for &'a [T][src]

type Element = &'a T

impl<'a, T, const N: usize> Broadcastable<1_usize> for &'a [T; N][src]

type Element = &'a T

impl<T: Copy, const N: usize> Broadcastable<1_usize> for [T; N][src]

type Element = T

impl<'a, T> Broadcastable<1_usize> for &'a Vec<T>[src]

type Element = &'a T

impl<T: Copy> Broadcastable<1_usize> for Vec<T>[src]

type Element = T

Loading content...

Implementors

impl<'a, R, T: Broadcastable<DIM>, F: Fn(T::Element) -> R, const DIM: usize> Broadcastable<DIM> for BMap<'a, R, T, F, DIM>[src]

type Element = R

impl<'a, T: Broadcastable<N>, F: Fn([usize; M], [usize; M]) -> [usize; N], const N: usize, const M: usize> Broadcastable<M> for MapIndex<'a, T, F, N, M>[src]

type Element = T::Element

impl<'a, T: Broadcastable<N>, const N: usize> Broadcastable<N> for OffsetBroadcast<'a, T, N>[src]

type Element = T::Element

impl<'a, T: Broadcastable<OLDDIM>, const OLDDIM: usize, const DIM: usize> Broadcastable<DIM> for LazyUpdim<'a, T, OLDDIM, DIM>[src]

type Element = T::Element

impl<'b, T: Broadcastable<N, Element = &'b E>, E: 'b + Clone, const N: usize> Broadcastable<N> for BCloned<T, N>[src]

type Element = E

impl<A: Broadcastable<N>, B: Broadcastable<N>, const N: usize> Broadcastable<N> for Broadcast2<A, B, N>[src]

type Element = (A::Element, B::Element)

impl<A: Broadcastable<N>, const N: usize, const K: usize> Broadcastable<N> for BroadcastK<A, N, K>[src]

type Element = [A::Element; K]

impl<T, F: Fn([usize; N]) -> T, const N: usize> Broadcastable<N> for BroadcastClosure<T, F, N>[src]

type Element = T

impl<T: Broadcastable<M>, const N: usize, const M: usize> Broadcastable<N> for ReShaped<T, N, M>[src]

type Element = T::Element

Loading content...