documentation issue
Paul Zimmermann
Paul.Zimmermann at loria.fr
Tue Feb 26 16:40:37 CET 2008
Hi,
the documentation of mpz_invert says:
-- Function: int mpz_invert (mpz_t ROP, mpz_t OP1, mpz_t OP2)
Compute the inverse of OP1 modulo OP2 and put the result in ROP.
If the inverse exists, the return value is non-zero and ROP will
satisfy 0 <= ROP < OP2. If an inverse doesn't exist the return
^^^^^^^^
value is zero and ROP is undefined.
Unless I'm mistaken, if the inverse exists, ROP cannot be zero for |OP2| >= 2.
Also, the behaviour should be specified for OP2 = 0 and |OP2| = 1.
If one assumes that the inverse exists if there exists an integer B
such that ROP*OP1 + B*OP2 = 1, then:
(a) for OP2=0, only OP1=1 and OP1=-1 admit an inverse, which seems what the
implementation does;
(b) for OP2=1, then any integer ROP is an inverse, since one can take
B = 1 - ROP*OP1. But the return value seems to be always 0 in that case.
Paul Zimmermann
More information about the gmp-bugs
mailing list