Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiplication Algorithms #3

Open
Kronuz opened this issue Nov 11, 2017 · 6 comments
Open

Multiplication Algorithms #3

Kronuz opened this issue Nov 11, 2017 · 6 comments

Comments

@Kronuz
Copy link

Kronuz commented Nov 11, 2017

What multiplication algorithm are you using here for uint128_t and uint256_t? I don’t see this algorithm in your integer repository... why?

@armchaircaver
Copy link

Surely Jason's code implements this via the operator overload starting in line 208 of uint128_t.cpp :
uint128_t uint128_t::operator*(const uint128_t & rhs) const{
...

By the way, you may be interested in the modified version of this operator overload that I wrote to solve a contest center puzzle, described in http://arthurvause.blogspot.co.uk/2017/05/three-pandigitals.html

@calccrypto
Copy link
Owner

I do long multiplication in uint128_t and uint256_t because these two types have fixed numbers of internal digits, and thus multiplication can be done in constant time. I have implemented long multiplication in integer, but it is relatively slow, when compared to other algorithms, which is why I have a list of commented out multiplication methods that are implemented but not used.

@Kronuz
Copy link
Author

Kronuz commented Nov 12, 2017

For modulo and divisions, have you tried Barrett? There’s also other method which combines Newton Inversion with Barrett’s algorithm (Newton Division), there’s an interesting paper here comparing algorithms: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.111.9736&rep=rep1&type=pdf

@calccrypto
Copy link
Owner

Cool! Thanks! I'll get to it at some point.

@Kronuz
Copy link
Author

Kronuz commented Nov 23, 2017

I made a ton of additions/changes in https://github.com/Kronuz/uint_t lots of optimizations and quite a few algorithms

@calccrypto
Copy link
Owner

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants