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>,
impl<'a, V, T> SubmatrixMut<'a, V, T>where
V: 'a + AsPointerToSlice<T>,
Sourcepub fn submatrix(self, rows: Range<usize>, cols: Range<usize>) -> Self
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.
Sourcepub fn restrict_rows(self, rows: Range<usize>) -> Self
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.
Sourcepub fn restrict_cols(self, cols: Range<usize>) -> Self
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.
Sourcepub fn split_rows(
self,
fst_rows: Range<usize>,
snd_rows: Range<usize>,
) -> (Self, Self)
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.
Sourcepub fn split_cols(
self,
fst_cols: Range<usize>,
snd_cols: Range<usize>,
) -> (Self, Self)
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.
Sourcepub fn row_iter(self) -> impl 'a + ExactSizeIterator<Item = &'a mut [T]>
pub fn row_iter(self) -> impl 'a + ExactSizeIterator<Item = &'a mut [T]>
Returns an iterator over (mutable views onto) the rows of this matrix.
Sourcepub fn col_iter(self) -> impl 'a + ExactSizeIterator<Item = ColumnMut<'a, V, T>>
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.
Sourcepub fn into_at_mut(self, i: usize, j: usize) -> &'a mut T
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.
Sourcepub fn at_mut<'b>(&'b mut self, i: usize, j: usize) -> &'b mut T
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.
Sourcepub fn at<'b>(&'b self, i: usize, j: usize) -> &'b T
pub fn at<'b>(&'b self, i: usize, j: usize) -> &'b T
Returns a reference to the (i, j)
-th entry of this matrix.
Sourcepub fn row_at<'b>(&'b self, i: usize) -> &'b [T]
pub fn row_at<'b>(&'b self, i: usize) -> &'b [T]
Returns a view onto the i
-th row of this matrix.
Sourcepub fn into_row_mut_at(self, i: usize) -> &'a mut [T]
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.
Sourcepub fn row_mut_at<'b>(&'b mut self, i: usize) -> &'b mut [T]
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.
Sourcepub fn col_at<'b>(&'b self, j: usize) -> Column<'b, V, T>
pub fn col_at<'b>(&'b self, j: usize) -> Column<'b, V, T>
Returns a view onto the i
-th column of this matrix.
Sourcepub fn col_mut_at<'b>(&'b mut self, j: usize) -> ColumnMut<'b, V, T>
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.
Sourcepub fn reborrow<'b>(&'b mut self) -> SubmatrixMut<'b, V, T>
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§impl<'a, T> SubmatrixMut<'a, AsFirstElement<T>, T>
impl<'a, T> SubmatrixMut<'a, AsFirstElement<T>, T>
Sourcepub fn from_1d(data: &'a mut [T], row_count: usize, col_count: usize) -> Self
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.
pub fn from_ndarray<S>(data: &'a mut ArrayBase<S, Ix2>) -> Selfwhere
S: DataMut<Elem = T>,
ndarray
only.Source§impl<'a, V: AsPointerToSlice<T> + Deref<Target = [T]>, T> SubmatrixMut<'a, V, T>
impl<'a, V: AsPointerToSlice<T> + Deref<Target = [T]>, T> SubmatrixMut<'a, V, T>
Trait Implementations§
Source§impl<'a, V, T: Debug> Debug for SubmatrixMut<'a, V, T>where
V: 'a + AsPointerToSlice<T>,
impl<'a, V, T: Debug> Debug for SubmatrixMut<'a, V, T>where
V: 'a + AsPointerToSlice<T>,
Source§impl<'a, V: AsPointerToSlice<T>, T> From<SubmatrixMut<'a, V, T>> for TransposableSubmatrixMut<'a, V, T, false>
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
fn from(value: SubmatrixMut<'a, V, T>) -> Self
Source§impl<'a, V: AsPointerToSlice<T>, T> MatrixCompare<T> for SubmatrixMut<'a, V, T>
impl<'a, V: AsPointerToSlice<T>, T> MatrixCompare<T> for SubmatrixMut<'a, V, T>
Auto Trait Implementations§
impl<'a, V, T> Freeze for SubmatrixMut<'a, V, T>
impl<'a, V, T> RefUnwindSafe for SubmatrixMut<'a, V, T>where
T: RefUnwindSafe,
V: RefUnwindSafe,
impl<'a, V, T> Send for SubmatrixMut<'a, V, T>
impl<'a, V, T> Sync for SubmatrixMut<'a, V, T>
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> 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> 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