#7017: prime_range problem
-----------------------------+----------------------------------------------
Reporter: kevin.stueve | Owner: kevin.stueve
Type: defect | Status: needs_review
Priority: critical | Milestone:
Component: number theory | Keywords: prime_range, primes, prime number
theory, prime
Work_issues: | Author: kevin.stueve
Upstream: N/A | Reviewer: was
Merged: |
-----------------------------+----------------------------------------------
Comment(by kevin.stueve):
On my atom netbook with 1GB RAM I can't even use prime_range near 4*10**8
(and my virtual memory was thrashing for 3*10**8). I don't think a hard-
coded limit is appropriate if what values are possible depends on how much
RAM is available (should the limit be configurable?).
Sebastian Pancratz suggested having the algorithm default be None, which
would cause the algorithm to be automatically chosen.
Yes, it would be better if it automatically selected the appropriate
algorithm for the input.
At a minimum, when prime_range with pari_primes fails, a message should be
printed saying that the other algorithm is available. Unfortunately
assuming the user will read the doc string when a function fails is not
realistic.
The patch I made also includes fixing a typo in a doc string in line 8605
(primes_up_to_n) of gen.pyx in the sage pari lib.
Currently prime_range in fast_arith.pyx calls primes_up_to_n in gen.pyx,
which calls pari(n).primepi(). I think this should be replaced with
Sage's prime_pi, which is faster and works for larger input.
Another bug, regarding Sage trac. I put the traceback in a special box.
Yet this text above does not wrap. This text above should still be word
wrapped.
{{{
sage: prime_range(10**10,10**10+100)
---------------------------------------------------------------------------
OverflowError Traceback (most recent call
last)
/home/kstueve/Desktop/sage-4.3-ubuntu9.10-AtomN270-i686-Linux/devel/sage-
ticket_7017/<ipython console> in <module>()
/home/kstueve/Desktop/sage-4.3-ubuntu9.10-AtomN270-i686-Linux/local/lib/python2.6
/site-packages/sage/rings/fast_arith.so in
sage.rings.fast_arith.prime_range (sage/rings/fast_arith.c:3968)()
/home/kstueve/Desktop/sage-4.3-ubuntu9.10-AtomN270-i686-Linux/local/lib/python2.6
/site-packages/sage/rings/fast_arith.so in
sage.rings.fast_arith.prime_range (sage/rings/fast_arith.c:3640)()
/home/kstueve/Desktop/sage-4.3-ubuntu9.10-AtomN270-i686-Linux/local/lib/python2.6
/site-packages/sage/libs/pari/gen.so in
sage.libs.pari.gen.PariInstance.primes_up_to_n
(sage/libs/pari/gen.c:40686)()
OverflowError: long int too large to convert to int
sage: prime_range(4*10**8,4*10**8+100)
---------------------------------------------------------------------------
PariError Traceback (most recent call
last)
/home/kstueve/Desktop/sage-4.3-ubuntu9.10-AtomN270-i686-Linux/devel/sage-
ticket_7017/<ipython console> in <module>()
/home/kstueve/Desktop/sage-4.3-ubuntu9.10-AtomN270-i686-Linux/local/lib/python2.6
/site-packages/sage/rings/fast_arith.so in
sage.rings.fast_arith.prime_range (sage/rings/fast_arith.c:3968)()
/home/kstueve/Desktop/sage-4.3-ubuntu9.10-AtomN270-i686-Linux/local/lib/python2.6
/site-packages/sage/rings/fast_arith.so in
sage.rings.fast_arith.prime_range (sage/rings/fast_arith.c:3640)()
/home/kstueve/Desktop/sage-4.3-ubuntu9.10-AtomN270-i686-Linux/local/lib/python2.6
/site-packages/sage/libs/pari/gen.so in
sage.libs.pari.gen.PariInstance.primes_up_to_n
(sage/libs/pari/gen.c:40789)()
/home/kstueve/Desktop/sage-4.3-ubuntu9.10-AtomN270-i686-Linux/local/lib/python2.6
/site-packages/sage/libs/pari/gen.so in sage.libs.pari.gen._pari_trap
(sage/libs/pari/gen.c:44110)()
PariError: length (lg) overflow (26)
sage: prime_range(3*10**8,3*10**8+100)
[300000007, 300000031, 300000047, 300000089]
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7017#comment:7>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
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.