#5759: bug in divides
------------------------------+---------------------------------------------
 Reporter:  was               |       Owner:  somebody  
     Type:  defect            |      Status:  new       
 Priority:  major             |   Milestone:  sage-3.4.2
Component:  basic arithmetic  |    Keywords:            
------------------------------+---------------------------------------------
Changes (by kkilger):

  * priority:  minor => major


Old description:

> {{{
> sage: Zmod(2)(0).divides(Zmod(2)(1))
> ---------------------------------------------------------------------------
> ZeroDivisionError                         Traceback (most recent call
> last)
>
> /Users/wstein/.sage/temp/teragon.local/50691/_Users_wstein__sage_init_sage_0.py
> in <module>()
>
> /Users/wstein/build/sage-3.4.1.rc2/local/lib/python2.5/site-
> packages/sage/structure/element.so in
> sage.structure.element.CommutativeRingElement.divides
> (sage/structure/element.c:12423)()
>
> /Users/wstein/build/sage-3.4.1.rc2/local/lib/python2.5/site-
> packages/sage/rings/integer_mod.so in
> sage.rings.integer_mod.IntegerMod_int.__mod__
> (sage/rings/integer_mod.c:17834)()
>    1867     def __mod__(IntegerMod_int self, right):
>    1868         right = int(right)
> -> 1869         if self.__modulus.int32 % right != 0:
>    1870             raise ZeroDivisionError, "reduction modulo right not
> defined."
>    1871         return integer_mod_ring.IntegerModRing(right)(self)
>
> ZeroDivisionError: integer division or modulo by zero
>
> Found by  kilian__ on irc.
> }}}

New description:

 The function "divides" does not work for generic commutative rings.

 1. it is not checked that the elements are in the same space, i.e.

 Zmod(5)(1).divides(Zmod(2)(1)) is "True"

 2. No division by zero checking is done! This gives for example an error
 if you type

 Zmod(2).zero_ideal() == Zmod(2).zero_ideal() Zmod(2).zero_ideal() ==
 Zmod(2).unit_ideal()

 This patch should fix this.

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5759#comment:1>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
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-trac?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to