mlr - single-header-only C++23 linear algebra math library
mlr implements aligned array arr : std::array<T,N> based vector vec::type<T,N,A> type for N-dimensional linear algebra math and Quake C++ vec_t type interface.
cmake . --install-prefix=/usr
make installChange CMakeLists.txt compile flags to fit your needs:
add_compile_options(-march=native -mfpmath=[your SIMD instruction set] -O3)#include <mlr/scalar.hpp>
#include <mlr/vector.hpp>
#include <mlr/colour.hpp>
#include <mlr/matrix.hpp>
#include <nlr/versor.hpp>
using namespace math;
using qboolean = eb32;
const qboolean qfalse = MLR_FALSE;
const qboolean qtrue = MLR_TRUE;
using vecf_t = f32;
using vecd_t = f64;
using vec_t = vecf_t;
using ivec_t = i32;
using bf16 = u16;
using bf32 = u32;
using vec2_t = vec::vec_t<2 >;
using vec3_t = vec::vec_t<3 >;
using avec3_t = vec::vec_t<3, align::linear >;
using vec4_t = vec::vec_t<4 >;
using vec5_t = vec::vec_t<5 >;
using avec5_t = vec::vec_t<5, align::linear >;
using rgba8888_t = col::u8 <{R,G,B,A} >;
using rgb888_t = col::u8 <{R,G,B } >;
using rgbaf32_t = col::f32<{R,G,B,A} >;
using rgbf32_t = col::f32<{R,G,B } >;
using rgba4444_t = col::u16<{R,G,B,A},{4,4,4,4} >;
using rgb565_t = col::u16<{R,G,B} ,{5,6,6} >;
using rgb5551_t = col::u16<{R,G,B} ,{5,5,5,1} >;
using mat3_t = mat::vec_t<3,3 >;
using lamat3_t = mat::vec_t,3,3, align::linear>;
using amat3_t = mat::vec_t,3,3, align::matrix>;
using mat4_t = mat::vec_t,4,4 >;
using lamat3_t = mat::vec_t,4,4, align::linear>;
using amat4_t = mat::vec_t,4,4, align::matrix>;
using mat34_t = mat::vec_t<3,4 >;
using lamat34_t = mat::vec_t,3,4, align::linear>;
using amat34_t = mat::vec_t,3,4, align::matrix>;
using mat43_t = mat::vec_t<4,3 >;
using lamat43_t = mat::vec_t,4,3, align::linear>;
using amat43_t = mat::vec_t,4,3, align::matrix>;
using versor = ver::vec_t;
using quat_t = qut::vec_t;
using oct_t = oct::vec_t;
using mot_t = mot::vec_t;|vector | typ|alg|vec|alg|mode |cnt
|+1.00e+00 +0.00e+00 +0.00e+00 +0.00e+00| 4| 4| 16| 16|adaptive/linear|4
|+0.00e+00 +1.00e+00 +0.00e+00 +0.00e+00| 4| 4| 16| 16|adaptive/linear|4
|cross3 | typ|alg|vec|alg|mode |cnt
|+0.00e+00 +0.00e+00 +1.00e+00 +0.00e+00| 4| 4| 16| 16|adaptive/linear|4
|cross4 | typ|alg|vec|alg|mode |cnt
|-0.00e+00 +0.00e+00 -0.00e+00 +1.00e+00| 4| 4| 16| 16|adaptive/linear|4
|cross2 MLR_CCW/MLR_CW | typ|alg|vec|alg|mode |cnt
|-0.00e+00 +1.00e+00 +0.00e+00 -1.00e+00| 4| 4| 16| 16|adaptive/linear|4
|dot4 | typ|alg|vec|alg|mode |cnt
|+0.00e+00 +0.00e+00 +0.00e+00 +0.00e+00| 4| 4| 16| 16|adaptive/linear|4
|sum | typ|alg|vec|alg|mode |cnt
|+1.00e+00 +1.00e+00 +1.00e+00 +1.00e+00| 4| 4| 16| 16|adaptive/linear|4
|vector | typ|alg|vec|alg|mode |cnt
|+1.00e+00 +0.00e+00 +0.00e+00| 4| 4| 12| 4|adaptive/scalar|3
|+0.00e+00 +1.00e+00 +0.00e+00| 4| 4| 12| 4| scalar|3
|+0.00e+00 +0.00e+00 +1.00e+00| 4| 4| 16| 16| linear|3
|un/aligned add | typ|alg|vec|alg|mode |cnt
|+0.00e+00 +1.00e+00 +1.00e+00| 4| 4| 12| 4|adaptive/scalar|3
|+1.00e+00 +0.00e+00 +1.00e+00| 4| 4| 12| 4| scalar|3
|+1.00e+00 +1.00e+00 +0.00e+00| 4| 4| 16| 16| linear|3
|array of vector | typ|alg|vec|alg|mode |cnt
|container container container| 12| 4| 36| 4|adaptive/scalar|3
|+0.00e+00 +1.00e+00 +2.00e+00| 4| 4| 12| 4|adaptive/scalar|3
|+3.00e+00 +4.00e+00 +5.00e+00| 4| 4| 12| 4|adaptive/scalar|3
|+6.00e+00 +7.00e+00 +8.00e+00| 4| 4| 12| 4|adaptive/scalar|3
|bitfield->vector colors | typ|alg|vec|alg|mode |cnt
|+82 +130 +165 +0 | 1| 1| 3| 1|adaptive/scalar|3
|+165 +130 +82 +0 | 1| 1| 3| 1|adaptive/scalar|3
|+255 +85 +136 +204 | 1| 1| 4| 4|adaptive/linear|4
|+85 +136 +204 +255 | 1| 1| 4| 4|adaptive/linear|4
|+1.00e+00 +6.45e-01 +4.84e-01 +3.23e-01| 4| 4| 16| 16|adaptive/linear|4
|+3.23e-01 +4.84e-01 +6.45e-01 +1.00e+00| 4| 4| 16| 16|adaptive/linear|4