StridedViewMut

Struct StridedViewMut 

Source
pub struct StridedViewMut<'a, T> { /* private fields */ }
Expand description

Dynamic-rank mutable strided view.

Always uses Identity element operation for write simplicity. Julia typically applies ops on the read side.

Implementations§

Source§

impl<'a, T> StridedViewMut<'a, T>

Source

pub fn new( data: &'a mut [T], dims: &[usize], strides: &[isize], offset: isize, ) -> Result<Self>

Create a new mutable strided view.

Source

pub unsafe fn new_unchecked( data: &'a mut [T], dims: &[usize], strides: &[isize], offset: isize, ) -> Self

Create without bounds checking.

§Safety

Caller must ensure all index combinations stay within bounds.

Source

pub fn dims(&self) -> &[usize]

Returns the shape (dimension sizes) of this view.

Source

pub fn strides(&self) -> &[isize]

Returns the strides (in units of T) for each dimension.

Source

pub fn offset(&self) -> isize

Returns the byte offset into the backing data.

Source

pub fn ndim(&self) -> usize

Returns the number of dimensions (rank).

Source

pub fn len(&self) -> usize

Returns the total number of elements.

Source

pub fn is_empty(&self) -> bool

Returns true if any dimension is zero.

Source

pub fn ptr(&self) -> *const T

Raw const pointer to element at the view’s base offset.

Source

pub fn as_mut_ptr(&self) -> *mut T

Raw mutable pointer to element at the view’s base offset.

Source

pub fn permute(self, perm: &[usize]) -> Result<StridedViewMut<'a, T>>

Permute dimensions, consuming the mutable view.

Returns a new mutable view with reordered dimensions and strides. Takes self by value to prevent aliasing of mutable views.

Source

pub fn as_view(&self) -> StridedView<'_, T, Identity>

Reborrow as an immutable view.

Source§

impl<'a, T: Copy> StridedViewMut<'a, T>

Source

pub fn get(&self, indices: &[usize]) -> T

Get an element.

Source

pub fn set(&mut self, indices: &[usize], value: T)

Set an element.

Trait Implementations§

Source§

impl<T: Debug> Debug for StridedViewMut<'_, T>

Source§

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

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

impl<T: Send> Send for StridedViewMut<'_, T>

Auto Trait Implementations§

§

impl<'a, T> Freeze for StridedViewMut<'a, T>

§

impl<'a, T> RefUnwindSafe for StridedViewMut<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> !Sync for StridedViewMut<'a, T>

§

impl<'a, T> Unpin for StridedViewMut<'a, T>

§

impl<'a, T> !UnwindSafe for StridedViewMut<'a, T>

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> 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, 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.