Matrix

Struct Matrix 

Source
pub struct Matrix<T> { /* private fields */ }

Implementations§

Source§

impl<T: Copy> Matrix<T>

Source

pub fn get_mut_data<'a>(&'a mut self) -> &'a mut Vec<T>

Source

pub fn get_mref<'lt>(&'lt mut self, row: usize, col: usize) -> &'lt mut T

Source

pub fn mmap<'a>(&'a mut self, f: &dyn Fn(&T) -> T) -> &'a mut Matrix<T>

Source§

impl<T: Num + Neg<Output = T> + Copy> Matrix<T>

Source

pub fn mneg<'a>(&'a mut self) -> &'a mut Matrix<T>

Source

pub fn mscale<'a>(&'a mut self, factor: T) -> &'a mut Matrix<T>

Source

pub fn madd<'a>(&'a mut self, m: &Matrix<T>) -> &'a mut Matrix<T>

Source

pub fn msub<'a>(&'a mut self, m: &Matrix<T>) -> &'a mut Matrix<T>

Source

pub fn melem_mul<'a>(&'a mut self, m: &Matrix<T>) -> &'a mut Matrix<T>

Source

pub fn melem_div<'a>(&'a mut self, m: &Matrix<T>) -> &'a mut Matrix<T>

Source

pub fn mmul<'a>( &self, m: &Matrix<T>, dst: &'a mut Matrix<T>, ) -> &'a mut Matrix<T>

Source§

impl<T: Copy> Matrix<T>

Source

pub fn set<'a>( &'a mut self, row: usize, col: usize, val: T, ) -> &'a mut Matrix<T>

Source

pub fn mt<'a>(&'a mut self) -> &'a mut Matrix<T>

Source§

impl<T: Copy> Matrix<T>

Source

pub fn new(no_rows: usize, no_cols: usize, data: Vec<T>) -> Matrix<T>

Source

pub fn dirty(no_rows: usize, no_cols: usize) -> Matrix<T>

Source

pub fn vector(data: Vec<T>) -> Matrix<T>

Source

pub fn row_vector(data: Vec<T>) -> Matrix<T>

Source

pub fn rows(&self) -> usize

Source

pub fn cols(&self) -> usize

Source

pub fn get_data<'a>(&'a self) -> &'a Vec<T>

Source

pub fn get_ref<'lt>(&'lt self, row: usize, col: usize) -> &'lt T

Source

pub fn map<S: Copy>(&self, f: &dyn Fn(&T) -> S) -> Matrix<S>

Source

pub fn reduce<S: Copy>( &self, init: &Vec<S>, f: &dyn Fn(&S, &T) -> S, ) -> Matrix<S>

Source

pub fn is_square(&self) -> bool

Source

pub fn is_not_square(&self) -> bool

Source§

impl<T: Num + Copy> Matrix<T>

Source

pub fn id(m: usize, n: usize) -> Matrix<T>

Source

pub fn zero(no_rows: usize, no_cols: usize) -> Matrix<T>

Source

pub fn diag(data: Vec<T>) -> Matrix<T>

Source

pub fn block_diag(m: usize, n: usize, data: Vec<T>) -> Matrix<T>

Source

pub fn zero_vector(no_rows: usize) -> Matrix<T>

Source

pub fn one_vector(no_rows: usize) -> Matrix<T>

Source§

impl<T: Num + Neg<Output = T> + Copy> Matrix<T>

Source

pub fn scale(&self, factor: T) -> Matrix<T>

Source

pub fn elem_mul(&self, m: &Matrix<T>) -> Matrix<T>

Source

pub fn elem_div(&self, m: &Matrix<T>) -> Matrix<T>

Source

pub fn dot(&self, m: &Matrix<T>) -> T

Source§

impl<T: Copy> Matrix<T>

Source

pub fn get(&self, row: usize, col: usize) -> T

Source

pub fn cr(&self, m: &Matrix<T>) -> Matrix<T>

Source

pub fn cb(&self, m: &Matrix<T>) -> Matrix<T>

Source

pub fn t(&self) -> Matrix<T>

Source

