Closed basiliscos closed 6 years ago
If we make the invert function a free function we can apply more optimizations and still use it with UFCS as
auto z = x.invert(y);
Nullable
is more robust, assert
is simpler for the user. What do you say? I haven't used Nullable
yet in gmp-d. I'm not sure.
I think that assert
is more appropriate, as the inverse number cannot be found only if LCM(base, N) != 1
, i.e. violation of contract / assumptions.
Let me try to make a PR (I'm D-newbie, ha-ha).
Hi,
There is need of
mpz_invert
[1] function export in the module.However, I'm not sure what
D
interface should it have, if a modular multiplicative inverse might not exist.Nullable
?[1] https://gmplib.org/manual/Number-Theoretic-Functions.html#Number-Theoretic-Functions