https://github.com/rusoleal/vector_math
https://github.com/rusoleal/vector_math
cpp17 linear-algebra math matrix-computations multiplatform simd
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/rusoleal/vector_math
- Owner: rusoleal
- License: mit
- Created: 2025-06-27T19:19:51.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2026-03-18T19:34:02.000Z (4 months ago)
- Last Synced: 2026-03-19T07:50:45.541Z (4 months ago)
- Topics: cpp17, linear-algebra, math, matrix-computations, multiplatform, simd
- Language: C++
- Homepage:
- Size: 92.8 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vector_math
A C++17 vector and matrix mathematics library with SIMD acceleration for x86/x64 (SSE/AVX) and ARM (NEON).
## Features
- Generic vector and matrix templates (`Vec`, `Mat`)
- Typed specializations: `Vector2`, `Vector3`, `Vector4`, `Matrix2`, `Matrix3`, `Matrix4`
- SIMD-optimized `Matrix4f` (SSE) and `Matrix4d` (AVX) for performance-critical paths
- `Quaternion` with Hamilton product, slerp, axis-angle, and vector rotation
- Rich vector API: dot, cross, distance, angle, reflect, lerp, clamp, floor/ceil/round, component-wise ops
- Rich matrix API: determinant, inverse, TRS compose/decompose helpers, row/column access
- Full Doxygen documentation on all public APIs
- Namespace: `systems::leal::vector_math`
## Requirements
- CMake 3.22.1+
- C++20 compiler (GCC, Clang, MSVC)
## Building
```bash
cmake -B build -S .
make -C build
```
### Tests
```bash
./launch_test.sh
# or
cmake -B build/test -S . -DVECTOR_MATH_BUILD_TEST=ON
make -C build/test
build/test/vector_math_test
```
### Benchmarks
```bash
./launch_benchmark.sh
# or
cmake -B build/benchmark -S . -DVECTOR_MATH_BUILD_BENCHMARK=ON -DCMAKE_BUILD_TYPE=Release
make -C build/benchmark
build/benchmark/vector_math_benchmark
```
## SIMD Support
Architecture is detected automatically at compile time:
| Architecture | Intrinsics | Types accelerated |
|---|---|---|
| x86/x64 | SSE / AVX (`-mavx`) | `Matrix4f` (SSE), `Matrix4d` (AVX) |
| AArch64 | NEON | `Matrix4f` (NEON), `Matrix4d` (NEON) |
| ARM 32-bit | — | `Matrix4f` (scalar fallback), `Matrix4d` (scalar fallback) |
`Vector4f` and `Matrix4f` use `alignas(16)` to satisfy SIMD alignment requirements.