pub fn minor(&self, row: usize, col: usize) -> Matrix<T>

Source

pub fn sub_matrix<RRI, RCI, RR, RC>(&self, rows: RR, cols: RC) -> Matrix<T>
where RRI: MatrixRangeIterator, RCI: MatrixRangeIterator, RR: MatrixRange<RRI>, RC: MatrixRange<RCI>,

Source

pub fn get_columns<RCI: MatrixRangeIterator, RC: MatrixRange<RCI>>( &self, columns: RC, ) -> Matrix<T>

Source

pub fn get_rows<RCI: MatrixRangeIterator, RC: MatrixRange<RCI>>( &self, row: RC, ) -> Matrix<T>

Source

pub fn permute(&self, rows: &[usize], columns: &[usize]) -> Matrix<T>

Source

pub fn permute_rows(&self, rows: &[usize]) -> Matrix<T>

Source

pub fn permute_columns(&self, columns: &[usize]) -> Matrix<T>

Source

pub fn filter_rows(&self, f: &dyn Fn(&Matrix<T>, usize) -> bool) -> Matrix<T>

Source

pub fn filter_columns(&self, f: &dyn Fn(&Matrix<T>, usize) -> bool) -> Matrix<T>

Source

pub fn select_rows(&self, selector: &[bool]) -> Matrix<T>

Source

pub fn select_columns(&self, selector: &[bool]) -> Matrix<T>

Source§

impl<T: Debug + Copy> Matrix<T>

Source

pub fn print(&self)

Source§

impl<T: Rand + Copy> Matrix<T>

Source

pub fn random(no_rows: usize, no_cols: usize) -> Matrix<T>

Source§

impl<T: Float + ApproxEq<T> + Signed + Copy> Matrix<T>

Source

pub fn trace(&self) -> T

Source

pub fn det(&self) -> T

Source

pub fn solve(&self, b: &Matrix<T>) -> Option<Matrix<T>>

Source

pub fn inverse(&self) -> Option<Matrix<T>>

Source

pub fn is_singular(&self) -> bool

Source

pub fn is_non_singular(&self) -> bool

Source

pub fn pinverse(&self) -> Matrix<T>

Source

pub fn vector_euclidean_norm(&self) -> T

Source

pub fn length(&self) -> T

Source

pub fn vector_1_norm(&self) -> T

Source

pub fn vector_2_norm(&self) -> T

Source

pub fn vector_p_norm(&self, p: T) -> T

Source

pub fn frobenius_norm(&self) -> T

Source

pub fn vector_inf_norm(&self) -> T

Source

pub fn is_symmetric(&self) -> bool

Source

pub fn is_non_symmetric(&self) -> bool

Source

pub fn approx_eq(&self, m: &Matrix<T>) -> bool

Trait Implementations§

Source§

impl<'a, 'b, T: Add<T, Output = T> + Copy> Add<&'a Matrix<T>> for &'b Matrix<T>

Source§

type Output = Matrix<T>

The resulting type after applying the + operator.
Source§

fn add(self, m: &Matrix<T>) -> Matrix<T>

Performs the + operation. Read more
Source§

impl<'a, T: Add<T, Output = T> + Copy> Add<&'a Matrix<T>> for Matrix<T>

Source§

type Output = Matrix<T>

The resulting type after applying the + operator.
Source§

fn add(self, m: &Matrix<T>) -> Matrix<T>

Performs the + operation. Read more
Source§

impl<'a, T: Add<T, Output = T> + Copy> Add<Matrix<T>> for &'a Matrix<T>

Source§

type Output = Matrix<T>

The resulting type after applying the + operator.
Source§

fn add(self, m: Matrix<T>) -> Matrix<T>

Performs the + operation. Read more
Source§

impl<T: Add<T, Output = T> + Copy> Add for Matrix<T>

Source§

type Output = Matrix<T>

The resulting type after applying the + operator.
Source§

fn add(self, m: Matrix<T>) -> Matrix<T>

Performs the + operation. Read more
Source§

impl<'a, T: Copy> BitOr<&'a Matrix<T>> for Matrix<T>

