[][src]Struct const_alg::Matrix

#[repr(transparent)]
pub struct Matrix<T, const N: usize, const M: usize>(pub [[T; M]; N]);

Matrix represents an N x M matrix stored in row-major order

So when you go to make it, you can just do

Matrix(
    [[0, 1, 2],
     [3, 4, 5]]
)

And Rust will take care of the rest!

Methods

impl<T, const N: usize, const M: usize> Matrix<T, { N }, { M }>[src]

Important traits for IntoRows<T, { N }, { M }>
pub fn into_rows(self) -> IntoRows<T, { N }, { M }>[src]

Consumes the matrix and iterates over its rows

Important traits for IntoCols<T, { N }, { M }>
pub fn into_cols(self) -> IntoCols<T, { N }, { M }>[src]

Consumes the matrix and iterates over its columns

Important traits for RowsMut<'a, T, { N }, { M }>
pub fn rows_mut(&mut self) -> RowsMut<T, { N }, { M }>[src]

iterates over unique references to rows of a matrix

Important traits for ColsMut<'a, T, { N }, { M }>
pub fn cols_mut(&mut self) -> ColsMut<T, { N }, { M }>[src]

iterates over unique references to columns of a matrix

Important traits for Rows<'a, T, { N }, { M }>
pub fn rows(&self) -> Rows<T, { N }, { M }>[src]

iterates over shared references to rows of a matrix

Important traits for Cols<'a, T, { N }, { M }>
pub fn cols(&self) -> Cols<T, { N }, { M }>[src]

iterates over shared references to columns of a matrix

impl<T, const N: usize, const M: usize> Matrix<T, { N }, { M }>[src]

pub fn T(self) -> Matrix<T, { M }, { N }>[src]

Transposes the matrix,

This is some sugar for transpose

pub fn transpose(self) -> Matrix<T, { M }, { N }>[src]

Does the matrix transpose of the given matrix

Every element matrix[(row, col)] will be taken to output[(col, row)]

pub fn get(&self, row: usize, col: usize) -> Option<&T>[src]

Gets an element from the matrix

If the row or col is out of bounds, None is returned

pub fn get_mut(&mut self, row: usize, col: usize) -> Option<&mut T>[src]

Gets an element from the matrix

If the row or col is out of bounds, None is returned

pub unsafe fn get_unchecked(&self, row: usize, col: usize) -> &T[src]

Gets an element from the matrix

If the row or col is out of bounds, this causes UB on release mode, and panics on debug mode

pub unsafe fn get_unchecked_mut(&mut self, row: usize, col: usize) -> &mut T[src]

Gets an element from the matrix

If the row or col is out of bounds, this causes UB on release mode, and panics on debug mode

pub fn get_all_mut<const P: usize>(
    &mut self,
    pos: [(usize, usize); P]
) -> [Option<&mut T>; P]
[src]

Get's all of the elements specified by the array,

If there are any duplicates, the first one will return a value and the rest will be None,

If any pos is out of bounds, it will result in None

Example,

let m = Matrix(
    [[0, 1, 2],
     [3, 4, 5]]
);
 
assert_eq!(m.get_all_mut([(0, 0), (0, 2), (2, 0), (0, 0)]), [Some(&mut 0), Some(&mut 2), None, None]);

Trait Implementations

impl<T, U, V, F, const N: usize, const M: usize> ZipWith<Matrix<U, N, M>, F> for Matrix<T, { N }, { M }> where
    F: FnMut(T, U) -> V, 
[src]

type Output = Matrix<V, { N }, { M }>

