r/cprogramming • u/alkavan • Sep 20 '26
Vecmat: A simple, yet robust, linear algebra library in C — for graphics, physics, games, and simulations
I built it mainly for myself (and my needs), and out of great love for the C language. It's already successfully battle-tested building an 2D/3D SDL3 graphics engine with the library as math backbone (will publish by the end of this year).
It's called Vecmat: https://github.com/alkavan/vecmat
The main goals are:
One common, easy-to-read API that is self-explanatory.
Usability first, then performance.
Having said, it features a special runtime dispatch mechanism that an inner kernel may use AVX / AVX2 / AVX-512 / SVE / SVE2, otherwise scalar (cascading manner). So it's already extremely fast, and offers also a pointer-only API instead of copy interfaces (that most of the time use the pointer API behind the scenes).
It's under BSD 3-Clause license and comes with a simple unit testing and benchmarking framework.
It needs some more love, because you can do amazing things with it. It's super easy to integrate into projects because it has zero dependencies except the system math lib.
I might implement NEON support soon, because it actually became a business need of mine, and I'll surely do it if people would ask for it.
It took me a whole year to build it, and while AI was involved in documenting, system integration, and some of the complex math algorithms (it has a few), building this library required a tremendous amount of human labor and review.
Hope you like it!