[][src]Struct quick_maths::Matrix

pub struct Matrix<T = DefaultFloat, const M: usize, const N: usize>(pub [Vector<T, M>; N])
where
    [T; M]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
;

A matrix, where each vector represents a column

Implementations

impl<T: Float, const M: usize, const N: usize> Matrix<T, M, N> where
    [T; M]: LengthAtMost32,
    [T; N]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
[src]

pub fn dot(&self, vec: &Vector<T, N>) -> Vector<T, M>[src]

pub fn t(&self) -> Matrix<T, N, M> where
    [Vector<T, N>; M]: LengthAtMost32
[src]

pub fn matmul<const P: usize>(&self, o: Matrix<T, N, P>) -> Matrix<T, M, P> where
    [Vector<T, N>; P]: LengthAtMost32,
    [Vector<T, M>; P]: LengthAtMost32,
    [T; P]: LengthAtMost32
[src]

Performs naive matrix multiplication

pub fn swap_rows(&mut self, cols: Range<usize>, a: usize, b: usize)[src]

pub fn swap_cols(&mut self, a: usize, b: usize)[src]

pub fn apply_fn<F, S>(&self, f: F) -> Matrix<S, M, N> where
    F: FnMut(T) -> S + Copy,
    S: Float,
    [S; M]: LengthAtMost32,
    [S; N]: LengthAtMost32,
    [Vector<S, M>; N]: LengthAtMost32
[src]

pub fn zxtend<const I: usize, const J: usize>(&self) -> Matrix<T, I, J> where
    [T; I]: LengthAtMost32,
    [T; J]: LengthAtMost32,
    [Vector<T, I>; J]: LengthAtMost32
[src]

Zero extend this matrix to a larger size

pub fn reduce<const I: usize, const J: usize>(&self) -> Matrix<T, I, J> where
    [T; I]: LengthAtMost32,
    [T; J]: LengthAtMost32,
    [Vector<T, I>; J]: LengthAtMost32
[src]

Take some subset of this matrix(only takes from the topt left)

pub fn frobenius(&self) -> T[src]

impl<T: Float, const M: usize> Matrix<T, M, M> where
    [T; M]: LengthAtMost32,
    [Vector<T, M>; M]: LengthAtMost32
[src]

pub fn diag(&self) -> impl Iterator<Item = T> + '_[src]

Returns elements on the diagonal from top left to bottom right

pub fn off_diag(&self) -> impl Iterator<Item = T> + '_[src]

Returns elements not on the diagonal in no specific order

pub fn trace(&self) -> T[src]

pub fn lup(&self) -> (Self, Self, Self)[src]

LUP decomposes self into lower triangular, upper triangular and pivot matrix

pub fn usolve(&self, b: &Vector<T, M>) -> Vector<T, M>[src]

Given an upper triangular matrix and a vector, compute the solution to the system of equations

pub fn lsolve(&self, b: &Vector<T, M>) -> Vector<T, M>[src]

Given a lower triangular matrix and a vector, compute the solution to the system of equations

pub fn solve((l, u, p): &(Self, Self, Self), b: &Vector<T, M>) -> Vector<T, M>[src]

Solves for x in the linear system Ax = b;

impl<T: Float> Matrix<T, 3usize, 3usize>[src]

pub fn new(c0: Vec3<T>, c1: Vec3<T>, c2: Vec3<T>) -> Self[src]

pub fn det(&self) -> T[src]

Computes the determinant of this matrix

pub fn inv(&self) -> Self[src]

Inverts this matrix, does not handle non-invertible matrices

pub fn rot(around: &Vec3<T>, cos_t: T) -> Self[src]

pub fn scale(by: &Vec3<T>) -> Self[src]

pub fn translate(by: &Vec2<T>) -> Self[src]

Translation operator for 2 space

pub fn project(normal: &Vec3<T>) -> Self[src]

pub fn from_quat(q: Quat<T>) -> Self[src]

https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation Converts a quaternion into an equivalent matrix

