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 \(\mathrm{GF}(p^m)\) with degree-\(m\) irreducible polynomial \(f(x)\) over \(\mathrm{GF}(p)\).

Parameters
  • irreducible_poly (galois.Poly) – The degree-\(m\) irreducible polynomial \(f(x)\) over \(\mathrm{GF}(p)\) that defines the extension field \(\mathrm{GF}(p^m)\).

  • start (int, optional) – Starting value (inclusive, integer representation of the polynomial) in the search for a primitive element \(g(x)\) of \(\mathrm{GF}(p^m)\). The default is None which represents \(p\), which corresponds to \(g(x) = x\) over \(\mathrm{GF}(p)\).

  • stop (int, optional) – Stopping value (exclusive, integer representation of the polynomial) in the search for a primitive element \(g(x)\) of \(\mathrm{GF}(p^m)\). The default is None which represents \(p^m\), which corresponds to \(g(x) = x^m\) over \(\mathrm{GF}(p)\).

  • reverse (bool, optional) – Search for a primitive element in reverse order, i.e. find the largest primitive element first. Default is False.

Returns

A primitive element of \(\mathrm{GF}(p^m)\) with irreducible polynomial \(f(x)\). The primitive element \(g(x)\) is a polynomial over \(\mathrm{GF}(p)\) with degree less than \(m\).

Return type

galois.Poly

Examples

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

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

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

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

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

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

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

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

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