SubmatrixMut

Struct SubmatrixMut 

Source
pub struct SubmatrixMut<'a, V, T>
where V: 'a + AsPointerToSlice<T>,
{ /* private fields */ }
Expand description

Mutable view on a matrix that stores elements of type T.

As for Submatrix, a SubmatrixMut never owns the data, but behaves similarly to a mutable reference.

This view is designed to work with various underlying representations of the matrix, as described by AsPointerToSlice.

Implementations§

Source§

impl<'a, V, T> SubmatrixMut<'a, V, T>
where V: 'a + AsPointerToSlice<T>,

Source

pub fn submatrix(self, rows: Range<usize>, cols: Range<usize>) -> Self

Returns the submatrix that references only the entries whose row resp. column indices are within the given ranges.

Source

pub fn restrict_rows(self, rows: Range<usize>) -> Self

Returns the submatrix that references only the entries whose row indices are within the given range.

Source

pub fn restrict_cols(self, cols: Range<usize>) -> Self

Returns the submatrix that references only the entries whose column indices are within the given range.

Source

pub fn split_rows( self, fst_rows: Range<usize>, snd_rows: Range<usize>, ) -> (Self, Self)

Returns the two submatrices referencing the entries whose row index is within the given ranges.

The ranges must not overlap, so that the returned matrices don’t alias the same entry.

Source

pub fn split_cols( self, fst_cols: Range<usize>, snd_cols: Range<usize>, ) -> (Self, Self)

Returns the two submatrices referencing the entries whose column index is within the given ranges.

The ranges must not overlap, so that the returned matrices don’t alias the same entry.

Source

pub fn row_iter(self) -> impl 'a + ExactSizeIterator<Item = &'a mut [T]>

Returns an iterator over (mutable views onto) the rows of this matrix.

Source

pub fn col_iter(self) -> impl 'a + ExactSizeIterator<Item = ColumnMut<'a, V, T>>

Returns an iterator over (mutable views onto) the columns of this matrix.

Source

pub fn into_at_mut(self, i: usize, j: usize) -> &'a mut T

Consumes the submatrix and produces a reference to its (i, j)-th entry.

In most cases, you will use SubmatrixMut::at_mut() instead, but in rare occasions, into_at_mut() might be necessary to provide a reference whose lifetime is not coupled to the lifetime of the submatrix object.

Source

pub fn at_mut<'b>(&'b mut self, i: usize, j: usize) -> &'b mut T

Returns a mutable reference to the (i, j)-th entry of this matrix.

Source

pub fn at<'b>(&'b self, i: usize, j: usize) -> &'b T

Returns a reference to the (i, j)-th entry of this matrix.

Source

pub fn row_at<'b>(&'b self, i: usize) -> &'b [T]

Returns a view onto the i-th row of this matrix.

Source

pub fn into_row_mut_at(self, i: usize) -> &'a mut [T]

Consumes the submatrix and produces a reference to its i-th row.

In most cases, you will use SubmatrixMut::row_mut_at() instead, but in rare occasions, into_row_mut_at() might be necessary to provide a reference whose lifetime is not coupled to the lifetime of the submatrix object.

Source

pub fn row_mut_at<'b>(&'b mut self, i: usize) -> &'b mut [T]

Returns a mutable view onto the i-th row of this matrix.

Source

pub fn col_at<'b>(&'b self, j: usize) -> Column<'b, V, T>

Returns a view onto the i-th column of this matrix.

Source

pub fn col_mut_at<'b>(&'b mut self, j: usize) -> ColumnMut<'b, V, T>

Returns a mutable view onto the j-th row of this matrix.

Source

pub fn reborrow<'b>(&'b mut self) -> SubmatrixMut<'b, V, T>

“Reborrows” the SubmatrixMut, which is somewhat like cloning the submatrix, but disallows the cloned object to be used while its copy is alive. This is necessary to follow the aliasing rules of Rust.

Source

pub fn as_const<'b>(&'b self) -> Submatrix<'b, V, T>

Returns an immutable view on the data of this matrix.

Source

pub fn col_count(&self) -> usize

Returns the number of columns of this matrix.

Source

pub fn row_count(&self) -> usize

Returns the number of rows of this matrix.

Source§

impl<'a, T> SubmatrixMut<'a, AsFirstElement<T>, T>

Source

pub fn from_1d(data: &'a mut [T], row_count: usize, col_count: usize) -> Self

Creates a view on the given data slice, interpreting it as a matrix of given shape. Assumes row-major order, i.e. contigous subslices of data will be the rows of the resulting matrix.

Source

pub fn from_ndarray<S>(data: &'a mut ArrayBase<S, Ix2>) -> Self
where S: DataMut<Elem = T>,

Available on crate feature ndarray only.
Source§

impl<'a, V: AsPointerToSlice<T> + Deref<Target = [T]>, T> SubmatrixMut<'a, V, T>

Source

pub fn from_2d(data: &'a mut [V]) -> Self

Interprets the given slice of slices as a matrix, by using the elements of the outer slice as the rows of the matrix.

Trait Implementations§

Source§

impl<'a, V, T: Debug> Debug for SubmatrixMut<'a, V, T>
where V: 'a + AsPointerToSlice<T>,

Source§

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

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

impl<'a, V: AsPointerToSlice<T>, T> From<SubmatrixMut<'a, V, T>> for TransposableSubmatrixMut<'a, V, T, false>

Source§

fn from(value: SubmatrixMut<'a, V, T>) -> Self

Converts to this type from the input type.
Source§

impl<'a, V: AsPointerToSlice<T>, T> MatrixCompare<T> for SubmatrixMut<'a, V, T>

Source§

fn col_count(&self) -> usize

Returns the number of columns of the matrix.
Source§

fn row_count(&self) -> usize

Returns the number of rows of the matrix.
Source§

fn at(&self, i: usize, j: usize) -> &T

Returns a reference to the element at the given position.

Auto Trait Implementations§

§

impl<'a, V, T> Freeze for SubmatrixMut<'a, V, T>

§

impl<'a, V, T> RefUnwindSafe for SubmatrixMut<'a, V, T>

§

impl<'a, V, T> Send for SubmatrixMut<'a, V, T>
where V: Sync, T: Sync + Send,

§

impl<'a, V, T> Sync for SubmatrixMut<'a, V, T>
where V: Sync, T: Sync,

§

impl<'a, V, T> Unpin for SubmatrixMut<'a, V, T>

§

impl<'a, V, T> !UnwindSafe for SubmatrixMut<'a, V, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.