Struct matrix_lib::Matrix
source · pub struct Matrix<T> { /* private fields */ }
Implementations§
source§impl<T> Matrix<T>where
T: Add<Output = T> + Sub<Output = T> + Mul<Output = T> + Div<Output = T> + Neg<Output = T> + AddAssign + SubAssign + MulAssign + DivAssign + Clone + One + Zero + PartialEq + Copy + ToPrimitive + Send + 'static,
impl<T> Matrix<T>where T: Add<Output = T> + Sub<Output = T> + Mul<Output = T> + Div<Output = T> + Neg<Output = T> + AddAssign + SubAssign + MulAssign + DivAssign + Clone + One + Zero + PartialEq + Copy + ToPrimitive + Send + 'static,
source§impl<T> Matrix<T>where
T: Add<Output = T> + Sub<Output = T> + Mul<Output = T> + Div<Output = T> + Neg<Output = T> + AddAssign + SubAssign + MulAssign + DivAssign + Clone + One + Zero + PartialEq + Copy + ToPrimitive,
impl<T> Matrix<T>where T: Add<Output = T> + Sub<Output = T> + Mul<Output = T> + Div<Output = T> + Neg<Output = T> + AddAssign + SubAssign + MulAssign + DivAssign + Clone + One + Zero + PartialEq + Copy + ToPrimitive,
sourcepub fn sum(&self, other: Matrix<T>) -> Result<Self, String>
pub fn sum(&self, other: Matrix<T>) -> Result<Self, String>
Sums two matrices of same size.
Errors
This function will return an error if matrices are different sizes.
examples:
use matrix_lib::*;
let m1 = matrix![[1,2,3], [4,5,6]];
let m2 = matrix![[1,2], [3,4], [5,6]];
assert!(matches!(m1.sum(m2), Err(String)));
will not sum successfully
Examples of correct usage
use matrix_lib::*;
let m1 = matrix![[1,2,3], [4,5,6]];
let m2 = matrix![[1,2,3], [4,5,6]];
assert_eq!(matrix![[2,4,6], [8,10,12]], m1.sum(m2).unwrap());
sourcepub fn scalar_mul(&self, scalar: T) -> Self
pub fn scalar_mul(&self, scalar: T) -> Self
Multiplies two matrices.
sourcepub fn gaussian_elimination(&self) -> Matrix<f64>
pub fn gaussian_elimination(&self) -> Matrix<f64>
sourcepub fn determinant(&self) -> Result<f64, String>
pub fn determinant(&self) -> Result<f64, String>
sourcepub fn from_vectorized(v: Vec<T>, columns: usize) -> Matrix<T>
pub fn from_vectorized(v: Vec<T>, columns: usize) -> Matrix<T>
Trait Implementations§
source§impl<T: PartialEq> PartialEq<Matrix<T>> for Matrix<T>
impl<T: PartialEq> PartialEq<Matrix<T>> for Matrix<T>
impl<T: Eq> Eq for Matrix<T>
impl<T> StructuralEq for Matrix<T>
impl<T> StructuralPartialEq for Matrix<T>
Auto Trait Implementations§
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> 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