pub struct MapIndex<'a, T: Broadcastable<N>, F: Fn([usize; M], [usize; M]) -> [usize; N], const N: usize, const M: usize> { /* private fields */ }Expand description
Return type of mapindex.
Implementations§
Trait Implementations§
Source§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>
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>
type Element = <T as Broadcastable<N>>::Element
Source§fn bget(&self, index: [usize; M]) -> Option<T::Element>
fn bget(&self, index: [usize; M]) -> Option<T::Element>
This should return none iff the default
inbounds method returns false.
Source§fn mod_bget(&self, index: [isize; DIM]) -> Self::Element
fn mod_bget(&self, index: [isize; DIM]) -> Self::Element
Takes indices modulo size. Useful for periodic shifts of indices.
Source§fn feedto(
&self,
receiver: &mut impl BroadcastReceiver<DIM, Element = Self::Element>,
) -> Option<()>
fn feedto( &self, receiver: &mut impl BroadcastReceiver<DIM, Element = Self::Element>, ) -> Option<()>
Writes the contents of the Broadcastable to a receiver, such as an actual (multidimensional) array.
Source§fn lazy_updim<const NEWDIM: usize>(
&self,
size: [usize; NEWDIM],
) -> LazyUpdim<'_, Self, DIM, NEWDIM>
fn lazy_updim<const NEWDIM: usize>( &self, size: [usize; NEWDIM], ) -> LazyUpdim<'_, Self, DIM, NEWDIM>
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.
Source§fn reshaped<const NEWDIM: usize>(
self,
size: [usize; NEWDIM],
) -> ReShaped<Self, NEWDIM, DIM>
fn reshaped<const NEWDIM: usize>( self, size: [usize; NEWDIM], ) -> ReShaped<Self, NEWDIM, DIM>
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.
Source§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 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>
Provides a more flexible but less safe way to reshape a broadcastable.
Useful for slicing and dicing arrays and broadcastables, taking diagonals, etc etc.
Source§fn offset_mod(&self, offset: [isize; DIM]) -> OffsetBroadcast<'_, Self, DIM>
fn offset_mod(&self, offset: [isize; DIM]) -> OffsetBroadcast<'_, Self, DIM>
Returns a new broadcast which is periodically offset by offset.
Source§fn bmap<T, F: Fn(Self::Element) -> T>(
&self,
foo: F,
) -> BMap<'_, T, Self, F, DIM>
fn bmap<T, F: Fn(Self::Element) -> T>( &self, foo: F, ) -> BMap<'_, T, Self, F, DIM>
Elements of returned broadcastable are the output of the provided closure,
applied to the input broadcastable.
Source§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 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>
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.
Source§fn bc_iter(&self) -> BroadcastIterator<'_, Self, DIM> ⓘ
fn bc_iter(&self) -> BroadcastIterator<'_, Self, DIM> ⓘ
Takes a broadcastable and returns an iterator over its elements.
Source§impl<'b, 'a, T: Broadcastable<N>, F: Fn([usize; M], [usize; M]) -> [usize; N], const N: usize, const M: usize> IntoIterator for &'b MapIndex<'a, T, F, N, M>
impl<'b, 'a, T: Broadcastable<N>, F: Fn([usize; M], [usize; M]) -> [usize; N], const N: usize, const M: usize> IntoIterator for &'b MapIndex<'a, T, F, N, M>
Source§type Item = <T as Broadcastable<N>>::Element
type Item = <T as Broadcastable<N>>::Element
The type of the elements being iterated over.
Source§type IntoIter = BroadcastIterator<'b, MapIndex<'a, T, F, N, M>, M>
type IntoIter = BroadcastIterator<'b, MapIndex<'a, T, F, N, M>, M>
Which kind of iterator are we turning this into?
Source§impl<'a, T: Broadcastable<N>, F: Fn([usize; M], [usize; M]) -> [usize; N], const N: usize, const M: usize> TensorDimension for MapIndex<'a, T, F, N, M>
impl<'a, T: Broadcastable<N>, F: Fn([usize; M], [usize; M]) -> [usize; N], const N: usize, const M: usize> TensorDimension for MapIndex<'a, T, F, N, M>
Auto Trait Implementations§
impl<'a, T, F, const N: usize, const M: usize> Freeze for MapIndex<'a, T, F, N, M>where
F: Freeze,
impl<'a, T, F, const N: usize, const M: usize> RefUnwindSafe for MapIndex<'a, T, F, N, M>where
F: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T, F, const N: usize, const M: usize> Send for MapIndex<'a, T, F, N, M>
impl<'a, T, F, const N: usize, const M: usize> Sync for MapIndex<'a, T, F, N, M>
impl<'a, T, F, const N: usize, const M: usize> Unpin for MapIndex<'a, T, F, N, M>where
F: Unpin,
impl<'a, T, F, const N: usize, const M: usize> UnwindSafe for MapIndex<'a, T, F, N, M>where
F: UnwindSafe,
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more