Expand description
Const-generic, fixed-size (stack-allocated) linear algebra.
This crate mirrors the Vector3/Matrix4 layer of nalgebra but is
implemented from scratch with const generics, so it carries no Apache-2.0
dependency and needs no allocator. Storage is plain fixed-size arrays
([T; N] / [[T; C]; R]), so every type here is #![no_std] and
allocator-free.
All arithmetic is generic over tpt_math_numeric::Scalar (i.e. any float
type), and the usual elementwise, scalar, dot/cross and matrix-product ops
are implemented. Square matrices get closed-form Matrix::determinant and
Matrix::inverse (exact for 2×2 / 3×3 / 4×4, and by Gauss–Jordan for any
size).
§Examples
use tpt_math_linalg_fixed::{Vector3, Matrix3};
let a = Vector3::new([1.0_f64, 2.0, 3.0]);
let b = Vector3::new([4.0_f64, 5.0, 6.0]);
assert_eq!(a.dot(&b), 32.0);
let m = Matrix3::identity();
assert_eq!(m * a, a);Structs§
- Matrix
- A fixed-size
R × Cmatrix of elements of typeT, stored row-major. - Vector
- A fixed-size column vector of
Nelements of typeT, stored inline.