Git Product home page Git Product logo

xenonis's Introduction

xenonis - a C++17 bigint implementation

xenonis is a portable header-only C++17 library which implements a basic bigint class which supports addition, subtraction and multiplication. bigint can be constructed using integers and hex-strings.

The library implements the naive addition, subtraction and multiplication using clean C++17 and additionally using x86_64 assembly. The Karatsuba algorithm is implemented using only C++17. All 64-bit platforms supported by Clang or GCC can be used.

NOTE: the x86_64 assembly will be enabled automatically at compile-time (when on x86_64 using GCC or Clang). The code assumes that the adox, adcx and mulx instructions are supported by the CPU. Please ensure the availability or disable the use of assembly by passing -DXENONIS_USE_INLINE_ASM=OFF to cmake.

Example:

#include <bigint/bigint.hpp>
#include <iostream>

int main()
{
    xenonis::bigint a("ffffffffffffffffff");
    xenonis::bigint b("-ffffffffffffffffff"); // the hex-string may contain a -

    // print the result: 
    std::cout << a * b << '\n';
    
    // print length of the hex-string:
    std::cout << (a - b + a).to_string().size() << '\n';
    return 0;
}

Installation

Requirements - all platforms

Installation

git clone https://github.com/fabhaas/xenonis.git #clone repo
cd xenonis
mkdir build && cd build #create build directory
cmake .. -G <generator>
make # make documentation
make install #when using make

Building the tests and benchmarks - all platforms

A basic script to configure and build the library looks like this:

git clone https://github.com/fabhaas/xenonis.git #clone repo
cd xenonis
mkdir build && cd build #create build directory
cmake .. -G <generator> -DCMAKE_BUILD_TYPE=Release -DXENONIS_BUILD_TESTS=ON \
    -DXENONIS_BUILD_BENCHMARKS=ON #generate build files
ninja #when using ninja as generator; build

Running the tests

./bin/bigint_test # has to be executed in the build directory

Running the benchmarks

./bin/bigint_bench # has to be executed in the build directory

Building the tests and benchmarks on Linux - detailed version

Ubuntu

Install the required packages using this command:

sudo apt-get install cmake build-essential python-pip
sudo pip install conan #install conan

Then to configure and build the library run this:

git clone https://github.com/fabhaas/xenonis.git #clone repo
cd xenonis
mkdir build && cd build #create build directory
cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DXENONIS_BUILD_TESTS=ON \
    -DXENONIS_BUILD_BENCHMARKS=ON #generate build files in release mode
make # make documentation
make install # install

Fedora

Install the required packages using this command:

sudo dnf install cmake gcc-c++ make python-pip
sudo pip install conan #install conan

Then to configure and build the library run this:

git clone https://github.com/fabhaas/xenonis.git #clone repo
cd xenonis
mkdir build && cd build #create build directory
cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DXENONIS_BUILD_TESTS=ON \
    -DXENONIS_BUILD_BENCHMARKS=ON #generate build files in release mode
make # make documentation
make install # install

TODO

  • check for support for adcx, adox and mulx instruction

License

The library is licensed under the Mozilla Public License 2.0 (MPL-2.0). See LICENSE for more information.

xenonis's People

Contributors

fabhaas avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.