pub struct Matrix<T = f64>where
T: Number,{ /* private fields */ }
Expand description
§Matrix
use opensrdk_linear_algebra::*;
let a = mat!(
1.0, 2.0;
3.0, 4.0
);
assert_eq!(a[0], [1.0, 3.0]);
assert_eq!(a[1], [2.0, 4.0]);
assert_eq!(a[(0, 0)], 1.0);
assert_eq!(a[(0, 1)], 2.0);
assert_eq!(a[(1, 0)], 3.0);
assert_eq!(a[(1, 1)], 4.0);
Implementations§
Source§impl<T> Matrix<T>where
T: Number,
impl<T> Matrix<T>where
T: Number,
pub fn new(rows: usize, cols: usize) -> Self
Sourcepub fn from(rows: usize, elems: Vec<T>) -> Result<Self, MatrixError>
pub fn from(rows: usize, elems: Vec<T>) -> Result<Self, MatrixError>
You can do unwrap()
if you have a conviction that elems.len() % rows == 0
pub fn is_same_size(&self, other: &Matrix<T>) -> bool
pub fn rows(&self) -> usize
pub fn cols(&self) -> usize
pub fn vec(self) -> Vec<T>
pub fn elems(&self) -> &[T]
pub fn elems_mut(&mut self) -> &mut [T]
pub fn reshape(self, rows: usize) -> Self
pub fn eject_row(&self, index: usize) -> Vec<T>
pub fn eject_sub_matrix( &self, start_i: usize, start_j: usize, rows: usize, cols: usize, ) -> Matrix<T>
Trait Implementations§
Source§impl<T> AddAssign for Matrix<T>where
T: Number,
impl<T> AddAssign for Matrix<T>where
T: Number,
Source§fn add_assign(&mut self, rhs: Matrix<T>)
fn add_assign(&mut self, rhs: Matrix<T>)
Performs the
+=
operation. Read moreSource§impl<'de, T> Deserialize<'de> for Matrix<T>where
T: Number + Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Matrix<T>where
T: Number + Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> DivAssign for Matrix<T>where
T: Number,
impl<T> DivAssign for Matrix<T>where
T: Number,
Source§fn div_assign(&mut self, rhs: Matrix<T>)
fn div_assign(&mut self, rhs: Matrix<T>)
Performs the
/=
operation. Read moreSource§impl<T> MulAssign for Matrix<T>where
T: Number,
impl<T> MulAssign for Matrix<T>where
T: Number,
Source§fn mul_assign(&mut self, rhs: Matrix<T>)
fn mul_assign(&mut self, rhs: Matrix<T>)
Performs the
*=
operation. Read moreSource§impl<T> SubAssign for Matrix<T>where
T: Number,
impl<T> SubAssign for Matrix<T>where
T: Number,
Source§fn sub_assign(&mut self, rhs: Matrix<T>)
fn sub_assign(&mut self, rhs: Matrix<T>)
Performs the
-=
operation. Read moreimpl<T> StructuralPartialEq for Matrix<T>where
T: Number,
Auto Trait Implementations§
impl<T> Freeze for Matrix<T>
impl<T> RefUnwindSafe for Matrix<T>where
T: RefUnwindSafe,
impl<T> Send for Matrix<T>
impl<T> Sync for Matrix<T>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more