galois.is_primitive_element¶
- galois.is_primitive_element(element, irreducible_poly)¶
Determines if \(g(x)\) is a primitive element of the Galois field \(\mathrm{GF}(p^m)\) with degree-\(m\) irreducible polynomial \(f(x)\) over \(\mathrm{GF}(p)\).
The number of primitive elements of \(\mathrm{GF}(p^m)\) is \(\phi(p^m - 1)\), where \(\phi(n)\) is the Euler totient function, see
galois.euler_totient
.- Parameters
element (galois.Poly) – An element \(g(x)\) of \(\mathrm{GF}(p^m)\) as a polynomial over \(\mathrm{GF}(p)\) with degree less than \(m\).
irreducible_poly (galois.Poly) – The degree-\(m\) irreducible polynomial \(f(x)\) over \(\mathrm{GF}(p)\) that defines the extension field \(\mathrm{GF}(p^m)\).
- Returns
True
if \(g(x)\) is a primitive element of \(\mathrm{GF}(p^m)\) with irreducible polynomial \(f(x)\).- Return type
Examples
In [389]: GF = galois.GF(3) In [390]: f = galois.Poly([1,1,2], field=GF); f Out[390]: Poly(x^2 + x + 2, GF(3)) In [391]: galois.is_irreducible(f) Out[391]: True In [392]: galois.is_primitive(f) Out[392]: True In [393]: g = galois.Poly.Identity(GF); g Out[393]: Poly(x, GF(3)) In [394]: galois.is_primitive_element(g, f) Out[394]: True
In [395]: GF = galois.GF(3) In [396]: f = galois.Poly([1,0,1], field=GF); f Out[396]: Poly(x^2 + 1, GF(3)) In [397]: galois.is_irreducible(f) Out[397]: True In [398]: galois.is_primitive(f) Out[398]: False In [399]: g = galois.Poly.Identity(GF); g Out[399]: Poly(x, GF(3)) In [400]: galois.is_primitive_element(g, f) Out[400]: False