A single-header, public domain, short vector math library for C++ inspired by shading languages.
linalg.h is a single-header linear algebra library for C++ that provides short vector and matrix math operations. It is designed as a lightweight alternative to larger libraries like GLM, focusing on simplicity and ease of use in domains such as computer graphics and physical simulation. The library offers a syntax inspired by shading languages, making it intuitive for developers familiar with GPU programming.
C++ developers working in computer graphics, computational geometry, game development, or physical simulation who need efficient vector and matrix operations without heavy dependencies.
Developers choose linalg.h for its minimal footprint, public domain license, and straightforward integration. It provides a complete set of linear algebra operations in a single header, avoiding the complexity and overhead of larger libraries while maintaining performance and standards compliance.
linalg.h is a single header, public domain, short vector math library for C++
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The entire library is contained in one header file under 1000 lines, making integration as simple as copying the file into your project without build system overhead.
Requires only a C++11 compiler and a small subset of the standard library, eliminating external dependencies and simplifying deployment.
Operations are parameterized over scalar types with consistent naming, allowing mixing of types like float and int in expressions based on C standard promotion rules.
Most operations are free of undefined behavior and can be evaluated in a constexpr context, enabling compile-time optimizations and metaprogramming use cases.
Primarily designed for vectors and matrices up to 4D, lacking support for larger matrices common in scientific computing or machine learning.
The documentation for version 2.2 is explicitly noted as 'still in progress', which can hinder learning, troubleshooting, and adoption of newer features.
Missing functionalities like eigenvalue decomposition, sparse matrix support, or numerical solvers that are available in heavier libraries such as Eigen or GLM.
Being lightweight, it lacks explicit SIMD vectorization or platform-specific optimizations, which may impact performance in compute-intensive applications compared to optimized alternatives.
linalg.h is an open-source alternative to the following products:
GLM (OpenGL Mathematics) is a header-only C++ mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specification, providing classes and functions for vector and matrix operations.
Boost.QVM is a C++ library for quaternion, vector, and matrix mathematics that provides generic, header-only implementations of linear algebra operations.