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:
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 [1]: GF = galois.GF(3**4)

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

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

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

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

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

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