Skip to main content

MatMut

Struct MatMut 

Source
pub struct MatMut<'a, T> { /* private fields */ }
Expand description

mutable matrix type column major

Implementations§

Source§

impl<'a, T> MatMut<'a, T>

Source

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));
Source

pub fn as_slice(&self) -> &[T]

accesses full internal immutable slice

Source

pub fn as_slice_mut(&mut self) -> &mut [T]

accesses full internal slice as mutable

Source

pub fn dimension(&self) -> (usize, usize)

accesses matrix dimension (n_rows, n_cols)

Source

pub fn n_rows(&self) -> usize

accesses matrix number of rows

Source

pub fn n_cols(&self) -> usize

accesses matrix number of cols

Source

pub fn col(&self, j: usize) -> VecRef<'_, T>

return a VecRef for a given column in Self

Source

pub fn col_mut(&mut self, j: usize) -> VecMut<'_, T>

return a VecMut for a given column in Self

Source

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); 
Source

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); 
Source

pub fn col_panels( &self, nc: usize, ) -> impl DoubleEndedIterator<Item = (Range<usize>, MatRef<'_, T>)>

return an Iterator over MatRefs chunks containing column panels that span Self.

each chunk holds nc columns, and the last item is the leftover column panel with n_cols < nc

args:

  • nc: usize - # cols in panel

returns:

Source

pub fn has_len_equal_to_n_cols(&self, length: usize) -> bool

checks whether matrix n_cols equals given length

Source

pub fn has_len_equal_to_n_rows(&self, length: usize) -> bool

checks whether matrix n_rows equals given length

Source

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§

Source§

impl<'a, T: Debug> Debug for MatMut<'a, T>

Source§

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

Formats the value using the given formatter. Read more

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> 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V