pub struct Matrix<const ROWS: usize, const COLS: usize> { /* private fields */ }Trait Implementations§
Source§impl<const ROWS: usize, const COLS: usize> AddAssign for Matrix<ROWS, COLS>
impl<const ROWS: usize, const COLS: usize> AddAssign for Matrix<ROWS, COLS>
Source§fn add_assign(&mut self, rhs: Matrix<ROWS, COLS>)
fn add_assign(&mut self, rhs: Matrix<ROWS, COLS>)
Performs the
+= operation. Read moreSource§impl<const ROWS: usize, const COLS: usize> MatrixConcat<ROWS, COLS> for Matrix<ROWS, COLS>
impl<const ROWS: usize, const COLS: usize> MatrixConcat<ROWS, COLS> for Matrix<ROWS, COLS>
Source§fn x_concat<const RHS_COLS: usize, const NEW_COLS: usize>(
self,
rhs: Matrix<ROWS, RHS_COLS>,
) -> Result<Matrix<ROWS, NEW_COLS>, &'static str>
fn x_concat<const RHS_COLS: usize, const NEW_COLS: usize>( self, rhs: Matrix<ROWS, RHS_COLS>, ) -> Result<Matrix<ROWS, NEW_COLS>, &'static str>
Example:
use heapless_matrix::{matrix_trait::{MatrixTrait, MatrixConcat}, Matrix};
let mat1: Matrix<2, 2> = Matrix::eye().unwrap();
let mat2: Matrix<2, 2> = Matrix::new().unwrap();
let mat3 = mat1.clone().x_concat::<2, 4>(mat2.clone()).unwrap();
for i in 0..2 {
for j in 0..2 {
assert_eq!(mat3[i][j], mat1[i][j]);
}
for j in 0..2 {
assert_eq!(mat3[i][j + 2], mat2[i][j]);
}
}Source§impl<const ROWS: usize, const COLS: usize> MatrixTrait<ROWS, COLS> for Matrix<ROWS, COLS>
impl<const ROWS: usize, const COLS: usize> MatrixTrait<ROWS, COLS> for Matrix<ROWS, COLS>
Source§fn from_vector(data: [[f64; COLS]; ROWS]) -> Result<Self, &'static str>where
Self: Sized,
fn from_vector(data: [[f64; COLS]; ROWS]) -> Result<Self, &'static str>where
Self: Sized,
Function used to create a heapless matrix from a 2D array Example:
use heapless_matrix::{matrix_trait::MatrixTrait as _, Matrix};
let data = [[1., 2.],
[3., 4.]];
let mat: Matrix<2, 2> = Matrix::from_vector(data).unwrap();
for i in 0..2 {
for j in 0..2 {
assert_eq!(data[i][j], mat[i][j]);
}
}type TransposeType = Matrix<COLS, ROWS>
Source§fn new() -> Result<Self, &'static str>where
Self: Sized,
fn new() -> Result<Self, &'static str>where
Self: Sized,
Function that creates an matrix where all elements are equal to zero
Source§fn eye() -> Result<Self, &'static str>where
Self: Sized,
fn eye() -> Result<Self, &'static str>where
Self: Sized,
Function that creates an identity matrix
Source§fn to_double(&self) -> Result<f64, &'static str>
fn to_double(&self) -> Result<f64, &'static str>
Function that converts a 1x1 matrix into a f64
Source§fn transpose(&self) -> Self::TransposeType
fn transpose(&self) -> Self::TransposeType
Function that transposes a matrix
Source§fn swap_rows(&mut self, row1: usize, row2: usize) -> Result<(), &'static str>
fn swap_rows(&mut self, row1: usize, row2: usize) -> Result<(), &'static str>
Function that swaps two rows of a matrix Read more
Source§fn swap_cols(&mut self, col1: usize, col2: usize) -> Result<(), &'static str>
fn swap_cols(&mut self, col1: usize, col2: usize) -> Result<(), &'static str>
function that swaps two columns of a matrix Read more
Source§fn sub_matrix<const NEW_ROWS: usize, const NEW_COLS: usize>(
&self,
row_start: usize,
col_start: usize,
) -> Result<Matrix<NEW_ROWS, NEW_COLS>, &'static str>
fn sub_matrix<const NEW_ROWS: usize, const NEW_COLS: usize>( &self, row_start: usize, col_start: usize, ) -> Result<Matrix<NEW_ROWS, NEW_COLS>, &'static str>
Function that returns the submatrix of a matrix Read more
Source§impl<const LHS_ROWS: usize, const LHS_COLS: usize, const RHS_COLS: usize> Mul<Matrix<LHS_COLS, RHS_COLS>> for Matrix<LHS_ROWS, LHS_COLS>
impl<const LHS_ROWS: usize, const LHS_COLS: usize, const RHS_COLS: usize> Mul<Matrix<LHS_COLS, RHS_COLS>> for Matrix<LHS_ROWS, LHS_COLS>
Source§impl<const N: usize> MulAssign<&Matrix<N, N>> for Matrix<N, N>
impl<const N: usize> MulAssign<&Matrix<N, N>> for Matrix<N, N>
Source§fn mul_assign(&mut self, rhs: &Matrix<N, N>)
fn mul_assign(&mut self, rhs: &Matrix<N, N>)
Performs the
*= operation. Read moreSource§impl<const ROWS: usize, const COLS: usize> MulAssign<f64> for Matrix<ROWS, COLS>
impl<const ROWS: usize, const COLS: usize> MulAssign<f64> for Matrix<ROWS, COLS>
Source§fn mul_assign(&mut self, rhs: f64)
fn mul_assign(&mut self, rhs: f64)
Performs the
*= operation. Read moreSource§impl<const N: usize> MulAssign for Matrix<N, N>
impl<const N: usize> MulAssign for Matrix<N, N>
Source§fn mul_assign(&mut self, rhs: Matrix<N, N>)
fn mul_assign(&mut self, rhs: Matrix<N, N>)
Performs the
*= operation. Read moreSource§impl<const N: usize> SquareMatrix<N> for Matrix<N, N>
impl<const N: usize> SquareMatrix<N> for Matrix<N, N>
Source§impl<const ROWS: usize, const COLS: usize> SubAssign for Matrix<ROWS, COLS>
impl<const ROWS: usize, const COLS: usize> SubAssign for Matrix<ROWS, COLS>
Source§fn sub_assign(&mut self, rhs: Matrix<ROWS, COLS>)
fn sub_assign(&mut self, rhs: Matrix<ROWS, COLS>)
Performs the
-= operation. Read moreSource§impl<const ROWS: usize> VectorCol<ROWS> for Matrix<ROWS, 1>
impl<const ROWS: usize> VectorCol<ROWS> for Matrix<ROWS, 1>
Source§fn shift_data(&mut self, data: f64)
fn shift_data(&mut self, data: f64)
Function that inserts new data at the begginig of the matrix, and shifts other data by one to the end
impl<const N: usize> IsSquareMatrix for Matrix<N, N>
impl<const ROWS: usize> IsVectorCol for Matrix<ROWS, 1>
Auto Trait Implementations§
impl<const ROWS: usize, const COLS: usize> Freeze for Matrix<ROWS, COLS>
impl<const ROWS: usize, const COLS: usize> RefUnwindSafe for Matrix<ROWS, COLS>
impl<const ROWS: usize, const COLS: usize> Send for Matrix<ROWS, COLS>
impl<const ROWS: usize, const COLS: usize> Sync for Matrix<ROWS, COLS>
impl<const ROWS: usize, const COLS: usize> Unpin for Matrix<ROWS, COLS>
impl<const ROWS: usize, const COLS: usize> UnwindSafe for Matrix<ROWS, COLS>
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