tpt-math-linalg-fixed
Const-generic, fixed-size (stack-allocated) linear algebra. No allocator.
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 (ADR-0007). Storage is plain fixed-size
arrays ([T; N] / [[T; C]; R]), so every type here is #![no_std] and
allocator-free.
Types
Vector<T, N>— a fixed-size column vector ofNelements, with aliasesVector2,Vector3,Vector4,Vector6.Matrix<T, R, C>— a fixed-size, row-majorR × Cmatrix, with aliasesMatrix2,Matrix3,Matrix4,Matrix2x3,Matrix3x4,Matrix4x3.
All arithmetic is generic over tpt_math_numeric::Scalar (i.e. any float
type). Elementwise, scalar, dot/cross and matrix-product ops are implemented.
Square matrices get closed-form determinant/inverse via Gauss elimination
with partial pivoting (exact for 2×2 / 3×3 / 4×4, and works for any size).
inverse() treats pivots below 1e-12 as singular. inverse_with_tolerance
takes an absolute threshold, and inverse_with_relative_tolerance a
scale-invariant one.
Features
std(default) — enablestpt-math-numeric/std.alloc— enablestpt-math-numeric/alloc.
Neither feature is required: the crate is usable in a plain #![no_std],
allocator-free context with default-features = false.
Example
use ;
let a = new;
let b = new;
assert_eq!;
let m = identity;
assert_eq!;
no_std example
The crate needs no allocator, so it runs on bare-metal targets. This program
uses only core types and the crate's fixed-size API:
use Matrix;
/// Solve a 2x2 system by inverting its matrix. Returns `None` if singular.
License
Licensed under either of MIT or Apache-2.0 at your option.