Skip to main content

Module matrix

Module matrix 

Source
Expand description

2x2 and 3x3 f32 matrices for no_std embedded systems, powered by embedded-matrix.

Provides Matrix2x2 and Matrix3x3 with native operators (+, -, *, unary -, matrix-vector multiplication, +=, -=, *=), determinant, trace, transpose, inversion (inv), and linear system solving (solve) without heap allocation, libm, or unsafe.

§Behavior & Notes

Operation / InputBehavior
Matrix2x2::new / Matrix3x3::newBuilds from row-major [[f32; N]; N] (identity, zero, from_diagonal)
inv()Returns Result<M, MatrixError> using a scale-relative singularity check
solve(b)Solves A * x = b -> Result<[f32; N], MatrixError>
rotation / rotation_x/y/zAvailable when the trig feature is enabled on embedded-matrix
Singular matrixReturns Err(MatrixError::SingularMatrix)
NaN, ±Infinity, or overflowReturns Err(MatrixError::NonFiniteValue)

Structs§

Matrix2x2
A 2×2 f32 matrix stored in row-major order.
Matrix3x3
A 3×3 f32 matrix stored in row-major order.

Enums§

MatrixError
Error returned when a matrix operation is invalid.

Functions§

inv_2x2
Inverts a 2x2 matrix.
inv_3x3
Inverts a 3x3 matrix.
solve_2x2
Solves a 2x2 linear system A * x = b.
solve_3x3
Solves a 3x3 linear system A * x = b.