Skip to main content

FixedMatrix

Struct FixedMatrix 

Source
pub struct FixedMatrix<T, const R: usize, const C: usize> { /* private fields */ }
Expand description

Stack-backed row-major fixed-size matrix.

Implementations§

Source§

impl FixedMatrix<f64, 3, 3>

Source

pub const fn from_row_major(data: [f64; 9]) -> Self

Create a 3x3 matrix from row-major storage.

Source

pub const fn from_column_major(data: [f64; 9]) -> Self

Create a 3x3 matrix from column-major storage.

Source

pub fn into_row_major(self) -> [f64; 9]

Return the matrix entries in row-major order.

Source

pub fn into_column_major(self) -> [f64; 9]

Return the matrix entries in column-major order.

Source

pub fn determinant(&self) -> f64

Determinant of a 3x3 matrix.

Source

pub fn symmetric_eigen(&self) -> (FixedVector<f64, 3>, Self)

Eigendecomposition of a real symmetric 3x3 matrix.

Uses the analytic cubic formula (trigonometric solution of the depressed cubic) for eigenvalues and the cross-product of (A - λI) columns for eigenvectors. Eigenvalues are sorted descending; eigenvectors are orthonormal columns of the returned matrix.

Source

pub fn try_inverse(&self) -> Option<Self>

Inverse of a 3x3 matrix using the analytic cofactor formula.

Returns None when the matrix is singular (determinant ≈ 0).

Source§

impl FixedMatrix<f64, 2, 2>

Source

pub fn determinant(&self) -> f64

Determinant of a 2x2 matrix.

Source

pub fn symmetric_eigen(&self) -> (FixedVector<f64, 2>, Self)

Eigendecomposition of a real symmetric 2x2 matrix.

Uses the closed-form quadratic formula. Eigenvalues are sorted descending; eigenvectors are orthonormal columns.

Source

pub fn try_inverse(&self) -> Option<Self>

Inverse of a 2x2 matrix using cofactor formula.

Returns None when the matrix is singular (determinant ≈ 0).

Source§

impl<T, const R: usize, const C: usize> FixedMatrix<T, R, C>

Source

pub const fn from_rows(data: [[T; C]; R]) -> Self

Create a row-major matrix from rows.

Source

pub fn into_rows(self) -> [[T; C]; R]

Return the row-major matrix storage.

Source

pub const fn rows(&self) -> &[[T; C]; R]

Borrow the row-major matrix storage.

Source

pub fn iter(&self) -> impl Iterator<Item = &T>

Iterate over matrix entries in row-major order.

Source§

impl<T, const R: usize, const C: usize> FixedMatrix<T, R, C>
where T: Copy + Default,

Source

pub fn zeros() -> Self

Create a zero matrix.

Source

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

Transpose the matrix.

Source

pub fn from_columns(columns: [FixedVector<T, R>; C]) -> Self

Create a matrix from column vectors.

Source

pub fn set_column(&mut self, column: usize, values: FixedVector<T, R>)

Replace one matrix column.

Source§

impl<T, const N: usize> FixedMatrix<T, N, N>
where T: Copy + Default + From<u8>,

Source

pub fn identity() -> Self

Create an identity matrix.

Source§

impl<T> FixedMatrix<T, 4, 4>
where T: Copy + Default + From<u8> + Add<Output = T> + Sub<Output = T> + Mul<Output = T> + Div<Output = T> + PartialEq + Neg<Output = T>,

Source

pub fn from_row_major(data: [T; 16]) -> Self

Create a 4×4 matrix from row-major storage.

Source

pub fn from_column_major(data: [T; 16]) -> Self

Create a 4×4 matrix from column-major storage.

Source

pub fn into_row_major(self) -> [T; 16]

Return the matrix entries in row-major order.

Source

pub fn into_column_major(self) -> [T; 16]

Return the matrix entries in column-major order.

Source

pub fn determinant(&self) -> T

Determinant using cofactor expansion along the first row.

Source

pub fn try_inverse(&self) -> Option<Self>

Inverse using the adjugate (cofactor matrix transpose) divided by the determinant. Returns None when the matrix is singular.

Trait Implementations§

Source§

