pub struct ArrayView<'a, T, D>{ /* private fields */ }Expand description
An immutable, borrowed view into an existing array’s data.
This is a zero-copy slice — no data is cloned. The lifetime 'a
ties this view to the source array.
Implementations§
Source§impl<'a, T, D> ArrayView<'a, T, D>
impl<'a, T, D> ArrayView<'a, T, D>
Sourcepub fn broadcast_to(
&self,
target_shape: &[usize],
) -> Result<ArrayView<'a, T, IxDyn>, FerrayError>
pub fn broadcast_to( &self, target_shape: &[usize], ) -> Result<ArrayView<'a, T, IxDyn>, FerrayError>
Broadcast this view to the given shape, returning a dynamic-rank view.
§Errors
Returns FerrayError::BroadcastFailure if the view cannot be broadcast.
Source§impl<T, D> ArrayView<'_, T, D>
impl<T, D> ArrayView<'_, T, D>
Source§impl<'a, T, D> ArrayView<'a, T, D>
impl<'a, T, D> ArrayView<'a, T, D>
Sourcepub fn layout(&self) -> MemoryLayout
pub fn layout(&self) -> MemoryLayout
Memory layout.
Sourcepub fn to_owned(&self) -> Array<T, D>
pub fn to_owned(&self) -> Array<T, D>
Convert this view into an owned array by cloning all elements.
Sourcepub fn flags(&self) -> ArrayFlags
pub fn flags(&self) -> ArrayFlags
Array flags for this view.
Source§impl<'a, T> ArrayView<'a, T, IxDyn>where
T: Element,
impl<'a, T> ArrayView<'a, T, IxDyn>where
T: Element,
Sourcepub unsafe fn from_shape_ptr(
ptr: *const T,
shape: &[usize],
strides: &[usize],
) -> ArrayView<'a, T, IxDyn>
pub unsafe fn from_shape_ptr( ptr: *const T, shape: &[usize], strides: &[usize], ) -> ArrayView<'a, T, IxDyn>
Construct a dynamic-rank view from a raw pointer, shape, and strides.
This is the primary escape hatch for crates that need to build views
with custom stride patterns (e.g., ferray-stride-tricks).
§Safety
The caller must ensure:
ptris valid for reads for the entire region described byshapeandstrides.- The lifetime
'adoes not outlive the allocation thatptrpoints into. - No mutable reference to the same memory region exists for the
duration of
'a. stridesare given in units of elements (not bytes).
Source§impl<T, D> ArrayView<'_, T, D>
impl<T, D> ArrayView<'_, T, D>
Sourcepub fn index_select(
&self,
axis: Axis,
indices: &[isize],
) -> Result<Array<T, IxDyn>, FerrayError>
pub fn index_select( &self, axis: Axis, indices: &[isize], ) -> Result<Array<T, IxDyn>, FerrayError>
Select elements along an axis using an array of indices (copy).
Sourcepub fn boolean_index(
&self,
mask: &Array<bool, D>,
) -> Result<Array<T, Ix1>, FerrayError>
pub fn boolean_index( &self, mask: &Array<bool, D>, ) -> Result<Array<T, Ix1>, FerrayError>
Select elements using a boolean mask (copy).
Source§impl<'a, T, D> ArrayView<'a, T, D>
impl<'a, T, D> ArrayView<'a, T, D>
Sourcepub fn index_axis(
&self,
axis: Axis,
index: isize,
) -> Result<ArrayView<'a, T, IxDyn>, FerrayError>
pub fn index_axis( &self, axis: Axis, index: isize, ) -> Result<ArrayView<'a, T, IxDyn>, FerrayError>
Index into the view along a given axis, removing that axis.
Sourcepub fn slice_axis(
&self,
axis: Axis,
spec: SliceSpec,
) -> Result<ArrayView<'a, T, IxDyn>, FerrayError>
pub fn slice_axis( &self, axis: Axis, spec: SliceSpec, ) -> Result<ArrayView<'a, T, IxDyn>, FerrayError>
Slice the view along a given axis.
Sourcepub fn insert_axis(
&self,
axis: Axis,
) -> Result<ArrayView<'a, T, IxDyn>, FerrayError>
pub fn insert_axis( &self, axis: Axis, ) -> Result<ArrayView<'a, T, IxDyn>, FerrayError>
Insert a new axis of length 1 at the given position.
Sourcepub fn remove_axis(
&self,
axis: Axis,
) -> Result<ArrayView<'a, T, IxDyn>, FerrayError>
pub fn remove_axis( &self, axis: Axis, ) -> Result<ArrayView<'a, T, IxDyn>, FerrayError>
Remove an axis of length 1.
Trait Implementations§
Source§impl<T, D> AsRawBuffer for ArrayView<'_, T, D>
impl<T, D> AsRawBuffer for ArrayView<'_, T, D>
Source§fn raw_strides_bytes(&self) -> Vec<isize>
fn raw_strides_bytes(&self) -> Vec<isize>
Source§fn is_c_contiguous(&self) -> bool
fn is_c_contiguous(&self) -> bool
Source§fn is_f_contiguous(&self) -> bool
fn is_f_contiguous(&self) -> bool
Auto Trait Implementations§
impl<'a, T, D> Freeze for ArrayView<'a, T, D>
impl<'a, T, D> RefUnwindSafe for ArrayView<'a, T, D>
impl<'a, T, D> Send for ArrayView<'a, T, D>
impl<'a, T, D> Sync for ArrayView<'a, T, D>
impl<'a, T, D> Unpin for ArrayView<'a, T, D>
impl<'a, T, D> UnsafeUnpin for ArrayView<'a, T, D>
impl<'a, T, D> UnwindSafe for ArrayView<'a, T, D>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more