impl<T: Float> Matrix<T, 2usize, 2usize>[src]

pub fn det(&self) -> T[src]

Computes the determinant of this matrix

pub fn inv(&self) -> Self[src]

Inverts this matrix, does not handle non-invertible matrices

pub fn rot(theta: T) -> Self[src]

Returns the rotation matrix given a theta in the counterclockwise direction

pub fn scale(sx: T, sy: T) -> Self[src]

Returns the scale matrix given scale in each direction

impl<T: Float> Matrix<T, 4usize, 4usize>[src]

pub fn new(c0: Vec4<T>, c1: Vec4<T>, c2: Vec4<T>, c3: Vec4<T>) -> Self[src]

pub fn translate(t: Vec3<T>) -> Self[src]

Returns a translation matrix by t

pub fn inv(&self) -> Self[src]

Computes the inverse of this matrix if it exists

impl<T: Float, const M: usize, const N: usize> Matrix<T, M, N> where
    [T; M]: LengthAtMost32,
    [T; N]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
[src]

pub fn cos(&self) -> Self[src]

Element-wise cos .

pub fn sin(&self) -> Self[src]

Element-wise sin .

pub fn tan(&self) -> Self[src]

Element-wise tan .

pub fn acos(&self) -> Self[src]

Element-wise acos .

pub fn asin(&self) -> Self[src]

Element-wise asin .

pub fn atan(&self) -> Self[src]

Element-wise atan .

pub fn acosh(&self) -> Self[src]

Element-wise acosh .

pub fn asinh(&self) -> Self[src]

Element-wise asinh .

pub fn atanh(&self) -> Self[src]

Element-wise atanh .

pub fn atan2(&self, v: T) -> Self[src]

Element-wise atan2 .

pub fn hypot(&self, v: T) -> Self[src]

Element-wise hypot .

pub fn ceil(&self) -> Self[src]

Element-wise ceil .

pub fn floor(&self) -> Self[src]

Element-wise floor .

pub fn round(&self) -> Self[src]

Element-wise round .

pub fn fract(&self) -> Self[src]

Element-wise fract .

pub fn trunc(&self) -> Self[src]

Element-wise trunc .

pub fn abs(&self) -> Self[src]

Element-wise abs .

pub fn abs_sub(&self, v: T) -> Self[src]

Element-wise abs_sub .

pub fn signum(&self) -> Self[src]

Element-wise signum .

pub fn recip(&self) -> Self[src]

Element-wise recip .

pub fn log2(&self) -> Self[src]

Element-wise log2 .

pub fn log10(&self) -> Self[src]

Element-wise log10 .

pub fn ln(&self) -> Self[src]

Element-wise ln .

pub fn ln_1p(&self) -> Self[src]

Element-wise ln_1p .

pub fn exp(&self) -> Self[src]

Element-wise exp .

pub fn exp2(&self) -> Self[src]

Element-wise exp2 .

pub fn exp_m1(&self) -> Self[src]

Element-wise exp_m1 .

pub fn sqrt(&self) -> Self[src]

Element-wise sqrt .

pub fn cbrt(&self) -> Self[src]

Element-wise cbrt .

pub fn powf(&self, v: T) -> Self[src]

Element-wise powf .

pub fn powi(&self, v: i32) -> Self[src]

pub fn log(&self, v: T) -> Self[src]

Element-wise log .

pub fn max(&self, v: T) -> Self[src]

Element-wise max .

pub fn min(&self, v: T) -> Self[src]

Element-wise min .

pub fn to_degrees(&self) -> Self[src]

Element-wise to_degrees .

pub fn to_radians(&self) -> Self[src]

Element-wise to_radians .

Trait Implementations

impl<T: Float, const M: usize, const N: usize> Add<Matrix<T, M, N>> for Matrix<T, M, N> where
    [T; M]: LengthAtMost32,
    [T; N]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
[src]

type Output = Self

The resulting type after applying the + operator.

