#4850: bug in power_mod
------------------------------+---------------------------------------------
 Reporter:  was               |       Owner:  somebody  
     Type:  defect            |      Status:  new       
 Priority:  major             |   Milestone:  sage-3.2.3
Component:  basic arithmetic  |    Keywords:            
------------------------------+---------------------------------------------
 {{{
 ----------------------------------------------------------------------
 | SAGE Version 3.1.4, Release Date: 2008-10-16                       |
 | Type notebook() for the GUI, and license() for information.        |
 ----------------------------------------------------------------------

 sage: power_mod(11,1,7)
 11
 sage: mod(11^1,7)
 4
 sage: # Hmmm...???
 sage:

 ...al
 }}}

 Note above that power_mod(11,1,7) should return 4.  The fix is to look at
 the *pure python* code that defines power_mod in rings/arith.py and:

   1. change it to use some much more intelligent compiled code, i.e.,
 either the powermod or powermod_ui methods when the first input coerces to
 ZZ, and

   2. when a doesn't coerce to ZZ, just revert to the existing Python code,
 but make sure to throw in an {{{%m}}} somewhere before returning the
 answer.

   3. Add a doctest like this that illustrates non-integer input for the
 first argument to power_mod:
 {{{
 sage: power_mod(3*x, 10, 7)
 4*x^10
 }}}

   4. There is an inconsistency in that the Integer method for power_mod is
 called "powermod" instead of "power_mod".  I think the Integer method
 should be changed, for consistency with the naming conventions used
 throughout sage (namely, be generous with underscores).

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/4850>
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