Struct heapless_matrix::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>

§

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 copy 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>

§

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> ) -> Option<Matrix<ROWS, NEW_COLS>>

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> ) -> Option<Matrix<NEW_ROWS, COLS>>

Function that concatenates matrices vertically
source§

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

source§

fn from_vector(data: [[f64; COLS]; ROWS]) -> Option<Self>
where Self: Sized,

Function used to create a heapless matrix from an 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() -> Option<Self>
where Self: Sized,

Function that creates an matrix where all elements are equal to zero
source§

fn eye() -> Option<Self>
where Self: Sized,

Function that creates an identity matrix
source§

fn to_double(&self) -> Option<f64>

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>

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>

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>

§

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> PartialEq for Matrix<ROWS, COLS>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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

source§

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

source§

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

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> 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.