Skip to main content

Crate tpt_math_linalg_fixed

Crate tpt_math_linalg_fixed 

Source
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 × C matrix of elements of type T, stored row-major.
Vector
A fixed-size column vector of N elements of type T, stored inline.

Type Aliases§

Matrix2
2×2 matrix.
Matrix3
3×3 matrix.
Matrix4
4×4 matrix.
Matrix2x3
2×3 matrix.
Matrix3x4
3×4 matrix.
Matrix4x3
4×3 matrix.
Vector2
2-D vector.
Vector3
3-D vector.
Vector4
4-D vector.
Vector6
6-D vector.