Hello,
While writing up doctests for rings/quotient_ring_element.py, I came
across the following oddity: in the ring Z/10Z, some elements have
multiplicative inverses. In particular, 3^{-1} = 7 and 4*7 = 8 in Z/
10Z. (See below.) However, it seems that it depends on how I define R
= Z/10Z in Sage in order for it to correctly compute the inverse:
**************************************************
sage: R = QuotientRing(ZZ,10*ZZ)
sage: S = ZZ.quotient(10*ZZ)
sage: T = ZZ.quotient(ZZ.ideal(10))
sage: S(4)/S(3)
8
sage: T(4)/T(3)
8
sage: R(4)/R(3)
---------------------------------------------------------------------------
<type 'exceptions.NotImplementedError'> Traceback (most recent call
last)
/home/cswiercz/<ipython console> in <module>()
/home/cswiercz/element.pyx in
sage.structure.element.RingElement.__div__()
/home/cswiercz/coerce.pxi in sage.structure.element._div_c()
/home/cswiercz/sage/local/lib/python2.5/site-packages/sage/rings/
quotient_ring_element.py in _div_(self, right)
110
111 def _div_(self, right):
--> 112 if not right.is_unit():
113 raise ZeroDivisionError
114 raise NotImplementedError
/home/cswiercz/sage/local/lib/python2.5/site-packages/sage/rings/
quotient_ring_element.py in is_unit(self)
88 if self.__rep.is_unit():
89 return True
---> 90 raise NotImplementedError
91
92 def _repr_(self):
<type 'exceptions.NotImplementedError'>:
sage: ~R(3)
---------------------------------------------------------------------------
<type 'exceptions.TypeError'> Traceback (most recent call
last)
/home/cswiercz/<ipython console> in <module>()
/home/cswiercz/sage/local/lib/python2.5/site-packages/sage/rings/
quotient_ring_element.py in __invert__(self)
142
143 def __invert__(self):
--> 144 inv =
self.__rep.inverse_mod(self.parent().defining_ideal())
145 return QuotientRingElement(self.parent(), inv)
146
/home/cswiercz/integer.pyx in sage.rings.integer.Integer.inverse_mod()
/home/cswiercz/integer.pyx in sage.rings.integer.Integer.__init__()
<type 'exceptions.TypeError'>: unable to coerce element to an integer
**************************************************
I was working on the _div_ function for the class QuotientRing_element
at the time when I ran into this issue. It seems to me that this
implies QuotientRing(<ring>,<ideal>) and <ring>.quotient(<ideal>) have
slightly different class structures. Any comments? I just thought I'd
bring it attention. Not sure if I know enough about how the classes
are organized to be able to fix it myself without some serious help.
--
Chris Swierczewski
email:
cswi...@gmail.com
mobile: (broken)