Native vector/matrix/tensor implementation
Calculations are performed inplace as much as possible to reduce allocations and copying.
Most places assume that vector/matrix sizes are correct.
Other places panic on wrong sizes. This is intentional since the code is intended for
embedded systems like microcontrollers. Therefore always test your code.
Some operations require a destination vector/matrix. The design decision was made
to have Vector
and Matrix
serve as the mutable arguments instead of a pointer to
a concrete type, e.g. Matrix3x3
.
Most of the code uses math32
package directly, however, in the future this package should be float32
implementation of basic math operations or a proxy to some other embedded math library.
Auto - Generated
The main code is in gen/*.tpl
and is autogenerated using parameters from gen/*.json
.
Generation instruction is in math.go
.
Tests were generated once and mostly generic implementagion is tested, however, where
more optimized implementation is available, then there will be tests for each such concrete
implementation.
Development cycle
Usually the fixes/development/experimentation is done on the generic implementation and/or
concrete in some cases, and then the code is moved to the template, generated back and tested.
NOTE: No manually edited code in the generated files should be commited.
Features
- Vectors
- Generic vector
- 2D, 3D, 4D
- Matrices
- Generic
- Inverse
- SVD
- Pseudo Inverse (for KI)
- 2x2, 3x3, 4x4, 3x4, 4x3
- Sparse matrix
- Tensors
- Helpers