Opened 10 years ago

Closed 10 years ago

#10873 closed defect (fixed)

Bug in integer_mod powering non-invertible base and negative exponents

Reported by: robertwb Owned by: AlexGhitza
Priority: major Milestone: sage-4.7.1
Component: basic arithmetic Keywords:
Cc: kcrisman Merged in: sage-4.7.1.alpha4
Authors: Robert Bradshaw Reviewers: Mariah Lenox
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by jdemeyer)

In sage-4.7::

sage: mod(2, 990)^-1
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)

/usr/local/src/sage-4.7/<ipython console> in <module>()

/usr/local/src/sage-4.7/local/lib/python2.6/site-packages/sage/rings/finite_rings/integer_mod.so in sage.rings.finite_rings.integer_mod.IntegerMod_int.__pow__ (sage/rings/finite_rings/integer_mod.c:20093)()

RuntimeError: Floating point exception

Attachments (2)

10873-mod-pow.patch (8.9 KB) - added by robertwb 10 years ago.
10873-mod-pow-rebased.patch (9.1 KB) - added by robertwb 10 years ago.
apply only this patch

Download all attachments as: .zip

Change History (13)

Changed 10 years ago by robertwb

comment:1 Changed 10 years ago by robertwb

  • Status changed from new to needs_review

comment:2 Changed 10 years ago by kcrisman

  • Cc kcrisman added

comment:3 Changed 10 years ago by mariah

  • Status changed from needs_review to needs_work

The patch fails to apply to sage-4.7.rc2:

sage: hg_sage.apply("/home/mariah/10873-mod-pow.patch")
cd "/home/mariah/sage/sage-4.7.rc2-x86_64-Linux-core2-fc-review-10873/devel/sage" && hg status
cd "/home/mariah/sage/sage-4.7.rc2-x86_64-Linux-core2-fc-review-10873/devel/sage" && hg status
cd "/home/mariah/sage/sage-4.7.rc2-x86_64-Linux-core2-fc-review-10873/devel/sage" && hg import   "/home/mariah/10873-mod-pow.patch"
applying /home/mariah/10873-mod-pow.patch
patching file sage/rings/finite_rings/integer_mod.pyx
Hunk #2 FAILED at 1637
Hunk #5 FAILED at 2131
Hunk #7 FAILED at 2933
3 out of 8 hunks FAILED -- saving rejects to file sage/rings/finite_rings/integer_mod.pyx.rej
abort: patch failed to apply
sage:

comment:4 Changed 10 years ago by robertwb

  • Status changed from needs_work to needs_review

FIxed _sig_on -> sig_on() conflict.

Changed 10 years ago by robertwb

apply only this patch

comment:5 Changed 10 years ago by mariah

  • Status changed from needs_review to needs_work

patch 10873-mod-pow-rebased.patch applied to sage-4.7.1.alpha1, then did 'make testlong'. Got the following error:

sage -t -long -force_lib "devel/sage/sage/rings/finite_rings/integer_mod.pyx"
ESC[?1034h**********************************************************************
File "/home/mariah/sage/sage-4.7.1.alpha1-x86_64-Linux-core2-fc-review-10873/devel/sage/sage/rings/finite_rings/integer_mod.pyx", iled example:
    sig_on_count()
Expected:
    0
Got:
    1
**********************************************************************
File "/home/mariah/sage/sage-4.7.1.alpha1-x86_64-Linux-core2-fc-review-10873/devel/sage/sage/rings/finite_rings/integer_mod.pyx", iled example:
    sig_on_count()
Expected:
    0
Got:
    1
**********************************************************************
File "/home/mariah/sage/sage-4.7.1.alpha1-x86_64-Linux-core2-fc-review-10873/devel/sage/sage/rings/finite_rings/integer_mod.pyx", iled example:
    sig_on_count()
Expected:
    0
Got:
    1
**********************************************************************

etc.

comment:6 follow-up: Changed 10 years ago by robertwb

How long ago was this? (I posted an updated version of the patch when I saw these errors on the patchbot, maybe you grabbed the old one?)

comment:7 in reply to: ↑ 6 Changed 10 years ago by mariah

Replying to robertwb:

How long ago was this? (I posted an updated version of the patch when I saw these errors on the patchbot, maybe you grabbed the old one?)

I now believe that what I am seeing is not due to your patch but to a relocation bug in sage-4.7.1-alpha1. See #11419. Apologies.

comment:8 Changed 10 years ago by robertwb

  • Status changed from needs_work to needs_review

No problem, I'm just glad you're taking the time to look at my tickets :).

comment:9 Changed 10 years ago by mariah

  • Authors set to Robert Bradshaw
  • Reviewers set to Mariah Lenox
  • Status changed from needs_review to positive_review

Applied patch, did 'sage -b', then 'make testlong'. All tests passed. Positive review!

comment:10 Changed 10 years ago by jdemeyer

  • Description modified (diff)

comment:11 Changed 10 years ago by jdemeyer

  • Merged in set to sage-4.7.1.alpha4
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.