galois.matlab_primitive_poly¶
- galois.matlab_primitive_poly(characteristic, degree)¶
Returns Matlab’s default primitive polynomial \(f(x)\) over \(\mathrm{GF}(p)\) with degree \(m\).
- Parameters
- Returns
Matlab’s default degree-\(m\) primitive polynomial over \(\mathrm{GF}(p)\).
- Return type
Notes
This function returns the same result as Matlab’s
gfprimdf(m, p)
. Matlab uses the lexicographically-minimal primitive polynomial (equivalent togalois.primitive_poly(p, m)
) as the default… mostly. There are three notable exceptions:\(\mathrm{GF}(2^7)\) uses \(x^7 + x^3 + 1\), not \(x^7 + x + 1\).
\(\mathrm{GF}(2^{14})\) uses \(x^{14} + x^{10} + x^6 + x + 1\), not \(x^{14} + x^5 + x^3 + x + 1\).
\(\mathrm{GF}(2^{16})\) uses \(x^{16} + x^{12} + x^3 + x + 1\), not \(x^{16} + x^5 + x^3 + x^2 + 1\).
Warning
This has been tested for all the \(\mathrm{GF}(2^m)\) fields for \(2 \le m \le 16\) (Matlab doesn’t support larger than 16). And it has been spot-checked for \(\mathrm{GF}(p^m)\). There may exist other exceptions. Please submit a GitHub issue if you discover one.
Examples
In [1]: galois.primitive_poly(2, 6) Out[1]: Poly(x^6 + x + 1, GF(2)) In [2]: galois.matlab_primitive_poly(2, 6) Out[2]: Poly(x^6 + x + 1, GF(2))
In [3]: galois.primitive_poly(2, 7) Out[3]: Poly(x^7 + x + 1, GF(2)) In [4]: galois.matlab_primitive_poly(2, 7) Out[4]: Poly(x^7 + x^3 + 1, GF(2))