pub struct Matrix<T> {
pub rows: Vec<Vec<T>>,
pub cols: Vec<Vec<T>>,
pub dims: MatrixDimensions,
}Expand description
Implementation for a finite-dimensional matrix over T.
Fields§
§rows: Vec<Vec<T>>Rows of the Matrix
cols: Vec<Vec<T>>Columns of the Matrix
dims: MatrixDimensionsDimensions of the Matrix
Implementations§
Source§impl<T> Matrix<T>where
T: Copy,
impl<T> Matrix<T>where
T: Copy,
Sourcepub fn new(rows: Vec<Vec<T>>) -> Matrix<T>
pub fn new(rows: Vec<Vec<T>>) -> Matrix<T>
Constructs a new Matrix from a nested Vec.
§Panics
This constructor panics in two scenarios. If the provided Vec has no
elements, as depicted below,
ⓘ
let _: Matrix<i32> = Matrix::new(vec![]); // panics!then a Matrix cannot be constructed and a panic issues. If the provided
Vec has rows of differing length, then it is similarly impossible to
determine the appropriate dimension of the Matrix desired and there is a
panic.
ⓘ
let _ = Matrix::new(vec![vec![1, 0], vec![0]]); // panics!Source§impl<T> Matrix<T>
impl<T> Matrix<T>
Sourcepub fn transform(&self, other: &Vector<T>) -> Vector<T>
pub fn transform(&self, other: &Vector<T>) -> Vector<T>
Transforms a Vector through matrix-vector multiplication with self
without transferring ownership.
let v = Vector::new(vec![0, 1]);
let m = Matrix::new(vec![
vec![2, 0],
vec![0, 2]
]);
let transformed_v = Vector::new(vec![0, 2]);
assert_eq!(transformed_v, m.transform(&v));Trait Implementations§
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> UnsafeUnpin for Matrix<T>
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