mpz_invert (x, 1, 0)

Joerg Arndt arndt at jjj.de
Fri Mar 2 13:34:03 CET 2012


* Torbjorn Granlund <tg at gmplib.org> [Mar 02. 2012 13:24]:
> If we consider the ring Z, and note that Z mod n is isomorphic to (some
> would say identical to) Z/nZ, letting n = 0 will quote with the zero
> ideal (0Z = {0}), leaving Z (or more accurately, leaving the set of
> congruence classes {{0}, {1}, {2}, ...} with just one element per class.
> 
> I agree with Jörg: Z is isomorphic to Z/0Z.
> 
> I am more concerned with not adding extra tests on existing critical
> paths than with defining corner cases that nobody will probably use.
> 
> Therefore, a series of disjoint unlikely conditions is not good.  If
> they can be combined to few disjoint unlikely conditions (possibly
> covering some unlikely case too much, to be rejected later) that I am
> much happier.  Unfortunetely, the change to invert adds such unlikely
> critical-path conditions.
> 
> -- 
> Torbjörn

Yes, for performance reasons mod zero should be left
undefined (and that fact documented), possibly ending
in a division by zero.

That mod zero "special" case can easily be described as follows:
two elements are equal (mod m) iff their difference is an
_integer_ multiple of m.
This way nothing special happens mod zero.
(The term "characteristic zero" for fields is natural as well;
the notion of the characteristic of "how often one needs to add
an element to get zero (in general)" is rather misleading in the
light of the above.)

Also the above notion gives us equivalence mod m for m a real
(or even complex) number.

cheers,  jj


More information about the gmp-devel mailing list