pub struct MatMut<'a, T> { /* private fields */ }Expand description
mutable matrix type column major
Implementations§
Source§impl<'a, T> MatMut<'a, T>
impl<'a, T> MatMut<'a, T>
Sourcepub fn new(buffer: &'a mut [T], dimension: (usize, usize)) -> Self
pub fn new(buffer: &'a mut [T], dimension: (usize, usize)) -> Self
constructs MatMut with given slice and (n_rows, n_cols) dimension
example:
use lak::types::MatMut;
// col-major 2 x 3 matrix:
// [1 3 5]
// [2 4 6]
let mut a = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0];
let a = MatMut::new(&mut a, (2, 3));Sourcepub fn as_slice_mut(&mut self) -> &mut [T]
pub fn as_slice_mut(&mut self) -> &mut [T]
accesses full internal slice as mutable
Sourcepub fn col_mut(&mut self, j: usize) -> VecMut<'_, T>
pub fn col_mut(&mut self, j: usize) -> VecMut<'_, T>
return a VecMut for a given column in Self
Sourcepub fn col_panel(&self, cols: Range<usize>) -> MatRef<'_, T>
pub fn col_panel(&self, cols: Range<usize>) -> MatRef<'_, T>
return a MatRef for a contiguous column panel of Self
contains full columns over a given a range of column indices.
example:
use lak::types::{MatRef, MatMut};
// [1 3 5]
// [2 4 6]
let mut a = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0];
let a = MatMut::new(&mut a, (2, 3));
// MatRef of columns 1..3
// [3 5]
// [4 6]
let panel = a.col_panel(1..3); Sourcepub fn col_panel_mut(&mut self, cols: Range<usize>) -> MatMut<'_, T>
pub fn col_panel_mut(&mut self, cols: Range<usize>) -> MatMut<'_, T>
returns a MatMut for a contiguous column panel of Self
contains full columns over a given a range of column indices.
example:
use lak::types::MatMut;
// [1 3 5]
// [2 4 6]
let mut a = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0];
let mut a = MatMut::new(&mut a, (2, 3));
// MatMut of columns 1..3
// [3 5]
// [4 6]
let panel = a.col_panel_mut(1..3); Sourcepub fn col_panels(
&self,
nc: usize,
) -> impl DoubleEndedIterator<Item = (Range<usize>, MatRef<'_, T>)>
pub fn col_panels( &self, nc: usize, ) -> impl DoubleEndedIterator<Item = (Range<usize>, MatRef<'_, T>)>
Sourcepub fn has_len_equal_to_n_cols(&self, length: usize) -> bool
pub fn has_len_equal_to_n_cols(&self, length: usize) -> bool
checks whether matrix n_cols equals given length
Sourcepub fn has_len_equal_to_n_rows(&self, length: usize) -> bool
pub fn has_len_equal_to_n_rows(&self, length: usize) -> bool
checks whether matrix n_rows equals given length
Sourcepub fn reborrow(&mut self) -> MatMut<'_, T>
pub fn reborrow(&mut self) -> MatMut<'_, T>
used for calling routines over and over again on the stored internal mutable slice
borrows self mutably
example:
use lak::l2::ger;
use lak::types::{MatMut, VecRef};
let x = [1.0, 2.0];
let y = [3.0, 4.0];
let mut a = [0.0; 4];
let x = VecRef::new(&x);
let y = VecRef::new(&y);
let mut a = MatMut::new(&mut a, (2, 2));
ger(1.0, a.reborrow(), x, y);
ger(1.0, a.reborrow(), x, y);Trait Implementations§
Auto Trait Implementations§
impl<'a, T> !UnwindSafe for MatMut<'a, T>
impl<'a, T> Freeze for MatMut<'a, T>
impl<'a, T> RefUnwindSafe for MatMut<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for MatMut<'a, T>where
T: Send,
impl<'a, T> Sync for MatMut<'a, T>where
T: Sync,
impl<'a, T> Unpin for MatMut<'a, T>
impl<'a, T> UnsafeUnpin for MatMut<'a, 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
Mutably borrows from an owned value. Read more