impl<'b, T, U, V, F, const N: usize, const M: usize> ZipWith<&'b mut Matrix<U, N, M>, F> for Matrix<T, { N }, { M }> where
    F: FnMut(T, &'b mut U) -> V, 
[src]

type Output = Matrix<V, { N }, { M }>

impl<'b, T, U, V, F, const N: usize, const M: usize> ZipWith<&'b Matrix<U, N, M>, F> for Matrix<T, { N }, { M }> where
    F: FnMut(T, &'b U) -> V, 
[src]

type Output = Matrix<V, { N }, { M }>

impl<'a, T, U, V, F, const N: usize, const M: usize> ZipWith<Matrix<U, N, M>, F> for &'a mut Matrix<T, { N }, { M }> where
    F: FnMut(&'a mut T, U) -> V, 
[src]

type Output = Matrix<V, { N }, { M }>

impl<'a, 'b, T, U, V, F, const N: usize, const M: usize> ZipWith<&'b mut Matrix<U, N, M>, F> for &'a mut Matrix<T, { N }, { M }> where
    F: FnMut(&'a mut T, &'b mut U) -> V, 
[src]

type Output = Matrix<V, { N }, { M }>

impl<'a, 'b, T, U, V, F, const N: usize, const M: usize> ZipWith<&'b Matrix<U, N, M>, F> for &'a mut Matrix<T, { N }, { M }> where
    F: FnMut(&'a mut T, &'b U) -> V, 
[src]

type Output = Matrix<V, { N }, { M }>

impl<'a, T, U, V, F, const N: usize, const M: usize> ZipWith<Matrix<U, N, M>, F> for &'a Matrix<T, { N }, { M }> where
    F: FnMut(&'a T, U) -> V, 
[src]

type Output = Matrix<V, { N }, { M }>

impl<'a, 'b, T, U, V, F, const N: usize, const M: usize> ZipWith<&'b mut Matrix<U, N, M>, F> for &'a Matrix<T, { N }, { M }> where
    F: FnMut(&'a T, &'b mut U) -> V, 
[src]

type Output = Matrix<V, { N }, { M }>

impl<'a, 'b, T, U, V, F, const N: usize, const M: usize> ZipWith<&'b Matrix<U, N, M>, F> for &'a Matrix<T, { N }, { M }> where
    F: FnMut(&'a T, &'b U) -> V, 
[src]

type Output = Matrix<V, { N }, { M }>

impl<T, U, F, const N: usize, const M: usize> ZipWith<Matrix<U, N, M>, F> for Matrix<T, { N }, { M }> where
    F: FnMut(T, U), 
[src]

type Output

impl<'b, T, U, F, const N: usize, const M: usize> ZipWith<&'b mut Matrix<U, N, M>, F> for Matrix<T, { N }, { M }> where
    F: FnMut(T, &'b mut U), 
[src]

type Output

impl<'b, T, U, F, const N: usize, const M: usize> ZipWith<&'b Matrix<U, N, M>, F> for Matrix<T, { N }, { M }> where
    F: FnMut(T, &'b U), 
[src]

type Output

impl<'a, T, U, F, const N: usize, const M: usize> ZipWith<Matrix<U, N, M>, F> for &'a mut Matrix<T, { N }, { M }> where
    F: FnMut(&'a mut T, U), 
[src]

type Output

impl<'a, 'b, T, U, F, const N: usize, const M: usize> ZipWith<&'b mut Matrix<U, N, M>, F> for &'a mut Matrix<T, { N }, { M }> where
    F: FnMut(&'a mut T, &'b mut U), 
[src]

type Output

impl<'a, 'b, T, U, F, const N: usize, const M: usize> ZipWith<&'b Matrix<U, N, M>, F> for &'a mut Matrix<T, { N }, { M }> where
    F: FnMut(&'a mut T, &'b U), 
[src]

type Output

impl<'a, T, U, F, const N: usize, const M: usize> ZipWith<Matrix<U, N, M>, F> for &'a Matrix<T, { N }, { M }> where
    F: FnMut(&'a T, U), 
[src]

type Output

impl<'a, 'b, T, U, F, const N: usize, const M: usize> ZipWith<&'b mut Matrix<U, N, M>, F> for &'a Matrix<T, { N }, { M }> where
    F: FnMut(&'a T, &'b mut U), 
[src]

type Output

impl<'a, 'b, T, U, F, const N: usize, const M: usize> ZipWith<&'b Matrix<U, N, M>, F> for &'a Matrix<T, { N }, { M }> where
    F: FnMut(&'a T, &'b U), 
[src]

type Output

impl<F, T, U, const N: usize, const M: usize> Map<F> for Matrix<T, { N }, { M }> where
    F: FnMut(T) -> U, 
[src]

type Output = Matrix<U, { N }, { M }>

impl<F, T, const N: usize, const M: usize> Map<F> for Matrix<T, { N }, { M }> where
    F: FnMut(T), 
[src]

type Output

impl<'a, F, T, U, const N: usize, const M: usize> Map<F> for &'a mut Matrix<T, { N }, { M }> where
    F: FnMut(&'a mut T) -> U, 
[src]

type Output = Matrix<U, { N }, { M }>

impl<'a, F, T, U, const N: usize, const M: usize> Map<F> for &'a Matrix<T, { N }, { M }> where
    F: FnMut(&'a T) -> U, 
[src]

type Output = Matrix<U, { N }, { M }>

impl<'a, T, F, const N: usize, const M: usize> Map<F> for &'a mut Matrix<T, { N }, { M }> where
    F: FnMut(&'a mut T), 
[src]

type Output

impl<'a, 'b, T, F, const N: usize, const M: usize> Map<F> for &'a Matrix<T, { N }, { M }> where
    F: FnMut(&'a T), 
[src]

type Output

impl<T, F, const N: usize, const M: usize> ForEach<F> for Matrix<T, { N }, { M }> where
    F: FnMut(T), 
[src]

impl<'a, T, F, const N: usize, const M: usize> ForEach<F> for &'a mut Matrix<T, { N }, { M }> where
    F: FnMut(&'a mut T), 
[src]

impl<'a, T, F, const N: usize, const M: usize> ForEach<F> for &'a Matrix<T, { N }, { M }> where
    F: FnMut(&'a T), 
[src]

impl<T, U, F, const N: usize, const M: usize> ForBoth<Matrix<U, N, M>, F> for Matrix<T, { N }, { M }> where
    F: FnMut(T, U), 
[src]

impl<'b, T, U, F, const N: usize, const M: usize> ForBoth<&'b mut Matrix<U, N, M>, F> for Matrix<T, { N }, { M }> where
    F: FnMut(T, &'b mut U), 
[src]

impl<'b, T, U, F, const N: usize, const M: usize> ForBoth<&'b Matrix<U, N, M>, F> for Matrix<T, { N }, { M }> where
    F: FnMut(T, &'b U), 
[src]

impl<'a, T, U, F, const N: usize, const M: usize> ForBoth<Matrix<U, N, M>, F> for &'a mut Matrix<T, { N }, { M }> where
    F: FnMut(&'a mut T, U), 
[src]

impl<'a, 'b, T, U, F, const N: usize, const M: usize> ForBoth<&'b mut Matrix<U, N, M>, F> for &'a mut Matrix<T, { N }, { M }> where
    F: FnMut(&'a mut T, &'b mut U), 
[src]

impl<'a, 'b, T, U, F, const N: usize, const M: usize> ForBoth<&'b Matrix<U, N, M>, F> for &'a mut Matrix<T, { N }, { M }> where
    F: FnMut(&'a mut T, &'b U), 
[src]

impl<'a, T, U, F, const N: usize, const M: usize> ForBoth<Matrix<U, N, M>, F> for &'a Matrix<T, { N }, { M }> where
    F: FnMut(&'a T, U), 
[src]

impl<'a, 'b, T, U, F, const N: usize, const M: usize> ForBoth<&'b mut Matrix<U, N, M>, F> for &'a Matrix<T, { N }, { M }> where
    F: FnMut(&'a T, &'b mut U), 
[src]

impl<'a, 'b, T, U, F, const N: usize, const M: usize> ForBoth<&'b Matrix<U, N, M>, F> for &'a Matrix<T, { N }, { M }> where
    F: FnMut(&'a T, &'b U), 
[src]

impl<T: PartialEq, const N: usize, const M: usize> PartialEq<Matrix<T, N, M>> for Matrix<T, { N }, { M }>[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl<T: Copy, const N: usize, const M: usize> Copy for Matrix<T, N, M>[src]

impl<T: Eq, const N: usize, const M: usize> Eq for Matrix<T, { N }, { M }>[src]

impl<T, const N: usize, const M: usize> From<[[T; M]; N]> for Matrix<T, { N }, { M }>[src]

impl<T, const N: usize, const M: usize> Into<[[T; M]; N]> for Matrix<T, { N }, { M }>[src]

impl<T: Clone, const N: usize, const M: usize> Clone for Matrix<T, N, M>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T, const N: usize, const M: usize> Deref for Matrix<T, { N }, { M }>[src]

type Target = [[T; M]; N]

The resulting type after dereferencing.

impl<T, const N: usize, const M: usize> DerefMut for Matrix<T, { N }, { M }>[src]

impl<T: Hash, const N: usize, const M: usize> Hash for Matrix<T, { N }, { M }>[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl<T, const N: usize, const M: usize> Add<Matrix<T, N, M>> for Matrix<T, { N }, { M }> where
    T: Add<Output = T>, 
[src]

type Output = Self

The resulting type after applying the + operator.

impl<T, const N: usize, const M: usize> Sub<Matrix<T, N, M>> for Matrix<T, { N }, { M }> where
    T: Sub<Output = T>, 
[src]

type Output = Self

The resulting type after applying the - operator.

impl<'a, 'b, T, const N: usize, const M: usize, const O: usize> Mul<&'b Matrix<T, M, O>> for &'a Matrix<T, { N }, { M }> where
    T: Add<Output = T> + Mul<Output = T> + Zero + Clone
[src]

type Output = Matrix<T, { N }, { O }>

The resulting type after applying the * operator.

impl<'a, 'b, T, const N: usize, const M: usize, const O: usize> Mul<&'b mut Matrix<T, M, O>> for &'a Matrix<T, { N }, { M }> where
    T: Add<Output = T> + Mul<Output = T> + Zero + Clone
[src]

type Output = Matrix<T, { N }, { O }>

The resulting type after applying the * operator.

impl<'a, 'b, T, const N: usize, const M: usize, const O: usize> Mul<Matrix<T, M, O>> for &'a Matrix<T, { N }, { M }> where
    T: Add<Output = T> + Mul<Output = T> + Zero + Clone
[src]

type Output = Matrix<T, { N }, { O }>

The resulting type after applying the * operator.

impl<'a, 'b, T, const N: usize, const M: usize, const O: usize> Mul<&'b Matrix<T, M, O>> for &'a mut Matrix<T, { N }, { M }> where
    T: Add<Output = T> + Mul<Output = T> + Zero + Clone
[src]

type Output = Matrix<T, { N }, { O }>

The resulting type after applying the * operator.

impl<'a, 'b, T, const N: usize, const M: usize, const O: usize> Mul<&'b mut Matrix<T, M, O>> for &'a mut Matrix<T, { N }, { M }> where
    T: Add<Output = T> + Mul<Output = T> + Zero + Clone
[src]

type Output = Matrix<T, { N }, { O }>

The resulting type after applying the * operator.

impl<'a, 'b, T, const N: usize, const M: usize, const O: usize> Mul<Matrix<T, M, O>> for &'a mut Matrix<T, { N }, { M }> where
    T: Add<Output = T> + Mul<Output = T> + Zero + Clone
[src]

type Output = Matrix<T, { N }, { O }>

The resulting type after applying the * operator.

impl<'a, 'b, T, const N: usize, const M: usize, const O: usize> Mul<&'b Matrix<T, M, O>> for Matrix<T, { N }, { M }> where
    T: Add<Output = T> + Mul<Output = T> + Zero + Clone
[src]

type Output = Matrix<T, { N }, { O }>

The resulting type after applying the * operator.

impl<'a, 'b, T, const N: usize, const M: usize, const O: usize> Mul<&'b mut Matrix<T, M, O>> for Matrix<T, { N }, { M }> where
    T: Add<Output = T> + Mul<Output = T> + Zero + Clone
[src]

type Output = Matrix<T, { N }, { O }>

The resulting type after applying the * operator.

impl<'a, 'b, T, const N: usize, const M: usize, const O: usize> Mul<Matrix<T, M, O>> for Matrix<T, { N }, { M }> where
    T: Add<Output = T> + Mul<Output = T> + Zero + Clone
[src]

type Output = Matrix<T, { N }, { O }>

The resulting type after applying the * operator.

impl<T, const N: usize, const M: usize> Mul<T> for Matrix<T, { N }, { M }> where
    T: Mul<Output = T> + Clone
[src]

type Output = Matrix<T, { N }, { M }>

The resulting type after applying the * operator.

impl<T, const N: usize, const M: usize> Div<T> for Matrix<T, { N }, { M }> where
    T: Div<Output = T> + Clone
[src]

type Output = Matrix<T, { N }, { M }>

The resulting type after applying the / operator.

impl<T, const N: usize, const M: usize> Neg for Matrix<T, { N }, { M }> where
    T: Neg
[src]

type Output = Matrix<T::Output, { N }, { M }>

The resulting type after applying the - operator.

impl<T, const N: usize, const M: usize> AddAssign<Matrix<T, N, M>> for Matrix<T, { N }, { M }> where
    T: AddAssign
[src]

impl<T, const N: usize, const M: usize> SubAssign<Matrix<T, N, M>> for Matrix<T, { N }, { M }> where
    T: SubAssign
[src]

impl<T, const N: usize> MulAssign<Matrix<T, N, N>> for Matrix<T, { N }, { N }> where
    T: Add<Output = T> + Mul<Output = T> + Zero + Clone
[src]

impl<T, const N: usize, const M: usize> MulAssign<T> for Matrix<T, { N }, { M }> where
    T: MulAssign + Clone
[src]

impl<T, const N: usize, const M: usize> DivAssign<T> for Matrix<T, { N }, { M }> where
    T: DivAssign + Clone
[src]

impl<T, const N: usize, const M: usize> Index<(usize, usize)> for Matrix<T, { N }, { M }>[src]

type Output = T

The returned type after indexing.

impl<T, const N: usize, const M: usize> IndexMut<(usize, usize)> for Matrix<T, { N }, { M }>[src]

impl<T: Debug, const N: usize, const M: usize> Debug for Matrix<T, { N }, { M }>[src]

impl<T: Zero, const N: usize, const M: usize> Zero for Matrix<T, { N }, { M }>[src]

impl<T: PartialEq + Zero + One, const N: usize> One for Matrix<T, { N }, { N }> where
    Self: Mul<Output = Self>, 
[src]

Auto Trait Implementations

impl<const N: usize, const M: usize, T> Send for Matrix<T, N, M> where
    T: Send

impl<const N: usize, const M: usize, T> Unpin for Matrix<T, N, M> where
    T: Unpin

impl<const N: usize, const M: usize, T> Sync for Matrix<T, N, M> where
    T: Sync

impl<const N: usize, const M: usize, T> UnwindSafe for Matrix<T, N, M> where
    T: UnwindSafe

impl<const N: usize, const M: usize, T> RefUnwindSafe for Matrix<T, N, M> where
    T: RefUnwindSafe

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]