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>
impl<const R: usize, const C: usize> MatrixPrecise<R, C>
Sourcepub fn new(data: [[r32; C]; R]) -> Self
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.
Sourcepub fn num_rows() -> usize
pub fn num_rows() -> usize
Returns R, the number of rows in this Matrix Type (i.e. returns 3 for a Matrix<3, 4>).
Sourcepub fn col_len() -> usize
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>).
Sourcepub fn num_cols() -> usize
pub fn num_cols() -> usize
Returns C, the number of columns in this Matrix Type (i.e. returns 4 for a Matrix<3, 4>).
Sourcepub fn row_len() -> usize
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>).
Sourcepub fn row(&self, index: usize) -> VectorPrecise<C>
pub fn row(&self, index: usize) -> VectorPrecise<C>
Returns a single row of the Matrix as a VectorPrecise
Sourcepub fn col(&self, index: usize) -> VectorPrecise<R>
pub fn col(&self, index: usize) -> VectorPrecise<R>
Returns a single column of the Matrix as a VectorPrecise
Sourcepub fn multiply<const D: usize>(
&self,
other: MatrixPrecise<C, D>,
) -> MatrixPrecise<R, D>
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.
pub fn transpose(&self) -> MatrixPrecise<C, R>
pub fn change_dimensions<const R0: usize, const C0: usize>( &self, ) -> MatrixPrecise<R0, C0>
pub fn minor(&self, row: usize, col: usize) -> Option<MatrixPrecise<R, C>>
pub fn to_data_vec(&self) -> Vec<r32>
pub fn minor_vec( vec: &Vec<r32>, dim: (usize, usize), index: (usize, usize), ) -> Vec<r32>
Source§impl<const L: usize> MatrixPrecise<L, L>
impl<const L: usize> MatrixPrecise<L, L>
pub fn det(&self) -> Option<r32>
pub fn det_vec(vec: &Vec<r32>, dim: usize) -> Option<r32>
pub fn cofactor(&self) -> Option<MatrixPrecise<L, L>>
pub fn adjoint(&self) -> Option<MatrixPrecise<L, L>>
pub fn inverse(&self) -> Option<MatrixPrecise<L, L>>
pub fn cofactor_vec(vec: &Vec<r32>, dim: usize) -> Option<Vec<r32>>
Sourcepub fn lu(&self) -> Option<(Self, Self)>
pub fn lu(&self) -> Option<(Self, Self)>
LU decomposition - may not succeed, tries to triangulate into two triangular matrices, L and U.
Sourcepub fn lup(&self) -> Option<(Self, Self, Self)>
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.
Sourcepub fn lup_det(&self) -> Option<r32>
pub fn lup_det(&self) -> Option<r32>
Tries to calculate the determinant using LUP decomposition.
Sourcepub fn forward_sub(&self, target: VectorPrecise<L>) -> VectorPrecise<L>
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.
Sourcepub fn back_sub(&self, target: VectorPrecise<L>) -> VectorPrecise<L>
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.
Sourcepub fn lup_sub(&self, target: VectorPrecise<L>) -> Option<VectorPrecise<L>>
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.
Sourcepub fn lup_inverse(&self) -> Option<MatrixPrecise<L, L>>
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>
impl<const R: usize, const C: usize> Clone for MatrixPrecise<R, C>
Source§fn clone(&self) -> MatrixPrecise<R, C>
fn clone(&self) -> MatrixPrecise<R, C>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<const R: usize, const C: usize> From<MatrixPrecise<R, C>> for Matrix<R, C>
impl<const R: usize, const C: usize> From<MatrixPrecise<R, C>> for Matrix<R, C>
Source§fn from(v: MatrixPrecise<R, C>) -> Self
fn from(v: MatrixPrecise<R, C>) -> Self
Source§impl<const A: usize, const B: usize> Mul<MatrixPrecise<A, B>> for VectorPrecise<A>
impl<const A: usize, const B: usize> Mul<MatrixPrecise<A, B>> for VectorPrecise<A>
Source§type Output = VectorPrecise<B>
type Output = VectorPrecise<B>
* operator.Source§fn mul(self, other: MatrixPrecise<A, B>) -> VectorPrecise<B>
fn mul(self, other: MatrixPrecise<A, B>) -> VectorPrecise<B>
* operation. Read moreSource§impl<const A: usize, const B: usize> Mul<MatrixPrecise<A, B>> for r32
impl<const A: usize, const B: usize> Mul<MatrixPrecise<A, B>> for r32
Source§type Output = MatrixPrecise<A, B>
type Output = MatrixPrecise<A, B>
* operator.Source§fn mul(self, other: MatrixPrecise<A, B>) -> MatrixPrecise<A, B>
fn mul(self, other: MatrixPrecise<A, B>) -> MatrixPrecise<A, B>
* operation. Read moreSource§impl<const A: usize, const B: usize, const C: usize> Mul<MatrixPrecise<B, C>> for MatrixPrecise<A, B>
impl<const A: usize, const B: usize, const C: usize> Mul<MatrixPrecise<B, C>> for MatrixPrecise<A, B>
Source§type Output = MatrixPrecise<A, C>
type Output = MatrixPrecise<A, C>
* operator.Source§fn mul(self, other: MatrixPrecise<B, C>) -> MatrixPrecise<A, C>
fn mul(self, other: MatrixPrecise<B, C>) -> MatrixPrecise<A, C>
* operation. Read moreSource§impl<const A: usize, const B: usize> Mul<VectorPrecise<B>> for MatrixPrecise<A, B>
impl<const A: usize, const B: usize> Mul<VectorPrecise<B>> for MatrixPrecise<A, B>
Source§type Output = VectorPrecise<A>
type Output = VectorPrecise<A>
* operator.Source§fn mul(self, other: VectorPrecise<B>) -> VectorPrecise<A>
fn mul(self, other: VectorPrecise<B>) -> VectorPrecise<A>
* operation. Read moreSource§impl<const A: usize, const B: usize> Mul<r32> for MatrixPrecise<A, B>
impl<const A: usize, const B: usize> Mul<r32> for MatrixPrecise<A, B>
Source§type Output = MatrixPrecise<A, B>
type Output = MatrixPrecise<A, B>
* operator.Source§impl<const R: usize, const C: usize> PartialEq for MatrixPrecise<R, C>
impl<const R: usize, const C: usize> PartialEq for MatrixPrecise<R, C>
Source§fn eq(&self, other: &MatrixPrecise<R, C>) -> bool
fn eq(&self, other: &MatrixPrecise<R, C>) -> bool
self and other values to be equal, and is used by ==.