#[repr(C)]pub struct Matrix<const M: usize, const N: usize, T = f32> { /* private fields */ }
Expand description
Represents a matrix with constant M
rows and constant N
columns.
The underlying data is represented as an array and is always stored in column-major order.
See the crate root for usage examples.
Implementations§
Source§impl<const M: usize, const N: usize, T> Matrix<M, N, T>
impl<const M: usize, const N: usize, T> Matrix<M, N, T>
Sourcepub fn as_mut_slice(&mut self) -> &mut [T]
pub fn as_mut_slice(&mut self) -> &mut [T]
Views the underlying data as a contiguous mutable slice.
Sourcepub fn row(&self, i: usize) -> &Row<M, N, T>
pub fn row(&self, i: usize) -> &Row<M, N, T>
Returns a reference to the i
-th row of this matrix.
Sourcepub fn row_mut(&mut self, i: usize) -> &mut Row<M, N, T>
pub fn row_mut(&mut self, i: usize) -> &mut Row<M, N, T>
Returns a mutable reference to the i
-th row of this matrix.
Sourcepub fn column(&self, i: usize) -> &Column<M, N, T>
pub fn column(&self, i: usize) -> &Column<M, N, T>
Returns a reference to the i
-th column of this matrix.
Sourcepub fn column_mut(&mut self, i: usize) -> &mut Column<M, N, T>
pub fn column_mut(&mut self, i: usize) -> &mut Column<M, N, T>
Returns a mutable reference to the i
-th column of this matrix.
Sourcepub fn get<I>(&self, i: I) -> Option<&I::Output>where
I: MatrixIndex<Self>,
pub fn get<I>(&self, i: I) -> Option<&I::Output>where
I: MatrixIndex<Self>,
Returns a reference to an element in the matrix or None
if out of
bounds.
Sourcepub fn get_mut<I>(&mut self, i: I) -> Option<&mut I::Output>where
I: MatrixIndex<Self>,
pub fn get_mut<I>(&mut self, i: I) -> Option<&mut I::Output>where
I: MatrixIndex<Self>,
Returns a mutable reference to an element in the matrix or None
if out
of bounds.
Sourcepub unsafe fn get_unchecked<I>(&self, i: I) -> &I::Outputwhere
I: MatrixIndex<Self>,
pub unsafe fn get_unchecked<I>(&self, i: I) -> &I::Outputwhere
I: MatrixIndex<Self>,
Returns a reference to an element in the matrix without doing any bounds checking.
§Safety
Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.
Sourcepub unsafe fn get_unchecked_mut<I>(&mut self, i: I) -> &mut I::Outputwhere
I: MatrixIndex<Self>,
pub unsafe fn get_unchecked_mut<I>(&mut self, i: I) -> &mut I::Outputwhere
I: MatrixIndex<Self>,
Returns a mutable reference to an element in the matrix without doing any bounds checking.
§Safety
Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, T>
pub fn iter_mut(&mut self) -> IterMut<'_, T>
Returns a mutable iterator over the underlying data.
Sourcepub fn swap_rows(&mut self, r1: usize, r2: usize)where
T: Copy,
pub fn swap_rows(&mut self, r1: usize, r2: usize)where
T: Copy,
Swap the two given rows of this matrix
Sourcepub fn swap_columns(&mut self, c1: usize, c2: usize)where
T: Copy,
pub fn swap_columns(&mut self, c1: usize, c2: usize)where
T: Copy,
Swap the two given columns of this matrix
Trait Implementations§
Source§impl<const M: usize, const N: usize, T: AbsDiffEq> AbsDiffEq for Matrix<M, N, T>
impl<const M: usize, const N: usize, T: AbsDiffEq> AbsDiffEq for Matrix<M, N, T>
Source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
Source§fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
Source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
AbsDiffEq::abs_diff_eq
.Source§impl<T, const M: usize, const N: usize> AddAssign<&Matrix<M, N, T>> for Matrix<M, N, T>
impl<T, const M: usize, const N: usize> AddAssign<&Matrix<M, N, T>> for Matrix<M, N, T>
Source§fn add_assign(&mut self, other: &Matrix<M, N, T>)
fn add_assign(&mut self, other: &Matrix<M, N, T>)
+=
operation. Read moreSource§impl<T, const M: usize, const N: usize> AddAssign<&T> for Matrix<M, N, T>
impl<T, const M: usize, const N: usize> AddAssign<&T> for Matrix<M, N, T>
Source§fn add_assign(&mut self, other: &T)
fn add_assign(&mut self, other: &T)
+=
operation. Read moreSource§impl<'a, T, const M: usize, const N: usize> AddAssign<T> for Matrix<M, N, T>
impl<'a, T, const M: usize, const N: usize> AddAssign<T> for Matrix<M, N, T>
Source§fn add_assign(&mut self, other: T)
fn add_assign(&mut self, other: T)
+=
operation. Read moreSource§impl<T, const M: usize, const N: usize> AddAssign for Matrix<M, N, T>
impl<T, const M: usize, const N: usize> AddAssign for Matrix<M, N, T>
Source§fn add_assign(&mut self, other: Matrix<M, N, T>)
fn add_assign(&mut self, other: Matrix<M, N, T>)
+=
operation. Read moreSource§impl<T, const M: usize, const N: usize> DivAssign<&T> for Matrix<M, N, T>
impl<T, const M: usize, const N: usize> DivAssign<&T> for Matrix<M, N, T>
Source§fn div_assign(&mut self, other: &T)
fn div_assign(&mut self, other: &T)
/=
operation. Read moreSource§impl<'a, T, const M: usize, const N: usize> DivAssign<T> for Matrix<M, N, T>
impl<'a, T, const M: usize, const N: usize> DivAssign<T> for Matrix<M, N, T>
Source§fn div_assign(&mut self, other: T)
fn div_assign(&mut self, other: T)
/=
operation. Read moreSource§impl<T: Copy> From<(T, T, T, T)> for Matrix<1, 4, T>
impl<T: Copy> From<(T, T, T, T)> for Matrix<1, 4, T>
Source§fn from(src: (T, T, T, T)) -> Self
fn from(src: (T, T, T, T)) -> Self
Source§impl<T: Copy> From<(T, T, T, T)> for Matrix<4, 1, T>
impl<T: Copy> From<(T, T, T, T)> for Matrix<4, 1, T>
Source§fn from(src: (T, T, T, T)) -> Self
fn from(src: (T, T, T, T)) -> Self
Source§impl<T, const M: usize, const N: usize> FromIterator<T> for Matrix<M, N, T>
impl<T, const M: usize, const N: usize> FromIterator<T> for Matrix<M, N, T>
Source§fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = T>,
fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = T>,
Create a new matrix from an iterator.
Elements will be filled in column-major order.
§Panics
If the iterator doesn’t yield enough elements to fill the matrix.
Source§impl<T, I, const M: usize, const N: usize> Index<I> for Matrix<M, N, T>where
I: MatrixIndex<Self>,
impl<T, I, const M: usize, const N: usize> Index<I> for Matrix<M, N, T>where
I: MatrixIndex<Self>,
Source§impl<T, I, const M: usize, const N: usize> IndexMut<I> for Matrix<M, N, T>where
I: MatrixIndex<Self>,
impl<T, I, const M: usize, const N: usize> IndexMut<I> for Matrix<M, N, T>where
I: MatrixIndex<Self>,
Source§impl<T, const M: usize, const N: usize> MatrixIndex<Matrix<M, N, T>> for (usize, usize)
impl<T, const M: usize, const N: usize> MatrixIndex<Matrix<M, N, T>> for (usize, usize)
Source§fn get(self, matrix: &Matrix<M, N, T>) -> Option<&Self::Output>
fn get(self, matrix: &Matrix<M, N, T>) -> Option<&Self::Output>
Source§fn get_mut(self, matrix: &mut Matrix<M, N, T>) -> Option<&mut Self::Output>
fn get_mut(self, matrix: &mut Matrix<M, N, T>) -> Option<&mut Self::Output>
Source§unsafe fn get_unchecked(
self,
matrix: *const Matrix<M, N, T>,
) -> *const Self::Output
unsafe fn get_unchecked( self, matrix: *const Matrix<M, N, T>, ) -> *const Self::Output
Source§unsafe fn get_unchecked_mut(
self,
matrix: *mut Matrix<M, N, T>,
) -> *mut Self::Output
unsafe fn get_unchecked_mut( self, matrix: *mut Matrix<M, N, T>, ) -> *mut Self::Output
Source§impl<T, const M: usize, const N: usize> MatrixIndex<Matrix<M, N, T>> for usize
impl<T, const M: usize, const N: usize> MatrixIndex<Matrix<M, N, T>> for usize
Source§fn get(self, matrix: &Matrix<M, N, T>) -> Option<&Self::Output>
fn get(self, matrix: &Matrix<M, N, T>) -> Option<&Self::Output>
Source§fn get_mut(self, matrix: &mut Matrix<M, N, T>) -> Option<&mut Self::Output>
fn get_mut(self, matrix: &mut Matrix<M, N, T>) -> Option<&mut Self::Output>
Source§unsafe fn get_unchecked(
self,
matrix: *const Matrix<M, N, T>,
) -> *const Self::Output
unsafe fn get_unchecked( self, matrix: *const Matrix<M, N, T>, ) -> *const Self::Output
Source§unsafe fn get_unchecked_mut(
self,
matrix: *mut Matrix<M, N, T>,
) -> *mut Self::Output
unsafe fn get_unchecked_mut( self, matrix: *mut Matrix<M, N, T>, ) -> *mut Self::Output
Source§impl<T, const N: usize, const M: usize, const P: usize> Mul<&Matrix<N, P, T>> for &Matrix<M, N, T>
impl<T, const N: usize, const M: usize, const P: usize> Mul<&Matrix<N, P, T>> for &Matrix<M, N, T>
Source§impl<T, const N: usize, const M: usize, const P: usize> Mul<&Matrix<N, P, T>> for Matrix<M, N, T>
impl<T, const N: usize, const M: usize, const P: usize> Mul<&Matrix<N, P, T>> for Matrix<M, N, T>
Source§impl<T, const N: usize, const M: usize, const P: usize> Mul<Matrix<N, P, T>> for &Matrix<M, N, T>
impl<T, const N: usize, const M: usize, const P: usize> Mul<Matrix<N, P, T>> for &Matrix<M, N, T>
Source§impl<T, const N: usize, const M: usize, const P: usize> Mul<Matrix<N, P, T>> for Matrix<M, N, T>
impl<T, const N: usize, const M: usize, const P: usize> Mul<Matrix<N, P, T>> for Matrix<M, N, T>
Source§impl<T, const M: usize, const N: usize> MulAssign<&T> for Matrix<M, N, T>
impl<T, const M: usize, const N: usize> MulAssign<&T> for Matrix<M, N, T>
Source§fn mul_assign(&mut self, other: &T)
fn mul_assign(&mut self, other: &T)
*=
operation. Read moreSource§impl<'a, T, const M: usize, const N: usize> MulAssign<T> for Matrix<M, N, T>
impl<'a, T, const M: usize, const N: usize> MulAssign<T> for Matrix<M, N, T>
Source§fn mul_assign(&mut self, other: T)
fn mul_assign(&mut self, other: T)
*=
operation. Read moreSource§impl<const M: usize, const N: usize, T: Ord> Ord for Matrix<M, N, T>
impl<const M: usize, const N: usize, T: Ord> Ord for Matrix<M, N, T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<const M: usize, const N: usize, T: PartialOrd> PartialOrd for Matrix<M, N, T>
impl<const M: usize, const N: usize, T: PartialOrd> PartialOrd for Matrix<M, N, T>
Source§impl<const M: usize, const N: usize, T: RelativeEq> RelativeEq for Matrix<M, N, T>
impl<const M: usize, const N: usize, T: RelativeEq> RelativeEq for Matrix<M, N, T>
Source§fn default_max_relative() -> Self::Epsilon
fn default_max_relative() -> Self::Epsilon
Source§fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
Source§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
RelativeEq::relative_eq
.Source§impl<T, const M: usize, const N: usize> RemAssign<&T> for Matrix<M, N, T>
impl<T, const M: usize, const N: usize> RemAssign<&T> for Matrix<M, N, T>
Source§fn rem_assign(&mut self, other: &T)
fn rem_assign(&mut self, other: &T)
%=
operation. Read moreSource§impl<'a, T, const M: usize, const N: usize> RemAssign<T> for Matrix<M, N, T>
impl<'a, T, const M: usize, const N: usize> RemAssign<T> for Matrix<M, N, T>
Source§fn rem_assign(&mut self, other: T)
fn rem_assign(&mut self, other: T)
%=
operation. Read moreSource§impl<T, const M: usize, const N: usize> SubAssign<&Matrix<M, N, T>> for Matrix<M, N, T>
impl<T, const M: usize, const N: usize> SubAssign<&Matrix<M, N, T>> for Matrix<M, N, T>
Source§fn sub_assign(&mut self, other: &Matrix<M, N, T>)
fn sub_assign(&mut self, other: &Matrix<M, N, T>)
-=
operation. Read moreSource§impl<T, const M: usize, const N: usize> SubAssign<&T> for Matrix<M, N, T>
impl<T, const M: usize, const N: usize> SubAssign<&T> for Matrix<M, N, T>
Source§fn sub_assign(&mut self, other: &T)
fn sub_assign(&mut self, other: &T)
-=
operation. Read moreSource§impl<'a, T, const M: usize, const N: usize> SubAssign<T> for Matrix<M, N, T>
impl<'a, T, const M: usize, const N: usize> SubAssign<T> for Matrix<M, N, T>
Source§fn sub_assign(&mut self, other: T)
fn sub_assign(&mut self, other: T)
-=
operation. Read moreSource§impl<T, const M: usize, const N: usize> SubAssign for Matrix<M, N, T>
impl<T, const M: usize, const N: usize> SubAssign for Matrix<M, N, T>
Source§fn sub_assign(&mut self, other: Matrix<M, N, T>)
fn sub_assign(&mut self, other: Matrix<M, N, T>)
-=
operation. Read more