impl<T: Float, const M: usize, const N: usize> Add<T> for Matrix<T, M, N> where
    [T; M]: LengthAtMost32,
    [T; N]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
[src]

type Output = Self

The resulting type after applying the + operator.

impl<T: Clone, const M: usize, const N: usize> Clone for Matrix<T, M, N> where
    [T; M]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
[src]

impl<T: Copy, const M: usize, const N: usize> Copy for Matrix<T, M, N> where
    [T; M]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
[src]

impl<T: Debug, const M: usize, const N: usize> Debug for Matrix<T, M, N> where
    [T; M]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
[src]

impl<T: Float, const M: usize, const N: usize> Div<Matrix<T, M, N>> for Matrix<T, M, N> where
    [T; M]: LengthAtMost32,
    [T; N]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
[src]

type Output = Self

The resulting type after applying the / operator.

impl<T: Float, const M: usize, const N: usize> Div<T> for Matrix<T, M, N> where
    [T; M]: LengthAtMost32,
    [T; N]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
[src]

type Output = Self

The resulting type after applying the / operator.

impl<T: Eq, const M: usize, const N: usize> Eq for Matrix<T, M, N> where
    [T; M]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
[src]

impl<T: Float, const M: usize, const N: usize> Index<usize> for Matrix<T, M, N> where
    [T; M]: LengthAtMost32,
    [T; N]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
[src]

type Output = Vector<T, M>

The returned type after indexing.

impl<T: Float, const M: usize, const N: usize> IndexMut<usize> for Matrix<T, M, N> where
    [T; M]: LengthAtMost32,
    [T; N]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
[src]

impl<T: Float, const M: usize, const N: usize> Mul<Matrix<T, M, N>> for Matrix<T, M, N> where
    [T; M]: LengthAtMost32,
    [T; N]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
[src]

type Output = Self

The resulting type after applying the * operator.

impl<T: Float, const M: usize, const N: usize> Mul<T> for Matrix<T, M, N> where
    [T; M]: LengthAtMost32,
    [T; N]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
[src]

type Output = Self

The resulting type after applying the * operator.

impl<T: Float, const M: usize> One for Matrix<T, M, M> where
    [T; M]: LengthAtMost32,
    [Vector<T, M>; M]: LengthAtMost32
[src]

Multiplicative identity

impl<T: PartialEq, const M: usize, const N: usize> PartialEq<Matrix<T, M, N>> for Matrix<T, M, N> where
    [T; M]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
[src]

impl<T, const M: usize, const N: usize> StructuralEq for Matrix<T, M, N> where
    [T; M]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
[src]

impl<T, const M: usize, const N: usize> StructuralPartialEq for Matrix<T, M, N> where
    [T; M]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
[src]

impl<T: Float, const M: usize, const N: usize> Sub<Matrix<T, M, N>> for Matrix<T, M, N> where
    [T; M]: LengthAtMost32,
    [T; N]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
[src]

type Output = Self

The resulting type after applying the - operator.

impl<T: Float, const M: usize, const N: usize> Sub<T> for Matrix<T, M, N> where
    [T; M]: LengthAtMost32,
    [T; N]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
[src]

type Output = Self

The resulting type after applying the - operator.

impl<T: Float, const M: usize, const N: usize> Zero for Matrix<T, M, N> where
    [T; M]: LengthAtMost32,
    [T; N]: LengthAtMost32,
    [Vector<T, M>; N]: LengthAtMost32
[src]

Auto Trait Implementations

impl<const M: usize, const N: usize, T> RefUnwindSafe for Matrix<T, M, N> where
    T: RefUnwindSafe

impl<const M: usize, const N: usize, T> Send for Matrix<T, M, N> where
    T: Send

impl<const M: usize, const N: usize, T> Sync for Matrix<T, M, N> where
    T: Sync

impl<const M: usize, const N: usize, T> Unpin for Matrix<T, M, N> where
    T: Unpin

impl<const M: usize, const N: usize, T> UnwindSafe for Matrix<T, M, N> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.