Struct MatrixReverse

Source
pub struct MatrixReverse<T, S> { /* private fields */ }
Expand description

A view over a matrix where some or all of the rows and columns are iterated in reverse order.

use easy_ml::matrices::Matrix;
use easy_ml::matrices::views::{MatrixView, MatrixReverse, Reverse};
let ab = Matrix::from(vec![
    vec![ 0, 1, 2 ],
    vec![ 3, 4, 5 ]
]);
let reversed = ab.reverse(Reverse { rows: true, ..Default::default() });
let also_reversed = MatrixView::from(
    MatrixReverse::from(&ab, Reverse { rows: true, columns: false })
);
assert_eq!(reversed, also_reversed);
assert_eq!(
    reversed,
    Matrix::from(vec![
        vec![ 3, 4, 5 ],
        vec![ 0, 1, 2 ]
    ])
);

Implementations§

Source§

impl<T, S> MatrixReverse<T, S>
where S: MatrixRef<T>,

Source

pub fn from(source: S, reverse: Reverse) -> MatrixReverse<T, S>

Creates a MatrixReverse from a source and a struct for which dimensions to reverse the order of iteration for. If either or both of rows and columns in Reverse are set to false the iteration order for that dimension will continue to iterate in its normal order.

Source

pub fn source(self) -> S

Consumes the MatrixReverse, yielding the source it was created from.

Source

pub fn source_ref(&self) -> &S

Gives a reference to the MatrixReverse’s source (in which the data is not reversed).

Source

pub fn source_ref_mut(&mut self) -> &mut S

Gives a mutable reference to the MatrixReverse’s source (in which the data is not reversed).

Trait Implementations§

Source§

impl<T: Clone, S: Clone> Clone for MatrixReverse<T, S>

Source§

fn clone(&self) -> MatrixReverse<T, S>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, S: Debug> Debug for MatrixReverse<T, S>

Source§

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

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

impl<T, S> MatrixMut<T> for MatrixReverse<T, S>
where S: MatrixMut<T>,

A MatrixReverse implements MatrixMut, with the dimension names the MatrixReverse was created with iterating in reverse order compared to the dimension names in the original source.

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<T, S> MatrixRef<T> for MatrixReverse<T, S>
where S: MatrixRef<T>,

A MatrixReverse implements MatrixRef, with the dimension names the MatrixReverse was created with iterating in reverse order compared to the dimension names in the original source.

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<T, S> NoInteriorMutability for MatrixReverse<T, S>

A MatrixReverse of a NoInteriorMutability type implements NoInteriorMutability.

Auto Trait Implementations§

§

impl<T, S> Freeze for MatrixReverse<T, S>
where S: Freeze,

§

impl<T, S> RefUnwindSafe for MatrixReverse<T, S>

§

impl<T, S> Send for MatrixReverse<T, S>
where S: Send, T: Send,

§

impl<T, S> Sync for MatrixReverse<T, S>
where S: Sync, T: Sync,

§

impl<T, S> Unpin for MatrixReverse<T, S>
where S: Unpin, T: Unpin,

§

impl<T, S> UnwindSafe for MatrixReverse<T, S>
where S: UnwindSafe, T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.