Ongoing C++ library which covers a wide range of math operations and keeps growing to offer more tools for all sorts of calculations.
You can find the full in-depth documentation here:
Here's a short demo to use the library:
// <file_name>
#include "maTH.h"
#include <iostream>
using namespace std;
int main() {
int a = 10, b = 5;
float x = 5.1, y = 2;
cout << factorial(b) << endl; // 120
cout << PI << endl; // you can directly use constants
cout << "Addition: " << add<int>(a, x) << endl; // 15
cout << "Addition: " << add<float>(a, x) << endl; // 15.1
return 0;
}to run the code, run the following command with the library:
g++ <file_name> -L. -lmaTH -o main_executableand run the executable using ./main_executable or main_executable.exe
Don't have g++ compiler installed? Check the installation guide here
Incase you're changing the code and the included library doesn't work anymore, compile the source code to an object file with:
g++ -c maTH.cpp -o maTH.oand create the library with:
ar rcs libmaTH.a maTH.omkdir build
cd build
cmake ..
make
mainIncase the Makefile doesn't appear, use:
mkdir build
cd build
cmake -G "Unix Makefiles" ..
make
mainContributions for the library are very much welcome! If you have ideas for new features, optimizations, or bug fixes, feel free to open an issue or submit a pull request.
TODO:
- gitbook docs, more detail for constants
- more math!, maybe DS&algos in future