mpz_invert behavior -addendum
Benjamin Eltzner
b.eltzner at gmx.de
Sun Apr 13 00:08:18 UTC 2014
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
>> * The return value of mpz_invert is wrongly different from 0,
>> when the inverse cannot be calculated (cf. documentation, section
>> 5.9). In the example, the modulus by 1 yields 0, which cannot be
>> inverted. Thus, the result should be 0 but is 1.
>
> https://gmplib.org/gmp6.0.html
>
> First item of the changes in 6.0.0:
>
> * The function mpz_invert now considers any number invertible in
> Z/1Z.
>
> (because 0 * x == 1 modulo 1 whatever x)
To make my discomfort clearer: note that all of the following are "true"
a) for all n: 0 * n = 0 mod 1 (rop = indef, return = 0)
b) for all n: 0 * n = 1 mod 1 (rop = 0, return != 0)
c) for all n: 1 * n = 0 mod 1 (rop = indef, return = 0)
d) for all n: 1 * n = 1 mod 1 (rop = 1, return != 0)
I would consider a) conventional and a) and d) self-consistent in that
the single element of the zero ring is cast in a consistent role in
the whole expression. Your current implementation goes with b) which
chooses the single element of the zero ring once in its "zero-role"
and once in its "one-role".
I can imagine there has been a lot of discussion around this and you
are probably tired of the issue, so I would just like to ask you to
please update your documentation. (However, should you choose to
reconsider, I would be very glad if you reverted the behavior to case a).)
Best regards,
Benjamin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Icedove - http://www.enigmail.net/
iQIcBAEBAgAGBQJTSdVmAAoJEK27BRz67lmpgg8P/iUFfh2dBlG+NP+NuBqHnSxr
ofIPCWkbXwYFhP2jlu58ayb/RfUfvOy0cpdSLEmzgCqNqpeehedGZL6KyGf24VbC
BVUohm/xIDMBL6hQ9ZwWQ2zxXg1q/bxX7zb/7Q6j860RWi7wjiymJs13utGONK1y
6qINdXsoToF/dDZsQrD9LbRi2bWQQyp24sBoFODWdar04+JmnplinXDqaeTXIcL6
RLRJvCzxzuHW1T0fWPxeljQ0nUm0VsQ4yNW6+1M7DhbXxFJnco01TbS1+YSO/ctP
EBGsQIehgyYqCV6f+dHej1vrQhSXH/56kyv8PEjJy6drKl8RPR/SA1wqOaTiFcbP
dOgjeChEtHGLt25DviLZya0h34xuIPjKeMLlRTzfG/7IdJZK6n5klmfCz2eEYE0j
+YEBqgvbP6Ck3TVtIw1Yz2H2G4hnqDW+PaWri2t637MGdMVH++hbhCvp5ITXrkHl
oofWYua8Dg91+U32NLPrulMu8pgY9+414V28CvFdH1GiQ4jENBpAK29GO5HdzE8Z
L4Hf7MiIp7ltXc1R9B7x3zCGT4CEsfO4H5mAUXUnKCUAP+o+SKjp5rIX8ioexqBu
5Nf7M0IvDOuoJSRzZJk/ojtunEMgrA+WEajKT2COKR6Cu9Xnt/qwYwSd3brPBLZL
Kv0vwKXq7Zp2CGxIODKR
=IguP
-----END PGP SIGNATURE-----
More information about the gmp-bugs
mailing list