galois.primitive_polys

galois.primitive_polys(characteristic, degree)

Returns all monic primitive polynomials \(f(x)\) over \(\mathrm{GF}(p)\) with degree \(m\).

In addition to other applications, \(f(x)\) produces the field extension \(\mathrm{GF}(p^m)\) of \(\mathrm{GF}(p)\). Since \(f(x)\) is primitive, \(x\) is a primitive element \(\alpha\) of \(\mathrm{GF}(p^m)\) such that \(\mathrm{GF}(p^m) = \{0, 1, \alpha, \alpha^2, \dots, \alpha^{p^m-2}\}\).

Parameters
  • characteristic (int) – The prime characteristic \(p\) of the field \(\mathrm{GF}(p)\) that the polynomial is over.

  • degree (int) – The degree \(m\) of the desired primitive polynomial.

Returns

All degree-\(m\) monic primitive polynomials over \(\mathrm{GF}(p)\).

Return type

list

Examples

In [1]: galois.primitive_polys(2, 5)
Out[1]: 
[Poly(x^5 + x^2 + 1, GF(2)),
 Poly(x^5 + x^3 + 1, GF(2)),
 Poly(x^5 + x^3 + x^2 + x + 1, GF(2)),
 Poly(x^5 + x^4 + x^2 + x + 1, GF(2)),
 Poly(x^5 + x^4 + x^3 + x + 1, GF(2)),
 Poly(x^5 + x^4 + x^3 + x^2 + 1, GF(2))]