Cramer is an open-source, numerical linear algebra library for C++. It supports a wide variety of computations with vectors and matrices. For a full list of features, see below.
It's named after the Genevan mathematician Gabriel Cramer, who is probably most well-known for Cramer's rule: a formula to solve a system of linear equations using determinants.
There are better linear algebra libraries out there, but I wanted to create one that was easier to use, understand, and maintain. Think of it as a smaller version of Eigen.
Vector operations:
- norm (length)
- inner (dot) and cross product
- projections, reflections, and rotations
Matrix operations:
- rank, trace, and determinant
- transpose, adjoint, and inverse (if it exists)
- LU, QR, and SVD decompositions
- eigenvalues and eigenvectors
- C++17 compiler (e.g., GCC 7.0+, Clang 5.0+)
- CMake 3.12+
- Google Test 1.10.0+ for unit testing
- Google Benchmark 1.6.1+ for benchmarking
Optional:
- clang-format 10.0+ for code formatting
- clang-tidy 10.0+ for static analysis
-
Clone the repository:
git clone https://github.com/cm-jones/cramer.git
-
Create a build directory and navigate to it:
cd cramer mkdir build cd build
-
Run CMake to configure the project:
cmake ..
-
Build the library:
make
-
(Optional) Install the library and headers:
sudo make install
Include the header in your source files:
#include <cramer>
Create vectors and matrices, and perform operations on them:
#include <vector> // Not to be confused with cramer::Vector!
using namespace cramer;
Matrix<double> A(2, 2);
A(0, 0) = 1.0;
A(0, 1) = 2.0;
A(1, 0) = 3.0;
A(1, 1) = 4.0;
Vector<double> b(2);
b(0) = 5.0;
b(1) = 6.0;
Vector<double> x = A.solve(b);
std::vector<double> lambdas = A.eigenvalues();
Cramer uses Google Test for unit testing. To run the unit tests, first build the project, and then execute the following command inside the build
directory:
ctest
Cramer uses Google Benchmark for benchmarking. To run the benchmarks, follow these steps:
-
Build the benchmarks (if not already built):
cmake --build build --target benchmark_all
-
Run the benchmarks:
cd build make benchmark_all ./benchmark_all
Documentation is generated automatically via Doxygen and document.yml when there's a push or a pull request on the main branch. It can be viewed here.
See CONTRIBUTING.md for details on how to contribute to Cramer.
Cramer is licensed under the GNU General Public License v3.0.