Main Content

primpoly

Find primitive polynomials for Galois field

Description

pr = primpoly(m) returns the primitive polynomial for GF(2m). Running this syntax displays the primitive polynomial using "D" as an indeterminate quantity in the command window.

example

pr = primpoly(m,opt) returns one or more primitive polynomials for GF(2m) as specified by the optional argument opt. If no primitive polynomial satisfies the constraints, pr is empty.

pr = primpoly(___,"nodisplay") suppresses the command window display of the result as polynomials in "D". The output argument pr is unaffected by the "nodisplay" option.

Examples

collapse all

Generate primitive polynomials by using various syntax options.

Generate the degree-m primitive polynomial for gf(2,4) that has the smallest possible number of nonzero terms. Display the default output, showing the polynomial format and integer value for the binary equivalent representation of the polynomial coefficients.

pr = primpoly(4)
 
Primitive polynomial(s) = 
 
D^4+D^1+1
pr = 
19

The optional string argument "nodisplay" suppresses display of the polynomial format output.

pr = primpoly(4,"nodisplay")
pr = 
19

The optional string argument "all" outputs all degree-m primitive polynomials for gf(2,5).

pr_all = primpoly(5,"all")
 
Primitive polynomial(s) = 
 
D^5+D^2+1
D^5+D^3+1
D^5+D^3+D^2+D^1+1
D^5+D^4+D^2+D^1+1
D^5+D^4+D^3+D^1+1
D^5+D^4+D^3+D^2+1
pr_all = 6×1

    37
    41
    47
    55
    59
    61

The optional string argument "max" outputs the degree-m primitive polynomials for gf(2,5) that have the greatest possible number of nonzero terms.

pr1 = primpoly(5,"max","nodisplay")
pr1 = 
61

The optional string argument "min" outputs the degree-m primitive polynomials for gf(2,5) that have the smallest possible number of nonzero terms.

pr2 = primpoly(5,"min")
 
Primitive polynomial(s) = 
 
D^5+D^2+1
pr2 = 
37

The optional integer argument, 3, outputs the degree-m primitive polynomials for gf(2,5) that have three nonzero terms.

pr4 = primpoly(5,3)
 
Primitive polynomial(s) = 
 
D^5+D^2+1
D^5+D^3+1
pr4 = 2×1

    37
    41

Input Arguments

collapse all

Primitive polynomial degree, specified as an integer in the range [2, 16].

Optional input argument, specified as one of these options to define the list of primitive polynomials output to pr:

  • "min" — One primitive polynomial for GF(2m) that has the smallest possible number of nonzero terms

  • "max" — One primitive polynomial for GF(2m) that has the greatest possible number of nonzero terms

  • "all" — All primitive polynomials for GF(2m)

  • Positive integer, L — All primitive polynomials for GF(2m) that have L nonzero terms.

Output Arguments

collapse all

Primitive polynomials, specified as a positive integer or row vector. The returned output, pr, includes integers whose binary representation indicates the coefficients of the polynomials.

Version History

Introduced before R2006a