galois.is_primitive_element¶
- galois.is_primitive_element(element: PolyLike, irreducible_poly: Poly) bool ¶
Determines if \(g\) is a primitive element of the Galois field \(\mathrm{GF}(q^m)\) with degree-\(m\) irreducible polynomial \(f(x)\) over \(\mathrm{GF}(q)\).
- Parameters
- Returns
True
if \(g\) is a primitive element of \(\mathrm{GF}(q^m)\).
Examples
Find all primitive elements for the degree \(4\) extension of \(\mathrm{GF}(3)\).
In [1]: f = galois.conway_poly(3, 4); f Out[1]: Poly(x^4 + 2x^3 + 2, GF(3)) In [2]: g = galois.primitive_elements(f); g Out[2]: [Poly(x, GF(3)), Poly(x + 2, GF(3)), Poly(2x, GF(3)), Poly(2x + 1, GF(3)), Poly(x^2 + x, GF(3)), Poly(x^2 + 2x + 2, GF(3)), Poly(2x^2 + x + 1, GF(3)), Poly(2x^2 + 2x, GF(3)), Poly(x^3, GF(3)), Poly(x^3 + 2, GF(3)), Poly(x^3 + x, GF(3)), Poly(x^3 + x + 2, GF(3)), Poly(x^3 + 2x + 2, GF(3)), Poly(x^3 + x^2 + 2x, GF(3)), Poly(x^3 + x^2 + 2x + 2, GF(3)), Poly(x^3 + 2x^2, GF(3)), Poly(x^3 + 2x^2 + 1, GF(3)), Poly(x^3 + 2x^2 + x, GF(3)), Poly(x^3 + 2x^2 + x + 1, GF(3)), Poly(x^3 + 2x^2 + 2x + 2, GF(3)), Poly(2x^3, GF(3)), Poly(2x^3 + 1, GF(3)), Poly(2x^3 + x + 1, GF(3)), Poly(2x^3 + 2x, GF(3)), Poly(2x^3 + 2x + 1, GF(3)), Poly(2x^3 + x^2, GF(3)), Poly(2x^3 + x^2 + 2, GF(3)), Poly(2x^3 + x^2 + x + 1, GF(3)), Poly(2x^3 + x^2 + 2x, GF(3)), Poly(2x^3 + x^2 + 2x + 2, GF(3)), Poly(2x^3 + 2x^2 + x, GF(3)), Poly(2x^3 + 2x^2 + x + 1, GF(3))]
Note from the list above that \(x + 2\) is a primitive element, but \(x + 1\) is not.
In [3]: galois.is_primitive_element("x + 2", f) Out[3]: True # x + 1 over GF(3) has integer equivalent of 4 In [4]: galois.is_primitive_element(4, f) Out[4]: False
Last update:
May 16, 2022