- galois.matlab_primitive_poly(characteristic: int, degree: int) Poly
Returns Matlab’s default primitive polynomial \(f(x)\) over \(\mathrm{GF}(p)\) with degree \(m\).
See also
Notes¶
This function returns the same result as Matlab’s
gfprimdf(m, p)
. Matlab uses the lexicographically first primitive polynomial with minimum terms, which is equivalent togalois.primitive_poly(p, m, terms="min")
. There are three notable exceptions, however:In \(\mathrm{GF}(2^7)\), Matlab uses \(x^7 + x^3 + 1\), not \(x^7 + x + 1\).
In \(\mathrm{GF}(2^{14})\), Matlab uses \(x^{14} + x^{10} + x^6 + x + 1\), not \(x^{14} + x^5 + x^3 + x + 1\).
In \(\mathrm{GF}(2^{16})\), Matlab 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.
References¶
Lin, S. and Costello, D. Error Control Coding. Table 2.7.
Examples¶
In [1]: galois.primitive_poly(2, 6, terms="min") 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))
Below is one of the exceptions.
In [3]: galois.primitive_poly(2, 7, terms="min") 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))