-
Notifications
You must be signed in to change notification settings - Fork 113
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
Modular arithmetics adaptor #144
Comments
I'm not sure I follow what you mean, anything like: https://github.com/boostorg/multiprecision/blob/develop/performance/arithmetic_backend.hpp ? |
Not really. It is actually about being able to do something like this:
or...
And this is achieved with implementation of something similar to |
Ah, sorry, stupid me! Yes, that's certainly something that was on the original TODO list but has been pushed back and back, but now that we've sorted out complex numbers, I guess this is the next number type to tackle. It's probably not easy though - both the the algorithmic sense, and in getting the supporting architecture right. There's also an initialization problem - all the main algorithms for modular reduction require some precomputed data based on the modulus (which is what makes them fast), I guess ideally the modulus would be a template parameter and constexpr arithmetic would be used for that, but that's not going to be possible for mpz_int for example (even in C++20?), so you might be looking at defining a separate type for the modulus, and passing that type to the constructor:
and so on. I'm not especially keen on the syntax, but can't think of anything better off hand. Which modular reduction algorithms were you thinking of? |
You are perfectly right with such a consideration, this is all was though about and partially done in First of all several reduction techniques are being presented. Barrett reduction along with Montgomery reduction and newly introduced scheme from https://eprint.iacr.org/2014/040.pdf. As for module type intended for some precomputed params storage, it is also was done pretty similar to your suggestion. The only difference - no Definitely no Such a separation of a monster branch to feature branches (I mentioned it above) actually depends on #146, #143 and #142 because this is not a hotfix of simple patch, this requires complex changes which could be only done in consensus with the upstream maintainer (I don't want to merge something in my own |
I believe it would be great to link this issue to PR #161, so it will close just as that PR will be merged. |
For several purposes it would be great for the Boost.Multiprecision to have a modular arithmetics adaptor.
Does it have any chance to be merged?
The text was updated successfully, but these errors were encountered: