Struct 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 of data stored in the matrix implementation, and could be 0.
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 of data stored in the matrix implementation, and could be 0.
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>,

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.