Matrix

Struct Matrix 

Source
pub struct Matrix<const ROWS: usize, const COLS: usize> { /* private fields */ }

Trait Implementations§

Source§

impl<const ROWS: usize, const COLS: usize> Add for Matrix<ROWS, COLS>

Source§

type Output = Matrix<ROWS, COLS>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Matrix<ROWS, COLS>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const ROWS: usize, const COLS: usize> AddAssign for Matrix<ROWS, COLS>

Source§

fn add_assign(&mut self, rhs: Matrix<ROWS, COLS>)

Performs the += operation. Read more
Source§

impl<const ROWS: usize, const COLS: usize> Clone for Matrix<ROWS, COLS>

Source§

fn clone(&self) -> Matrix<ROWS, COLS>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const ROWS: usize, const COLS: usize> Debug for Matrix<ROWS, COLS>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const ROWS: usize, const COLS: usize> Index<usize> for Matrix<ROWS, COLS>

Source§

type Output = Vec<f64, COLS>

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<const ROWS: usize, const COLS: usize> IndexMut<usize> for Matrix<ROWS, COLS>

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

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>

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§

fn y_concat<const RHS_ROWS: usize, const NEW_ROWS: usize>( self, rhs: Matrix<RHS_ROWS, COLS>, ) -> Result<Matrix<NEW_ROWS, COLS>, &'static str>

Function that concatenates matrices vertically Read more
Source§

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,

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]);
    }
}
Source§

type TransposeType = Matrix<COLS, ROWS>

Source§

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,

Function that creates an identity matrix
Source§

fn to_double(&self) -> Result<f64, &'static str>

Function that converts a 1x1 matrix into a f64
Source§

fn transpose(&self) -> Self::TransposeType

Function that transposes a matrix
Source§

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>

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>

Function that returns the submatrix of a matrix Read more
Source§

fn vector_to_row(elems: [f64; ROWS]) -> Result<Matrix<ROWS, 1>, &'static str>

Function that takes the element from the array and sort them in a matrix row of dimensions ROWS x 1
Source§

fn pinv<const DOUBLE: usize>(&self) -> Result<Matrix<COLS, ROWS>, &'static str>

Function that implements Moore-Penrose pseudoinversion 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>

Source§

type Output = Matrix<LHS_ROWS, RHS_COLS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Matrix<LHS_COLS, RHS_COLS>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const ROWS: usize, const COLS: usize> Mul<Matrix<ROWS, COLS>> for f64

Source§

type Output = Matrix<ROWS, COLS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Matrix<ROWS, COLS>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const ROWS: usize, const COLS: usize> Mul<f64> for Matrix<ROWS, COLS>

Source§

type Output = Matrix<ROWS, COLS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Self::Output

Performs the * operation. Read more
Source§

impl<const N: usize> MulAssign<&Matrix<N, N>> for Matrix<N, N>

Source§

fn mul_assign(&mut self, rhs: &Matrix<N, N>)

Performs the *= operation. Read more
Source§

impl<const ROWS: usize, const COLS: usize> MulAssign<f64> for Matrix<ROWS, COLS>

Source§

fn mul_assign(&mut self, rhs: f64)

Performs the *= operation. Read more
Source§

impl<const N: usize> MulAssign for Matrix<N, N>

Source§

fn mul_assign(&mut self, rhs: Matrix<N, N>)

Performs the *= operation. Read more
Source§

impl<const ROWS: usize, const COLS: usize> PartialEq for Matrix<ROWS, COLS>

Source§

fn eq(&self, other: &Matrix<ROWS, COLS>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const N: usize> SquareMatrix<N> for Matrix<N, N>

Source§

fn det(&self) -> f64

Function that calculates the determinant of a square matrix
Source§

fn inv<const DOUBLE_COLS: usize>(&self) -> Result<Matrix<N, N>, &'static str>

Function that calculates the inversion of a sqaure matrix if possible, othervise it returns an Err Read more
Source§

fn pow(&self, n: usize) -> Matrix<N, N>

Function that calculates the pow of a square matrix
Source§

fn diag(elems: [f64; N]) -> Result<Matrix<N, N>, &'static str>

Function that takes the element from an array an makes a diagonal matrix using them
Source§

impl<const ROWS: usize, const COLS: usize> Sub for Matrix<ROWS, COLS>

Source§

type Output = Matrix<ROWS, COLS>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Matrix<ROWS, COLS>) -> Self::Output

Performs the - operation. Read more
Source§

impl<const ROWS: usize, const COLS: usize> SubAssign for Matrix<ROWS, COLS>

Source§

fn sub_assign(&mut self, rhs: Matrix<ROWS, COLS>)

Performs the -= operation. Read more
Source§

impl<const ROWS: usize> VectorCol<ROWS> for Matrix<ROWS, 1>

Source§

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
Source§

impl<const N: usize> IsSquareMatrix for Matrix<N, N>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.