galois.matlab_primitive_poly(characteristic: int, degree: int) Poly

Returns Matlab’s default primitive polynomial \(f(x)\) over \(\mathrm{GF}(p)\) with degree \(m\).

Parameters
characteristic: int

The prime characteristic \(p\) of the field \(\mathrm{GF}(p)\) that the polynomial is over.

degree: int

The degree \(m\) of the desired primitive polynomial.

Returns

Matlab’s default degree-\(m\) primitive polynomial over \(\mathrm{GF}(p)\).

Notes

This function returns the same result as Matlab’s gfprimdf(m, p). Matlab uses the primitive polynomial with minimum terms (equivalent to galois.primitive_poly(p, m, method="min-terms")) as the default… mostly. There are three notable exceptions:

  1. \(\mathrm{GF}(2^7)\) uses \(x^7 + x^3 + 1\), not \(x^7 + x + 1\).

  2. \(\mathrm{GF}(2^{14})\) uses \(x^{14} + x^{10} + x^6 + x + 1\), not \(x^{14} + x^5 + x^3 + x + 1\).

  3. \(\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.

References

  • Lin, S. and Costello, D. Error Control Coding. Table 2.7.

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))