On Mar 2, 1:40 pm, achrzesz <[email protected]> wrote: > | Sage Version 4.6.2, Release Date: 2011-02-25 | > | Type notebook() for the GUI, and license() for information. | > ---------------------------------------------------------------------- > sage: inverse_mod(2,990) > --------------------------------------------------------------------------- > ZeroDivisionError Traceback (most recent call > last) > > /home/andy/<ipython console> in <module>() > > /home/andy/Pobrane/sage-4.6.2/local/lib/python2.6/site-packages/sage/ > rings/arith.pyc in inverse_mod(a, m) > 1726 """ > 1727 try: > -> 1728 return a.inverse_mod(m) > 1729 except AttributeError: > 1730 return integer.Integer(a).inverse_mod(m) > > /home/andy/Pobrane/sage-4.6.2/local/lib/python2.6/site-packages/sage/ > rings/integer.so in sage.rings.integer.Integer.inverse_mod (sage/rings/ > integer.c:30572)() > > ZeroDivisionError: Inverse does not exist. > > Does it mean that a different code is used in this case?
I think it would use __pow__(), and that seems to call mpz_powm, which is presumably in GMP/MPIR and I don't know much about that. The point is there is no catch for this. The fact that sage: ~a --------------------------------------------------------------------------- ZeroDivisionError Traceback (most recent call last) means that we are not using __invert__ and hence not mod_inverse_int variants in integer_mod.pyx. Robert B. might have some comments as the author of at least a good chunk of this code. I wouldn't want to make things inefficient by just naively checking for exponent -1 when it comes to Cythonized code. - kcrisman - kcrisman -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
