galois.matlab_primitive_poly(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)$$.

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 to galois.primitive_poly(p, m, terms="min"). There are three notable exceptions, however:

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

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

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

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

Examples

In : galois.primitive_poly(2, 6, terms="min")
Out: Poly(x^6 + x + 1, GF(2))

In : galois.matlab_primitive_poly(2, 6)
Out: Poly(x^6 + x + 1, GF(2))


Below is one of the exceptions.

In : galois.primitive_poly(2, 7, terms="min")
Out: Poly(x^7 + x + 1, GF(2))

In : galois.matlab_primitive_poly(2, 7)
Out: Poly(x^7 + x^3 + 1, GF(2))