galois.is_primitive_element(element: PolyLike, irreducible_poly: Poly) bool

Determines if g is a primitive element of the Galois field GF(qm) with degree-m irreducible polynomial f(x) over GF(q).

Parameters:
element: PolyLike

An element g of GF(qm) is a polynomial over GF(q) with degree less than m.

irreducible_poly: Poly

The degree-m irreducible polynomial f(x) over GF(q) that defines the extension field GF(qm).

Returns:

True if g is a primitive element of GF(qm).

Examples

In the extension field GF(34), the element x+2 is a primitive element whose order is 341=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