openGPMP is an open-source, multi-threaded, mathematics package written in C++, C, Fortran and Assembly with no runtime dependencies. The primary focus in Number Theory and Cryptographic algorithms, Linear Algebra, Calculus, Statistics, and Machine Learning concepts, and more. openGPMP aims to serve as a warehouse and one-stop shop for mathematical operations. Additional acceleration methods are featured for optional use and installation via OpenCL and CUDA. By default, SIMD intrinsics will be used for the supported platforms.
Look in the samples folder for examples on how to use some of openGPMP's functionalities and the in-depth documentation.
openGPMP C++ & Python is tested on the following:
Note Testing on Apple specific hardware (M1, M2) is in progress.
- Linux/OSX
- CMake v3.18+ (build from source for latest version)
- C++20
- gcc, g++, gfortran v12+ (clang, clang++, and flang are being tested)
Clone the repository or download the codebase from a release:
# clone repo
$ git clone git@github.com:akielaries/openGPMP.git
$ cd openGPMP
Create a build directory and configure with CMake:
$ mkdir build && cd build
$ cmake -S ../
- Additional CMake options include:
-DBUILD_TESTS=ON
-DCMAKE_C_COMPILER=/path/to/C/compiler
-DCMAKE_CXX_COMPILER=/path/to/CPP/compiler
-DCMAKE_FC_COMPILER=/path/to/Fortran/compiler
Note ATM OSX requires GCC for compilation
Install the compiled static library and headers:
$ make
$ sudo make install
Note Keep the build directory for easy uninstallation.
To install the Python interface, use the pip package manager and run the following, pip install pygpmp
. Additional hardware support is available with SWIG as a dependency for the pip
installation.
Building the Python pip wheel from source is easy as well. Run the following:
# install dependencies
$ pip install -r requirements.txt
# create CMake files in py_build dir
$ cmake -B py_build -DBUILD_PYGPMP=ON
# install
$ pip install .
Note In progress The Julia interface is built with the help of wrapit.
To test the installation build some of the example drivers in the projects samples directory.
# compile yourself
$ cd samples/cpp
$ g++ mtx.cpp -lopenGPMP -o mtx
$ g++ primes.cpp -lopenGPMP -o primes
To uninstall files related to openGPMP, simply run the following:
# enter the build dir from installation
$ cd build
$ sudo make uninstall
tinygpmp
targets low-voltage, resource-constrained devices and is currently aiming to support
AVR series MCUs, STM32 chips, and other embedded devices.
During early stages, modules will be developed in breadth while focusing on depth
in later stages of the PRE-V1.0.0
phase. The modules below are all in progress.
- Core (utilities & common interfaces)
- Arithmetic
- Calculus
- Discrete Mathematics
- Linear Algebra
- Machine/Deep Learning
- Number Theory
- Complex
- Statistics
- Optimization
For more details view the project documentation.
View the simple examples on how to use some of the modules in different languages here.
# clone the repo and enter
$ git clone git@github.com:akielaries/openGPMP.git
$ cd openGPMP/scripts
# to run all examples
$ ./all.sh
# to remove the generated binaries
$ cd ../ && make clean-mods
# run unit tests and other checking methods
$ make run-tests
# clean up generated test files
$ make clean-tests
Example C++ driver file for running Caesar Cipher & Mono-Alphabetic Substitution Keyword cipher:
#include <iostream>
#include <string>
// include the number theory module header
#include <openGPMP/nt.hpp>
int main() {
// declare CIPHER class obj
gpmp::Cipher cc;
/* CAESAR CIPHER */
std::string text0 = "Plaintext";
int shift_key_0 = 5;
std::string hashtext_0 = cc.caesar(text0, shift_key_0);
std::cout << "Hashtext0 = " << hashtext_0 << std::endl;
/* TESTING MONOALPHABETIC SUBSTITUION KEYWORD CIPHER */
std::string shift_key_2 = "Computer";
std::string text2 = "Password";
// encode the plaintext
std::string encoded_text = cc.keyword_encode(shift_key_2);
// call the cipher function
std::string hashtext_2 = cc.keyword(text2 , encoded_text);
std::cout << "Hashtext2 = " << hashtext_2 << std::endl;
return 0;
}
A Python example showing the same functionalities.
>>> from pygpmp import nt
>>> c = nt.Cipher()
>>> text0 = c.caesar('Plaintext', 5)
>>> print(ciphertext_0)
Uqfnsyjcy
>>>
>>> text1 = c.caesar('ATTACKATONCE', 4)
>>> print(text1)
EXXEGOEXSRGI
>>>
>>> text = "Password"
>>> shift = "Computer"
>>> encoded_text = c.keyword_encode(shift);
>>> hashtext = c.keyword(text, encoded_text);
>>> print(hashtext)
JCNNWILP