Skip to main content

MatrixPrecise

Struct MatrixPrecise 

Source
pub struct MatrixPrecise<const R: usize, const C: usize> {
    pub data: [[r32; C]; R],
}
Expand description

Precise Matrix Type using rational components - R rows, C columns, components are r32. Stored in row-major format, indexable by usize indices - row then column.

Fields§

§data: [[r32; C]; R]

2D Array of r32 data.

Implementations§

Source§

impl<const R: usize, const C: usize> MatrixPrecise<R, C>

Source

pub fn new(data: [[r32; C]; R]) -> Self

Returns a new Matrix with R rows and C columns from a correctly shaped array of r32.

Source

pub fn num_rows() -> usize

Returns R, the number of rows in this Matrix Type (i.e. returns 3 for a Matrix<3, 4>).

Source

pub fn col_len() -> usize

Returns R, the length of a column in this Matrix Type (i.e. returns 3 for a Matrix<3, 4>).

Source

pub fn num_cols() -> usize

Returns C, the number of columns in this Matrix Type (i.e. returns 4 for a Matrix<3, 4>).

Source

pub fn row_len() -> usize

Returns C, the length of a row in this Matrix Type (i.e. returns 4 for a Matrix<3, 4>).

Source

pub fn row(&self, index: usize) -> VectorPrecise<C>

Returns a single row of the Matrix as a VectorPrecise, indexed by usize.

Source

pub fn col(&self, index: usize) -> VectorPrecise<R>

Returns a single column of the Matrix as a VectorPrecise, indexed by usize.

Source

pub fn multiply<const D: usize>( &self, other: MatrixPrecise<C, D>, ) -> MatrixPrecise<R, D>

Utility function for multiplying matrices - as per standard matrix multiplication, to multiply two matrices of dimensions (A, B) and (C, D), B must equal C. Used for implementing std::ops.

Source

pub fn transpose(&self) -> MatrixPrecise<C, R>

Source

pub fn change_dimensions<const R0: usize, const C0: usize>( &self, ) -> MatrixPrecise<R0, C0>

Source

pub fn minor(&self, row: usize, col: usize) -> Option<MatrixPrecise<R, C>>

Source

pub fn to_data_vec(&self) -> Vec<r32>

Source

pub fn minor_vec( vec: &Vec<r32>, dim: (usize, usize), index: (usize, usize), ) -> Vec<r32>

Source§

impl<const L: usize> MatrixPrecise<L, L>

Source

pub fn det(&self) -> Option<r32>

Source

pub fn det_vec(vec: &Vec<r32>, dim: usize) -> Option<r32>

Source

pub fn cofactor(&self) -> Option<MatrixPrecise<L, L>>

Source

pub fn adjoint(&self) -> Option<MatrixPrecise<L, L>>

Source

pub fn inverse(&self) -> Option<MatrixPrecise<L, L>>

Source

pub fn cofactor_vec(vec: &Vec<r32>, dim: usize) -> Option<Vec<r32>>

Source

pub fn lu(&self) -> Option<(Self, Self)>

LU decomposition - may not succeed, tries to triangulate into two triangular matrices, L and U.

Source

pub fn lup(&self) -> Option<(Self, Self, Self)>

LUP decomposition - may not succeed, tries to decompose into two triangular matrices L and U, with a permutation matrix P.

Source

pub fn lup_det(&self) -> Option<r32>

Tries to calculate the determinant using LUP decomposition.

Source

pub fn forward_sub(&self, target: VectorPrecise<L>) -> VectorPrecise<L>

Forward substitution - solves for Lx = b where L is a lower triangular matrix. Takes target vector b and calculates x, where the matrix is L.

Source

pub fn back_sub(&self, target: VectorPrecise<L>) -> VectorPrecise<L>

Backward substitution - solves for Ux = b where U is an upper triangular matrix. Takes target vector b and calculates x, where the matrix is U.

Source

pub fn lup_sub(&self, target: VectorPrecise<L>) -> Option<VectorPrecise<L>>

LUP substitution - uses LUP decomposition to solve for Ax = b, where A is the matrix calling this, b is the target vector provided as an argument, and x is returned - dependent on successful LUP decomposition.

Source

pub fn lup_inverse(&self) -> Option<MatrixPrecise<L, L>>

