Skip to main content

MatRef

Struct MatRef 

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

immutable matrix type column major

Implementations§

Source§

impl<'a, T> MatRef<'a, T>

Source

pub fn new(buffer: &'a [T], dimension: (usize, usize)) -> Self

constructs MatRef with given slice and (n_rows, n_cols) dimension

example:

use lak::types::MatRef; 

// col-major 2 x 3 matrix: 
// [1 3 5] 
// [2 4 6] 
let a = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]; 
let a = MatRef::new(&a, (2, 3));
Source

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

accesses internal immutable slice

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_panel(&self, cols: Range<usize>) -> MatRef<'_, T>

return a MatRef for a contiguous column panel of Self

example:

use lak::types::MatRef; 

// [1 3 5] 
// [2 4 6] 
let a = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]; 
let a = MatRef::new(&a, (2, 3)); 

// MatRef of columns 1..3 
// [3 5] 
// [4 6] 
let panel = a.col_panel(1..3); 
Source

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

returns an Iterator over MatRefs containing column panels that span Self.

each panel holds nc columns, and the last item is the leftover panel with column width < 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

Trait Implementations§

Source§

impl<'a, T: Clone> Clone for MatRef<'a, T>

Source§

fn clone(&self) -> MatRef<'a, T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a, T: Copy> Copy for MatRef<'a, T>

Source§

impl<'a, T: Debug> Debug for MatRef<'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> Freeze for MatRef<'a, T>

§

impl<'a, T> RefUnwindSafe for MatRef<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for MatRef<'a, T>
where T: Sync,

§

impl<'a, T> Sync for MatRef<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for MatRef<'a, T>

§

impl<'a, T> UnsafeUnpin for MatRef<'a, T>

§

impl<'a, T> UnwindSafe for MatRef<'a, T>
where T: RefUnwindSafe,

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

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

Source§

fn vzip(self) -> V