galois.primitive_element

galois.primitive_element(irreducible_poly, start=None, stop=None, reverse=False)

Finds the smallest primitive element g(x) of the Galois field GF(pm) with degree-m irreducible polynomial f(x) over GF(p).

Parameters
irreducible_poly : Poly

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

start : Optional[int]

Starting value (inclusive, integer representation of the polynomial) in the search for a primitive element g(x) of GF(pm). The default is None which represents p, which corresponds to g(x)=x over GF(p).

stop : Optional[int]

Stopping value (exclusive, integer representation of the polynomial) in the search for a primitive element g(x) of GF(pm). The default is None which represents pm, which corresponds to g(x)=xm over GF(p).

reverse : bool

Search for a primitive element in reverse order, i.e. find the largest primitive element first. Default is False.

Returns

A primitive element of GF(pm) with irreducible polynomial f(x). The primitive element g(x) is a polynomial over GF(p) with degree less than m.

Return type

Poly

Examples

In [1]: GF = galois.GF(3)

In [2]: f = galois.Poly([1,1,2], field=GF); f
Out[2]: Poly(x^2 + x + 2, GF(3))

In [3]: galois.is_irreducible(f)
Out[3]: True

In [4]: galois.is_primitive(f)
Out[4]: True

In [5]: galois.primitive_element(f)
Out[5]: Poly(x, GF(3))
In [6]: GF = galois.GF(3)

In [7]: f = galois.Poly([1,0,1], field=GF); f
Out[7]: Poly(x^2 + 1, GF(3))

In [8]: galois.is_irreducible(f)
Out[8]: True

In [9]: galois.is_primitive(f)
Out[9]: False

In [10]: galois.primitive_element(f)
Out[10]: Poly(x + 1, GF(3))

Last update: Feb 09, 2022