Attempts to calculate an inverse matrix for this matrix using LUP substitution. This will fail if a LUP decomposition cannot be found for the matrix.

Trait Implementations§

Source§

impl<const R: usize, const C: usize> Clone for MatrixPrecise<R, C>

Source§

fn clone(&self) -> MatrixPrecise<R, C>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<const R: usize, const C: usize> Debug for MatrixPrecise<R, C>

Source§

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

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

impl<const A: usize, const B: usize> Default for MatrixPrecise<A, B>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const A: usize, const B: usize> Display for MatrixPrecise<A, B>

Source§

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

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

impl<const R: usize, const C: usize> From<Matrix<R, C>> for MatrixPrecise<R, C>

Source§

fn from(v: Matrix<R, C>) -> Self

Converts to this type from the input type.
Source§

impl<const R: usize, const C: usize> From<MatrixPrecise<R, C>> for Matrix<R, C>

Source§

fn from(v: MatrixPrecise<R, C>) -> Self

Converts to this type from the input type.
Source§

impl<const R: usize, const C: usize> Hash for MatrixPrecise<R, C>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

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

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<const A: usize> Identity for MatrixPrecise<A, A>

Source§

fn identity() -> Self

Source§

impl<const A: usize, const B: usize> Index<usize> for MatrixPrecise<A, B>

Source§

type Output = [r32; B]

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &[r32; B]

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

impl<const A: usize, const B: usize> IndexMut<usize> for MatrixPrecise<A, B>

Source§

fn index_mut(&mut self, index: usize) -> &mut [r32; B]

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

impl<const A: usize, const B: usize> Mul<MatrixPrecise<A, B>> for VectorPrecise<A>

Source§

type Output = VectorPrecise<B>

The resulting type after applying the * operator.
Source§

fn mul(self, other: MatrixPrecise<A, B>) -> VectorPrecise<B>

Performs the * operation. Read more
Source§

impl<const A: usize, const B: usize> Mul<MatrixPrecise<A, B>> for r32

Source§

type Output = MatrixPrecise<A, B>

The resulting type after applying the * operator.
Source§

fn mul(self, other: MatrixPrecise<A, B>) -> MatrixPrecise<A, B>

Performs the * operation. Read more
Source§

impl<const A: usize, const B: usize, const C: usize> Mul<MatrixPrecise<B, C>> for MatrixPrecise<A, B>

Source§

type Output = MatrixPrecise<A, C>

The resulting type after applying the * operator.
Source§

fn mul(self, other: MatrixPrecise<B, C>) -> MatrixPrecise<A, C>

Performs the * operation. Read more
Source§

impl<const A: usize, const B: usize> Mul<VectorPrecise<B>> for MatrixPrecise<A, B>

Source§

type Output = VectorPrecise<A>

The resulting type after applying the * operator.
Source§

fn mul(self, other: VectorPrecise<B>) -> VectorPrecise<A>

Performs the * operation. Read more
Source§

impl<const A: usize, const B: usize> Mul<r32> for MatrixPrecise<A, B>

Source§

type Output = MatrixPrecise<A, B>

The resulting type after applying the * operator.
Source§

fn mul(self, other: r32) -> MatrixPrecise<A, B>

Performs the * operation. Read more
Source§

impl<const R: usize, const C: usize> PartialEq for MatrixPrecise<R, C>

Source§

fn eq(&self, other: &MatrixPrecise<R, C>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 R: usize, const C: usize> Copy for MatrixPrecise<R, C>

Source§

impl<const R: usize, const C: usize> Eq for MatrixPrecise<R, C>

Source§

impl<const R: usize, const C: usize> StructuralPartialEq for MatrixPrecise<R, C>

Auto Trait Implementations§

§

impl<const R: usize, const C: usize> Freeze for MatrixPrecise<R, C>

§

impl<const R: usize, const C: usize> RefUnwindSafe for MatrixPrecise<R, C>

§

impl<const R: usize, const C: usize> Send for MatrixPrecise<R, C>

§

impl<const R: usize, const C: usize> Sync for MatrixPrecise<R, C>

§

impl<const R: usize, const C: usize> Unpin for MatrixPrecise<R, C>

§

impl<const R: usize, const C: usize> UnsafeUnpin for MatrixPrecise<R, C>

§

impl<const R: usize, const C: usize> UnwindSafe for MatrixPrecise<R, C>

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

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.