Struct vectrix::Matrix [−][src]
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
Create a new matrix filled with the given element.
Create a new matrix filled with computed elements.
Elements will be filled in column-major order.
Views the underlying data as a contiguous slice.
Views the underlying data as a contiguous mutable slice.
Returns a reference to an element in the matrix or None
if out of
bounds.
Returns a mutable reference to an element in the matrix or None
if out
of bounds.
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.
pub unsafe fn get_unchecked_mut<I>(&mut self, i: I) -> &mut I::Output where
I: MatrixIndex<Self>,
pub unsafe fn get_unchecked_mut<I>(&mut self, i: I) -> &mut I::Output where
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.
Returns a reference to the i
-th row of this matrix.
Returns a mutable reference to the i
-th row of this matrix.
Returns a reference to the i
-th column of this matrix.
Returns a mutable reference to the i
-th column of this matrix.
Returns a mutable iterator over the underlying data.
Returns an iterator over the rows in this matrix.
pub fn iter_rows_mut(&mut self) -> IterRowsMut<'_, T, M, N>ⓘNotable traits for IterRowsMut<'a, T, M, N>impl<'a, T, const M: usize, const N: usize> Iterator for IterRowsMut<'a, T, M, N> type Item = &'a mut Row<T, M, N>;
pub fn iter_rows_mut(&mut self) -> IterRowsMut<'_, T, M, N>ⓘNotable traits for IterRowsMut<'a, T, M, N>impl<'a, T, const M: usize, const N: usize> Iterator for IterRowsMut<'a, T, M, N> type Item = &'a mut Row<T, M, N>;
impl<'a, T, const M: usize, const N: usize> Iterator for IterRowsMut<'a, T, M, N> type Item = &'a mut Row<T, M, N>;
Returns a mutable iterator over the rows in this matrix.
pub fn iter_columns(&self) -> IterColumns<'_, T, M, N>ⓘNotable traits for IterColumns<'a, T, M, N>impl<'a, T, const M: usize, const N: usize> Iterator for IterColumns<'a, T, M, N> type Item = &'a Column<T, M, N>;
pub fn iter_columns(&self) -> IterColumns<'_, T, M, N>ⓘNotable traits for IterColumns<'a, T, M, N>impl<'a, T, const M: usize, const N: usize> Iterator for IterColumns<'a, T, M, N> type Item = &'a Column<T, M, N>;
impl<'a, T, const M: usize, const N: usize> Iterator for IterColumns<'a, T, M, N> type Item = &'a Column<T, M, N>;
Returns an iterator over the columns in this matrix.
pub fn iter_columns_mut(&mut self) -> IterColumnsMut<'_, T, M, N>ⓘNotable traits for IterColumnsMut<'a, T, M, N>impl<'a, T, const M: usize, const N: usize> Iterator for IterColumnsMut<'a, T, M, N> type Item = &'a mut Column<T, M, N>;
pub fn iter_columns_mut(&mut self) -> IterColumnsMut<'_, T, M, N>ⓘNotable traits for IterColumnsMut<'a, T, M, N>impl<'a, T, const M: usize, const N: usize> Iterator for IterColumnsMut<'a, T, M, N> type Item = &'a mut Column<T, M, N>;
impl<'a, T, const M: usize, const N: usize> Iterator for IterColumnsMut<'a, T, M, N> type Item = &'a mut Column<T, M, N>;
Returns a mutable iterator over the columns in this matrix.
Returns a matrix of the same size as self, with function f
applied to
each element in column-major order.
Returns the L1 norm of the matrix.
Also known as Manhattan Distance or Taxicab norm. L1 Norm is the sum of the magnitudes of the vectors in a space.
Note: if the matrix is a row vector this method might not do what you what you expect. For example:
let row_vector = matrix![1, 2, 3];
assert_eq!(row_vector.l1_norm(), 3);
let column_vector = matrix![1; 2; 3];
assert_eq!(column_vector.l1_norm(), 6);
Trait Implementations
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
impl<T, const M: usize, const N: usize> BitAndAssign<&'_ T> for Matrix<T, M, N> where
T: Copy + BitAndAssign<T>,
impl<T, const M: usize, const N: usize> BitAndAssign<&'_ T> for Matrix<T, M, N> where
T: Copy + BitAndAssign<T>,
Performs the &=
operation. Read more
impl<'a, T, const M: usize, const N: usize> BitAndAssign<T> for Matrix<T, M, N> where
T: Copy + BitAndAssign<T>,
impl<'a, T, const M: usize, const N: usize> BitAndAssign<T> for Matrix<T, M, N> where
T: Copy + BitAndAssign<T>,
Performs the &=
operation. Read more
impl<T, const M: usize, const N: usize> BitOrAssign<&'_ T> for Matrix<T, M, N> where
T: Copy + BitOrAssign<T>,
impl<T, const M: usize, const N: usize> BitOrAssign<&'_ T> for Matrix<T, M, N> where
T: Copy + BitOrAssign<T>,
Performs the |=
operation. Read more
impl<'a, T, const M: usize, const N: usize> BitOrAssign<T> for Matrix<T, M, N> where
T: Copy + BitOrAssign<T>,
impl<'a, T, const M: usize, const N: usize> BitOrAssign<T> for Matrix<T, M, N> where
T: Copy + BitOrAssign<T>,
Performs the |=
operation. Read more
impl<T, const M: usize, const N: usize> BitXorAssign<&'_ T> for Matrix<T, M, N> where
T: Copy + BitXorAssign<T>,
impl<T, const M: usize, const N: usize> BitXorAssign<&'_ T> for Matrix<T, M, N> where
T: Copy + BitXorAssign<T>,
Performs the ^=
operation. Read more
impl<'a, T, const M: usize, const N: usize> BitXorAssign<T> for Matrix<T, M, N> where
T: Copy + BitXorAssign<T>,
impl<'a, T, const M: usize, const N: usize> BitXorAssign<T> for Matrix<T, M, N> where
T: Copy + BitXorAssign<T>,
Performs the ^=
operation. Read more
Create a new matrix using T::default()
as an initializer.
Note: this implementation will not be as efficient for types that
are Copy
. In most cases it would be better to use one of the
following:
Performs the /=
operation. Read more
Performs the /=
operation. Read more
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.
type Output = T
type Output = T
The output type returned by methods.
Returns a shared reference to the output at this location, if in bounds. Read more
Returns a mutable reference to the output at this location, if in bounds. Read more
Returns a shared reference to the output at this location, without performing any bounds checking. Read more
Returns a mutable reference to the output at this location, without performing any bounds checking. Read more
Returns a shared reference to the output at this location, panicking if out of bounds. Read more
type Output = T
type Output = T
The output type returned by methods.
Returns a shared reference to the output at this location, if in bounds. Read more
Returns a mutable reference to the output at this location, if in bounds. Read more
Returns a shared reference to the output at this location, without performing any bounds checking. Read more
Returns a mutable reference to the output at this location, without performing any bounds checking. Read more
Returns a shared reference to the output at this location, panicking if out of bounds. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
impl<T: PartialOrd, const M: usize, const N: usize> PartialOrd<Matrix<T, M, N>> for Matrix<T, M, N>
impl<T: PartialOrd, const M: usize, const N: usize> PartialOrd<Matrix<T, M, N>> for Matrix<T, M, N>
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Performs the %=
operation. Read more
Performs the %=
operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Auto Trait Implementations
impl<T, const M: usize, const N: usize> RefUnwindSafe for Matrix<T, M, N> where
T: RefUnwindSafe,
impl<T, const M: usize, const N: usize> UnwindSafe for Matrix<T, M, N> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more