Opened 12 years ago
Closed 11 years ago
#4670 closed defect (fixed)
prime_pi for input ~ 10^10 causes PariError
Reported by: | roed | Owned by: | was |
---|---|---|---|
Priority: | minor | Milestone: | sage-4.3.1 |
Component: | number theory | Keywords: | |
Cc: | Merged in: | sage-4.3.1.rc1 | |
Authors: | Kevin Stueve | Reviewers: | Sebastian Pancratz |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
Calling the primepi function on a large pari integer (10^10)
causes an error. The issue is that in sage/libs/pari/gen.pyx the function init_primes casts the input to an unsigned long. If we don't want to allow initialization with input bigger than this, we should give a better error.
sage: prime_pi(10^10) --------------------------------------------------------------------------- PariError Traceback (most recent call last) /Users/Roed/Math/sage-3.2/<ipython console> in <module>() /Users/Roed/Math/sage-3.2/local/lib/python2.5/site-packages/sage/functions/transcendental.pyc in __call__(self, x) 363 from sage.rings.integer import Integer 364 pari.init_primes(pari(x)+Integer(1)) --> 365 return ZZ(pari(x).primepi()) 366 367 def plot(self, xmin=0, xmax=100, *args, **kwds): /Users/Roed/Math/sage-3.2/local/lib/python2.5/site-packages/sage/libs/pari/gen.so in sage.libs.pari.gen._pari_trap (sage/libs/pari/gen.c:37972)() PariError: impossible assignment I-->S (23)
Attachments (2)
Change History (8)
comment:1 Changed 12 years ago by
- Description modified (diff)
- Milestone set to sage-3.2.2
comment:2 Changed 12 years ago by
comment:3 Changed 12 years ago by
ohanar is fixing this!
comment:4 Changed 11 years ago by
- Report Upstream set to N/A
- Status changed from new to needs_review
Andrew Ohana's optimized Legendre prime_pi fixes this error. The attached patch adds prime_pi(1010) to the doctests of Andrew's code. It may still be desired to give a better error in the PARI implementation.
Kevin Stueve
comment:5 Changed 11 years ago by
- Status changed from needs_review to positive_review
The patch above includes left overs from another patch. I'll upload a new one now.
comment:6 Changed 11 years ago by
- Merged in set to sage-4.3.1.rc1
- Resolution set to fixed
- Reviewers set to Sebastian Pancratz
- Status changed from positive_review to closed
Note also #3658.