pub struct Matrix<T> { /* private fields */ }
Expand description
A representation of a standard Matrix of size r * c
§Examples
let mut m = Matrix::new(2, 2, vec![0; 4]);
assert_eq!(m.at(0, 0), 0);
*m.at_mut(1, 1) = 5;
assert_eq!(m.at(1, 1), 5);
let m = Matrix::from_vec(1, 2, &vec![9, 8]);
assert_eq!(&vec![9, 8], m.data());
Implementations§
Source§impl<T> Matrix<T>
impl<T> Matrix<T>
Sourcepub fn new(r: usize, c: usize, v: Vec<T>) -> Matrix<T>
pub fn new(r: usize, c: usize, v: Vec<T>) -> Matrix<T>
Constructs a new Matrix<T>
, taking ownership of v
and using it
as the buffer.
Sourcepub fn from_vec(r: usize, c: usize, v: &Vec<T>) -> Matrix<T>
pub fn from_vec(r: usize, c: usize, v: &Vec<T>) -> Matrix<T>
Constructs a new Matrix<T>
, using v
as the buffer without taking ownership of it.
Sourcepub fn at(&self, r: usize, c: usize) -> T
pub fn at(&self, r: usize, c: usize) -> T
Returns the element at the r
-th row and c
-th column,
provided those are within bounds.
Sourcepub fn at_mut(&mut self, r: usize, c: usize) -> &mut T
pub fn at_mut(&mut self, r: usize, c: usize) -> &mut T
Returns a mutable reference to the element at the r
-th row
and c
-th column, provided those are within bounds.
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> 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