impl<T, const R: usize, const C: usize> Add for FixedMatrix<T, R, C>
where T: Copy + Add<Output = T>,

Source§

type Output = FixedMatrix<T, R, C>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<T, const R: usize, const C: usize> AddAssign for FixedMatrix<T, R, C>
where T: Copy + AddAssign,

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<T: Clone, const R: usize, const C: usize> Clone for FixedMatrix<T, R, C>

Source§

fn clone(&self) -> Self

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<T: Copy, const R: usize, const C: usize> Copy for FixedMatrix<T, R, C>

Source§

impl<T: Debug, const R: usize, const C: usize> Debug for FixedMatrix<T, R, C>

Source§

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

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

impl<T, const R: usize, const C: usize> Div<T> for FixedMatrix<T, R, C>
where T: Copy + Div<Output = T>,

Source§

type Output = FixedMatrix<T, R, C>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
Source§

impl<T, const R: usize, const C: usize> DivAssign<T> for FixedMatrix<T, R, C>
where T: Copy + DivAssign,

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl<T, const R: usize, const C: usize> Index<(usize, usize)> for FixedMatrix<T, R, C>

Source§

type Output = T

The returned type after indexing.
Source§

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

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

impl<T, const R: usize, const C: usize> IndexMut<(usize, usize)> for FixedMatrix<T, R, C>

Source§

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

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

impl<T, const R: usize, const K: usize, const C: usize> Mul<FixedMatrix<T, K, C>> for FixedMatrix<T, R, K>
where T: Copy + Default + Add<Output = T> + Mul<Output = T>,

Source§

type Output = FixedMatrix<T, R, C>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: FixedMatrix<T, K, C>) -> Self::Output

Performs the * operation. Read more
Source§

impl<T, const R: usize, const C: usize> Mul<FixedVector<T, C>> for FixedMatrix<T, R, C>
where T: Copy + Default + Add<Output = T> + Mul<Output = T>,

Source§

type Output = FixedVector<T, R>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: FixedVector<T, C>) -> Self::Output

Performs the * operation. Read more
Source§

impl<T, const R: usize, const C: usize> Mul<T> for FixedMatrix<T, R, C>
where T: Copy + Mul<Output = T>,

Source§

type Output = FixedMatrix<T, R, C>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<T, const R: usize, const C: usize> MulAssign<T> for FixedMatrix<T, R, C>
where T: Copy + MulAssign,

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl<T, const R: usize, const C: usize> Neg for FixedMatrix<T, R, C>
where T: Copy + Neg<Output = T>,

Source§

type Output = FixedMatrix<T, R, C>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<T: PartialEq, const R: usize, const C: usize> PartialEq for FixedMatrix<T, R, C>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<T: PartialEq, const R: usize, const C: usize> StructuralPartialEq for FixedMatrix<T, R, C>

Source§

impl<T, const R: usize, const C: usize> Sub for FixedMatrix<T, R, C>
where T: Copy + Sub<Output = T>,

Source§

type Output = FixedMatrix<T, R, C>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<T, const R: usize, const C: usize> SubAssign for FixedMatrix<T, R, C>
where T: Copy + SubAssign,

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more

Auto Trait Implementations§

§

impl<T, const R: usize, const C: usize> Freeze for FixedMatrix<T, R, C>
where [[T; C]; R]: Freeze,

§

impl<T, const R: usize, const C: usize> RefUnwindSafe for FixedMatrix<T, R, C>

§

impl<T, const R: usize, const C: usize> Send for FixedMatrix<T, R, C>
where [[T; C]; R]: Send,

§

impl<T, const R: usize, const C: usize> Sync for FixedMatrix<T, R, C>
where [[T; C]; R]: Sync,

§

impl<T, const R: usize, const C: usize> Unpin for FixedMatrix<T, R, C>
where [[T; C]; R]: Unpin,

§

impl<T, const R: usize, const C: usize> UnsafeUnpin for FixedMatrix<T, R, C>
where [[T; C]; R]: UnsafeUnpin,

§

impl<T, const R: usize, const C: usize> UnwindSafe for FixedMatrix<T, R, C>
where [[T; C]; R]: UnwindSafe,

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> Same for T

Source§

type Output = T

Should always be Self
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.