galois.is_primitive_element(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:
element: PolyLike

An element $$g$$ of $$\mathrm{GF}(q^m)$$ is a polynomial over $$\mathrm{GF}(q)$$ with degree less than $$m$$.

irreducible_poly: Poly

The degree-$$m$$ irreducible polynomial $$f(x)$$ over $$\mathrm{GF}(q)$$ that defines the extension field $$\mathrm{GF}(q^m)$$.

Returns:

True if $$g$$ is a primitive element of $$\mathrm{GF}(q^m)$$.

Examples

In the extension field $$\mathrm{GF}(3^4)$$, the element $$x + 2$$ is a primitive element whose order is $$3^4 - 1 = 80$$.

In : GF = galois.GF(3**4)

In : f = GF.irreducible_poly; f
Out: Poly(x^4 + 2x^3 + 2, GF(3))

In : galois.is_primitive_element("x + 2", f)
Out: True

In : GF("x + 2").multiplicative_order()
Out: 80


However, the element $$x + 1$$ is not a primitive element, as noted by its order being only 20.

In : galois.is_primitive_element("x + 1", f)
Out: False

In : GF("x + 1").multiplicative_order()
Out: 20