Skip to content

Commit f65167c

Browse files
committed
move from sage.arith.misc to sage.combinat.q_analogues
1 parent 4a4b9c9 commit f65167c

File tree

4 files changed

+39
-39
lines changed

4 files changed

+39
-39
lines changed

src/sage/arith/all.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
prime_factors,
8282
prime_range,
8383
valuation,
84-
number_of_irreducible_polynomials,
8584
)
8685

8786
lazy_import("sage.arith.misc", ("Sigma", "Moebius", "Euler_Phi"), deprecation=30322)

src/sage/arith/misc.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6383,40 +6383,3 @@ def dedekind_psi(N):
63836383
"""
63846384
N = Integer(N)
63856385
return Integer(N * prod(1 + 1 / p for p in N.prime_divisors()))
6386-
6387-
6388-
def number_of_irreducible_polynomials(q, n):
6389-
r"""
6390-
Return the number of irreducible polynomials of degree ``n``
6391-
over the finite field with ``q`` elements.
6392-
6393-
INPUT:
6394-
6395-
- ``q`` -- prime power
6396-
- ``n`` -- positive integer
6397-
6398-
OUTPUT: integer
6399-
6400-
EXAMPLES::
6401-
6402-
sage: number_of_irreducible_polynomials(2, 8)
6403-
30
6404-
sage: number_of_irreducible_polynomials(9, 9)
6405-
43046640
6406-
6407-
This function is *much* faster than enumerating the polynomials::
6408-
6409-
sage: num = number_of_irreducible_polynomials(101, 99)
6410-
sage: num.bit_length()
6411-
653
6412-
6413-
ALGORITHM:
6414-
6415-
Classical formula `\frac1n \sum_{d\mid n} \mu(n/d) q^d` using the
6416-
Möbius function `\mu`; see :func:`moebius`.
6417-
"""
6418-
q, n = ZZ(q), ZZ(n)
6419-
r = ZZ.zero()
6420-
for d in n.divisors():
6421-
r += moebius(n//d) * q**d
6422-
return r // n

src/sage/combinat/all.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@
247247
from .integer_vector_weighted import WeightedIntegerVectors
248248
from .integer_vectors_mod_permgroup import IntegerVectorsModPermutationGroup
249249

250-
lazy_import('sage.combinat.q_analogues', ['gaussian_binomial', 'q_binomial'])
250+
lazy_import('sage.combinat.q_analogues', ['gaussian_binomial', 'q_binomial', 'number_of_irreducible_polynomials'])
251251

252252
from .species.all import *
253253

src/sage/combinat/q_analogues.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,3 +974,41 @@ def q_stirling_number2(n, k, q=None):
974974
return parent(q)(0)
975975
return (q**(k-1)*q_stirling_number2(n - 1, k - 1, q=q) +
976976
q_int(k, q=q) * q_stirling_number2(n - 1, k, q=q))
977+
978+
979+
def number_of_irreducible_polynomials(q, n):
980+
r"""
981+
Return the number of irreducible polynomials of degree ``n``
982+
over the finite field with ``q`` elements.
983+
984+
INPUT:
985+
986+
- ``q`` -- prime power
987+
- ``n`` -- positive integer
988+
989+
OUTPUT: integer
990+
991+
EXAMPLES::
992+
993+
sage: number_of_irreducible_polynomials(2, 8)
994+
30
995+
sage: number_of_irreducible_polynomials(9, 9)
996+
43046640
997+
998+
This function is *much* faster than enumerating the polynomials::
999+
1000+
sage: num = number_of_irreducible_polynomials(101, 99)
1001+
sage: num.bit_length()
1002+
653
1003+
1004+
ALGORITHM:
1005+
1006+
Classical formula `\frac1n \sum_{d\mid n} \mu(n/d) q^d` using the
1007+
Möbius function `\mu`; see :func:`moebius`.
1008+
"""
1009+
from sage.arith.misc import moebius
1010+
q, n = ZZ(q), ZZ(n)
1011+
r = ZZ.zero()
1012+
for d in n.divisors():
1013+
r += moebius(n//d) * q**d
1014+
return r // n

0 commit comments

Comments
 (0)