mpz_invert behavior -addendum
Torbjorn Granlund
tg at gmplib.org
Sun Apr 13 10:32:48 UTC 2014
Benjamin Eltzner <b.eltzner at gmx.de> writes:
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 don't follow how to relate the current GMP behaviour to your table.
To me the example a and b are the same just like c and d are the same.
(The number after the = sign is not input to GMP, so how you can find
different behaviour for these cases is a mystery.)
I believe we always return 0 as the result of any operation in the zero
ring. If you disagree, please show a concrete counter-example. In C
code.
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).)
I believe the current behaviour is mathematically correct. The
behaviour of older GMP was not mathematically correct in the zero ring.
I agree that there is a slight documentation problem for mpz_invert wrt
the zero ring.
Torbjörn
Please encrypt, key id 0xC8601622
More information about the gmp-bugs
mailing list