galois.is_primitive_element¶
- class 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 [533]: GF = galois.GF(3) In [534]: f = galois.Poly([1,1,2], field=GF); f Out[534]: Poly(x^2 + x + 2, GF(3)) In [535]: galois.is_irreducible(f) Out[535]: True In [536]: galois.is_primitive(f) Out[536]: True In [537]: g = galois.Poly.Identity(GF); g Out[537]: Poly(x, GF(3)) In [538]: galois.is_primitive_element(g, f) Out[538]: True
In [539]: GF = galois.GF(3) In [540]: f = galois.Poly([1,0,1], field=GF); f Out[540]: Poly(x^2 + 1, GF(3)) In [541]: galois.is_irreducible(f) Out[541]: True In [542]: galois.is_primitive(f) Out[542]: False In [543]: g = galois.Poly.Identity(GF); g Out[543]: Poly(x, GF(3)) In [544]: galois.is_primitive_element(g, f) Out[544]: False