Skip to content

AlyShmahell/polymath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

intf

Build Status

Multiple Precision Integer Arithmetic C++ Library.

Roadmap

Feature Implementation Next Candidate
Constructors std::string, int, long int, long long int, intf
Containers std::vector<> std::vector<std::bitset<> >
+ standard
- standard
* Long multiplication Karatsuba multiplication, Toom–Cook, Schönhage–Strassen, Fürer's algorithm, Harvey and van der Hoeven
/ Approximate Division Newton–Raphson, Goldschmidt, Binomial Goldschmidt, Barrett reduction, Montgomery reduction
% Approximate Division Newton–Raphson, Goldschmidt, Binomial Goldschmidt, Barrett reduction, Montgomery reduction
pow standard Exponentiation by squaring
sqrt bisection Babylonian(Heron), Newton-Raphson, Goldschmidt, Bakhshali approximation, Fast inverse square root
modexp
Right-to-left binary
modinv
abs
>> repetitive approximate division
<< repetitive approximate division
&
^
xor
ostream>>
ostream<<
gcd
gcdeuc
lcm

Next Steps:

Step Progress
Code Refactoring Work In Progress
Templating Work In Progress
Next Feature Candidates Work In Progress
Implementing Missing Features Work In Progress

Requirements:

  • lib:
    • GCC compiler with C++11 support.
    • CMake 3.10.2
  • tests:
    • Python 3

Installation:

git clone https://github.com/AlyShmahell/intf
cd intf
python3 install.py

Example:

#include <intf/intf.hpp>

int main()
{
    intf a = 4;
    intf b = 3;
    intf c;
    std::cout<<(a/b)<<std::endl;
    std::cout<<(a%b)<<std::endl;
    std::cout<<(a*b)<<std::endl;
    std::cout<<(a-b)<<std::endl;
    std::cout<<(a+b)<<std::endl;
    std::cout<<pow(a,3)/pow(b,3)<<std::endl;
    std::cout<<pow(a,3)%pow(b,3)<<std::endl;
    std::cout<<pow(a,2)*pow(b,2)<<std::endl;
    std::cout<<pow(a,3)-pow(b,3)<<std::endl;
    std::cout<<pow(a,3)+pow(b,3)<<std::endl;
    std::cout<<(a--)<<std::endl;
    std::cout<<(--a)<<std::endl;
    std::cout<<(a++)<<std::endl;
    std::cout<<(++a)<<std::endl;
    std::cout<<(a<<3)<<std::endl;
    std::cout<<(a>>4)<<std::endl;
    std::cout<<(a*a)<<std::endl;
    std::cout<<(a-a)<<std::endl;
    std::cout<<(a+a)<<std::endl;
    c = sqrt(a);
    std::cout<<pow(c,2)<<std::endl;
    a = a*(a+2);
    a >>= 1;
    std::cout<<a<<std::endl;
    a >>= intf(2);
    std::cout<<a<<std::endl;
    a <<= 3;
    std::cout<<a<<std::endl;
    a <<= intf(4);
    std::cout<<a<<std::endl;
    a += 3;
    std::cout<<a<<std::endl;
    a += b;
    std::cout<<a<<std::endl;
    a -= 3;
    std::cout<<a<<std::endl;
    a -= b;
    std::cout<<a<<std::endl;
    a *= 3;
    std::cout<<a<<std::endl;
    a *= b;
    std::cout<<a<<std::endl;
    a /= 3+1;
    std::cout<<a<<std::endl;
    a /= b+1;
    std::cout<<a<<std::endl;
    a %= 3+1;
    std::cout<<a<<std::endl;
    a %= b+1;
    std::cout<<a<<std::endl;
    return 0;
}

About

A (high efficiency, high precision) infinite-integer arithmetics library.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published