Source§

type Output = Matrix<T>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &Matrix<T>) -> Matrix<T>

Performs the | operation. Read more
Source§

impl<T: Clone> Clone for Matrix<T>

Source§

fn clone(&self) -> Matrix<T>

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 + Copy> Debug for Matrix<T>

Source§

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

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

impl<T: Copy> Index<(usize, usize)> for Matrix<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index<'a>(&'a self, (y, x): (usize, usize)) -> &'a T

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, 'b, T: Add<T, Output = T> + Mul<T, Output = T> + Zero + Copy> Mul<&'a Matrix<T>> for &'b Matrix<T>

Source§

type Output = Matrix<T>

The resulting type after applying the * operator.
Source§

fn mul(self, m: &'a Matrix<T>) -> Matrix<T>

Performs the * operation. Read more
Source§

impl<'a, T: Add<T, Output = T> + Mul<T, Output = T> + Zero + Copy> Mul<&'a Matrix<T>> for Matrix<T>

Source§

type Output = Matrix<T>

The resulting type after applying the * operator.
Source§

fn mul(self, m: &'a Matrix<T>) -> Matrix<T>

Performs the * operation. Read more
Source§

impl<'a, T: Add<T, Output = T> + Mul<T, Output = T> + Zero + Copy> Mul<Matrix<T>> for &'a Matrix<T>

Source§

type Output = Matrix<T>

The resulting type after applying the * operator.
Source§

fn mul(self, m: Matrix<T>) -> Matrix<T>

Performs the * operation. Read more
Source§

impl<T: Add<T, Output = T> + Mul<T, Output = T> + Zero + Copy> Mul for Matrix<T>

Source§

type Output = Matrix<T>

The resulting type after applying the * operator.
Source§

fn mul(self, m: Matrix<T>) -> Matrix<T>

Performs the * operation. Read more
Source§

impl<'a, T: Neg<Output = T> + Copy> Neg for &'a Matrix<T>

Source§

type Output = Matrix<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Matrix<T>

Performs the unary - operation. Read more
Source§

impl<T: Neg<Output = T> + Copy> Neg for Matrix<T>

Source§

type Output = Matrix<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Matrix<T>

Performs the unary - operation. Read more
Source§

impl<T: PartialEq> PartialEq for Matrix<T>

Source§

fn eq(&self, other: &Matrix<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b, T: Sub<T, Output = T> + Copy> Sub<&'a Matrix<T>> for &'b Matrix<T>

Source§

type Output = Matrix<T>

The resulting type after applying the - operator.
Source§

fn sub(self, m: &Matrix<T>) -> Matrix<T>

Performs the - operation. Read more
Source§

impl<'a, T: Sub<T, Output = T> + Copy> Sub<&'a Matrix<T>> for Matrix<T>

Source§

type Output = Matrix<T>

The resulting type after applying the - operator.
Source§

fn sub(self, m: &Matrix<T>) -> Matrix<T>

Performs the - operation. Read more
Source§

impl<'a, T: Sub<T, Output = T> + Copy> Sub<Matrix<T>> for &'a Matrix<T>

Source§

type Output = Matrix<T>

The resulting type after applying the - operator.
Source§

fn sub(self, m: Matrix<T>) -> Matrix<T>

Performs the - operation. Read more
Source§

impl<T: Sub<T, Output = T> + Copy> Sub for Matrix<T>

Source§

type Output = Matrix<T>

The resulting type after applying the - operator.
Source§

fn sub(self, m: Matrix<T>) -> Matrix<T>

Performs the - operation. Read more
Source§

impl<T> StructuralPartialEq for Matrix<T>

Auto Trait Implementations§

§

impl<T> Freeze for Matrix<T>

§

impl<T> RefUnwindSafe for Matrix<T>
where T: RefUnwindSafe,

§

impl<T> Send for Matrix<T>
where T: Send,

§

impl<T> Sync for Matrix<T>
where T: Sync,

§

impl<T> Unpin for Matrix<T>
where T: Unpin,

§

impl<T> UnwindSafe for Matrix<T>
where 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.