sagemath/sagemath-primecount.patch
Jerry James 05ae6fe453 Rebuild for ntl 11.4.0.
Add primecount support, including the -primecount patch.
Add still more gap packages, nearly finishing the set shipped by upstream.
2019-09-26 13:15:26 -06:00

110 lines
3.7 KiB
Diff

diff -up src/sage/interfaces/primecount.pyx.orig src/sage/interfaces/primecount.pyx
--- src/sage/interfaces/primecount.pyx.orig 2019-06-26 14:41:04.000000000 -0600
+++ src/sage/interfaces/primecount.pyx 2019-09-17 16:13:46.316032782 -0600
@@ -22,7 +22,7 @@ cdef inline int _do_sig(int64_t n):
"threshold for sig_on/sig_off"
return n >> 26
-cpdef int64_t prime_pi(int64_t n, method=None) except -1:
+cpdef int64_t prime_pi(int64_t n) except -1:
r"""
Return the number of prime numbers smaller or equal than ``n``.
@@ -30,76 +30,22 @@ cpdef int64_t prime_pi(int64_t n, method
- ``n`` - an integer
- - ``method`` - ``None`` or a string that determines the primecount
- function to be called
-
- - ``"deleglise_rivat"``
- - ``"legendre"``
- - ``"lehmer"``
- - ``"lmo"``
- - ``"meissel"``
- - ``"primesieve"``
-
EXAMPLES::
sage: from sage.interfaces.primecount import prime_pi # optional - primecount
sage: prime_pi(1000) == 168 # optional - primecount
True
- sage: prime_pi(1000, "deleglise_rivat") == 168 # optional - primecount
- True
- sage: prime_pi(1000, "legendre") == 168 # optional - primecount
- True
- sage: prime_pi(1000, "lehmer") == 168 # optional - primecount
- True
- sage: prime_pi(1000, "lmo") == 168 # optional - primecount
- True
- sage: prime_pi(1000, "meissel") == 168 # optional - primecount
- True
- sage: prime_pi(1000, "primesieve") == 168 # optional - primecount
- True
- sage: prime_pi(1000, "youpi") # optional - primecount
- Traceback (most recent call last):
- ...
- ValueError: unknown method 'youpi'
"""
cdef int64_t ans
- if method is None:
- if _do_sig(n): sig_on()
- ans = primecount.pi(n)
- if _do_sig(n): sig_off()
- elif method == "deleglise_rivat":
- if _do_sig(n): sig_on()
- ans = primecount.pi_deleglise_rivat(n)
- if _do_sig(n): sig_off()
- elif method == "legendre":
- if _do_sig(n): sig_on()
- ans = primecount.pi_legendre(n)
- if _do_sig(n): sig_off()
- elif method == "lehmer":
- if _do_sig(n): sig_on()
- ans = primecount.pi_lehmer(n)
- if _do_sig(n): sig_off()
- elif method == "lmo":
- if _do_sig(n): sig_on()
- ans = primecount.pi_lmo(n)
- if _do_sig(n): sig_off()
- elif method == "meissel":
- if _do_sig(n): sig_on()
- ans = primecount.pi_meissel(n)
- if _do_sig(n): sig_off()
- elif method == "primesieve":
- if _do_sig(n): sig_on()
- ans = primecount.pi_primesieve(n)
- if _do_sig(n): sig_off()
- else:
- raise ValueError("unknown method {!r}".format(method))
-
+ if _do_sig(n): sig_on()
+ ans = primecount.pi(n)
+ if _do_sig(n): sig_off()
return ans
cpdef prime_pi_128(n):
r"""
- Return the number of prime number smaller than ``n``.
+ Return the number of prime numbers smaller than ``n``.
EXAMPLES::
diff -up src/sage/libs/primecount.pxd.orig src/sage/libs/primecount.pxd
--- src/sage/libs/primecount.pxd.orig 2019-06-26 14:41:05.000000000 -0600
+++ src/sage/libs/primecount.pxd 2019-09-17 16:11:06.678851358 -0600
@@ -9,13 +9,6 @@ cdef extern from "primecount.hpp" namesp
cppstring pi(const cppstring& x)
- int64_t pi_deleglise_rivat(int64_t x)
- int64_t pi_legendre(int64_t x)
- int64_t pi_lehmer(int64_t x)
- int64_t pi_lmo(int64_t x)
- int64_t pi_meissel(int64_t x)
- int64_t pi_primesieve(int64_t x)
-
int64_t nth_prime(int64_t n)
int64_t phi(int64_t x, int64_t a)