ReShaped

Struct ReShaped 

Source
pub struct ReShaped<T: Broadcastable<M>, const N: usize, const M: usize> { /* private fields */ }
Expand description

Return type of reshaped.

Trait Implementations§

Source§

impl<T: Broadcastable<M> + BroadcastReceiver<M>, const N: usize, const M: usize> BroadcastReceiver<N> for ReShaped<T, N, M>

Source§

type Element = <T as BroadcastReceiver<M>>::Element

Source§

fn bget_mut(&mut self, index: [usize; N]) -> Option<&mut Self::Element>

Source§

fn receive( &mut self, broadcast: &impl Broadcastable<DIM, Element = Self::Element>, ) -> Option<()>

Source§

unsafe fn bc_iter_mut<'a>(&'a mut self) -> BroadcastIterMut<'a, Self, DIM>

To be safe, the BroadcastReceiver must NOT alias bget_mut to the same underlying field for different inputs. You may implement a safe iter_mut method using this on any receiver where that invariant is preserved. If in doubt, use eachindex + bget_mut for a safe solution.
Source§

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

Source§

type Element = <T as Broadcastable<M>>::Element

Source§

fn bget(&self, index: [usize; N]) -> Option<T::Element>

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

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<()>

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>

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>

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>

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>

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>

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

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

For inputs whose elements are references, clones them.
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>

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>

Takes a broadcastable and returns an iterator over its elements.
Source§

impl<T: Clone + Broadcastable<M>, const N: usize, const M: usize> Clone for ReShaped<T, N, M>

Source§

fn clone(&self) -> ReShaped<T, N, M>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Broadcastable<M>, const N: usize, const M: usize> Debug for ReShaped<T, N, M>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, T: Broadcastable<M>, const N: usize, const M: usize> IntoIterator for &'a ReShaped<T, N, M>

Source§

type Item = <T as Broadcastable<M>>::Element

The type of the elements being iterated over.
Source§

type IntoIter = BroadcastIterator<'a, ReShaped<T, N, M>, N>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T: PartialEq + Broadcastable<M>, const N: usize, const M: usize> PartialEq for ReShaped<T, N, M>

Source§

fn eq(&self, other: &ReShaped<T, N, M>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Broadcastable<M>, const N: usize, const M: usize> TensorDimension for ReShaped<T, N, M>

Source§

const DIM: usize = N

Source§

const ISSCALAR: bool = _

Source§

fn is_scalar(&self) -> bool

Source§

impl<T: Broadcastable<M>, const N: usize, const M: usize> TensorSize<N> for ReShaped<T, N, M>

Source§

fn size(&self) -> [usize; N]

Source§

fn inbounds(&self, index: [usize; DIM]) -> bool

Source§

fn eachindex(&self) -> EachIndex<DIM>

Returns an iterator over all valid indices.
Source§

const VALIDDIMS: bool = _

If this is false, you have an invalid implementation.
Source§

impl<T: Eq + Broadcastable<M>, const N: usize, const M: usize> Eq for ReShaped<T, N, M>

Source§

impl<T: Broadcastable<M>, const N: usize, const M: usize> StructuralPartialEq for ReShaped<T, N, M>

Auto Trait Implementations§

§

impl<T, const N: usize, const M: usize> Freeze for ReShaped<T, N, M>
where T: Freeze,

§

impl<T, const N: usize, const M: usize> RefUnwindSafe for ReShaped<T, N, M>
where T: RefUnwindSafe,

§

impl<T, const N: usize, const M: usize> Send for ReShaped<T, N, M>
where T: Send,

§

impl<T, const N: usize, const M: usize> Sync for ReShaped<T, N, M>
where T: Sync,

§

impl<T, const N: usize, const M: usize> Unpin for ReShaped<T, N, M>
where T: Unpin,

§

impl<T, const N: usize, const M: usize> UnwindSafe for ReShaped<T, N, M>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.