mpz_invert (x, 1, 0)

Joerg Arndt arndt at jjj.de
Fri Mar 2 09:33:50 CET 2012


* bodrato at mail.dm.unipi.it <bodrato at mail.dm.unipi.it> [Mar 01. 2012 20:20]:
> Ciao,
> 
> Il Gio, 1 Marzo 2012 4:23 pm, Joerg Arndt ha scritto:
> > If mod zero is allowed at all it should
> > return the first argument unchanged:
> >   mod(x,0) = x  for all x
> >
> > So the behavior below is what I would expect.
> 
> Maybe you are right, but ...
> 
> I did not specify that for any non-unity value n, the current mpz_invert,
> returns "non invertible" for the modulus 0.
> 

In fact, I'd be surprised if mod zero would do anything else.
Performance reasons suggest that no extra branch in any mod-code
should be done, leaving it to the user to handle the corner case
"equivalence mod zero" being "simple equality".


> Moreover the old documentation promised to return an inverse r so that
> 0<=r<m, where m is the modulus. If m=0, no return value r is allowed by
> this restriction: mod zero should not be allowed at all.
> 
> I recently changed the documentation writing "0<r<m", but I now realize
> that I should change it again, because a negative modulus is allowed:
> "0<r<|m|"
> 
> Regards, m
> 
> -- 
> http://bodrato.it/papers/
> http://www.notav.eu/modules.php?name=ePetitions&op=more_info&ePetitionId=3
> 

cheers,   jj


More information about the gmp-devel mailing list