Struct easy_ml::matrices::views::MatrixPart

source ·
pub struct MatrixPart<'source, T> { /* private fields */ }
Expand description

A mutably borrowed part of a matrix.

Rust’s borrow checker does not not permit overlapping exclusive references, so you cannot simply construct multiple views into a Matrix by creating each one sequentially as you can for immutable/shared references to a Matrix.

use easy_ml::matrices::Matrix;
use easy_ml::matrices::views::MatrixRange;
let matrix = Matrix::row(vec![1, 2, 3]);
let one = MatrixRange::from(&matrix, 0..1, 0..1);
let two = MatrixRange::from(&matrix, 0..1, 1..2);
let three = MatrixRange::from(&matrix, 0..1, 2..3);
let four = MatrixRange::from(&matrix, 0..1, 0..3);

MatrixPart instead holds only a mutable reference to a slice into a Matrix’s buffer. It does not borrow the entire Matrix, and thus is used as the container for Matrix APIs which partition a Matrix into multiple non overlapping parts. The Matrix can then be independently mutated by each of the MatrixParts.

See Matrix::partition_quadrants

Trait Implementations§

source§

impl<'source, T: Debug> Debug for MatrixPart<'source, T>

source§

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

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

impl<'a, T> MatrixMut<T> for MatrixPart<'a, T>

A MatrixPart implements MatrixMut.

source§

fn try_get_reference_mut(&mut self, row: Row, column: Column) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
source§

unsafe fn get_reference_unchecked_mut( &mut self, row: Row, column: Column, ) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see try_get_reference_mut. Read more
source§

impl<'a, T> MatrixRef<T> for MatrixPart<'a, T>

A MatrixPart implements MatrixRef.

source§

fn try_get_reference(&self, row: Row, column: Column) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
source§

fn view_rows(&self) -> Row

The number of rows that this reference can view. This may be less than the actual number of rows stored in the matrix.
source§

fn view_columns(&self) -> Column

The number of columns that this reference can view. This may be less than the actual number of columns stored in the matrix.
source§

unsafe fn get_reference_unchecked(&self, row: Row, column: Column) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see try_get_reference. Read more
source§

fn data_layout(&self) -> DataLayout

A hint for the data layout this MatrixView uses to store its data. Read more
source§

impl<'a, T> NoInteriorMutability for MatrixPart<'a, T>

A MatrixPart implements NoInteriorMutability.

Auto Trait Implementations§

§

impl<'source, T> Freeze for MatrixPart<'source, T>

§

impl<'source, T> RefUnwindSafe for MatrixPart<'source, T>
where T: RefUnwindSafe,

§

impl<'source, T> Send for MatrixPart<'source, T>
where T: Send,

§

impl<'source, T> Sync for MatrixPart<'source, T>
where T: Sync,

§

impl<'source, T> Unpin for MatrixPart<'source, T>

§

impl<'source, T> !UnwindSafe for MatrixPart<'source, 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>,

§

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

§

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.