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>,
impl<T, S> MatrixReverse<T, S>where
S: MatrixRef<T>,
Sourcepub fn from(source: S, reverse: Reverse) -> MatrixReverse<T, S>
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.
Sourcepub fn source_ref(&self) -> &S
pub fn source_ref(&self) -> &S
Gives a reference to the MatrixReverse’s source (in which the data is not reversed).
Sourcepub fn source_ref_mut(&mut self) -> &mut S
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>
impl<T: Clone, S: Clone> Clone for MatrixReverse<T, S>
Source§fn clone(&self) -> MatrixReverse<T, S>
fn clone(&self) -> MatrixReverse<T, S>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§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.
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>
fn try_get_reference_mut(&mut self, row: Row, column: Column) -> Option<&mut T>
Source§unsafe fn get_reference_unchecked_mut(
&mut self,
row: Row,
column: Column,
) -> &mut T
unsafe fn get_reference_unchecked_mut( &mut self, row: Row, column: Column, ) -> &mut T
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.
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>
fn try_get_reference(&self, row: Row, column: Column) -> Option<&T>
Source§fn view_rows(&self) -> Row
fn view_rows(&self) -> Row
Source§fn view_columns(&self) -> Column
fn view_columns(&self) -> Column
Source§unsafe fn get_reference_unchecked(&self, row: Row, column: Column) -> &T
unsafe fn get_reference_unchecked(&self, row: Row, column: Column) -> &T
Source§fn data_layout(&self) -> DataLayout
fn data_layout(&self) -> DataLayout
impl<T, S> NoInteriorMutability for MatrixReverse<T, S>where
S: NoInteriorMutability,
A MatrixReverse of a NoInteriorMutability type implements NoInteriorMutability.