주요 콘텐츠

gfprimfd

Find primitive polynomials for Galois field

Description

pol = gfprimfd(m,opt,p) searches for one or more primitive polynomials for GF(pm).

  • If m= 1 and pol = [1 1].

  • If m>1, the output pol depends on the argument opt as shown in the table:

    optSignificance of polFormat of pol
    'min'One primitive polynomial for GF(pm) having the smallest possible number of nonzero terms The row vector representing the polynomial
    'max'One primitive polynomial for GF(pm) having the greatest possible number of nonzero terms The row vector representing the polynomial
    'all'All primitive polynomials for GF(pm) A matrix, each row of which represents one such polynomial
    A positive integer All primitive polynomials for GF(pm) that have opt nonzero terms A matrix, each row of which represents one such polynomial

Note

This function performs computations in GF(pm), where p is prime. To work in GF(2m), use the primpoly function. For details, see Finding Primitive Polynomials in Primitive Polynomials and Element Representations.

example

Examples

collapse all

This example shows how to find primitive polynomials in GF(34) with the fewest terms, with exactly three terms, and with exactly four terms.

p =3;
m=4;

Find the fewest of nonzero terms.

fewterms = gfprimfd(m, 'min', p)
fewterms = 1×5

     2     1     0     0     1

fewterms returns one primitive polynomial with the fewest nonzero terms (three terms in this case).

Find all primitive polynomials with exactly three nonzero terms.

threeterms = gfprimfd(m, 3, p)
threeterms = 4×5

     2     1     0     0     1
     2     2     0     0     1
     2     0     0     1     1
     2     0     0     2     1

threeterms returns all three‑term primitive polynomials for GF(34).

Find all primitive polynomials with exactly four nonzero terms

fourterms = gfprimfd(m, 4, p)
Warning: No primitive polynomial satisfies the given constraints.
fourterms =

     []

fourterms is empty because no primitive polynomial for GF(34) has exactly four nonzero terms.

Input Arguments

collapse all

Degree of primitive polynomial, specified as a positive integer.

Data Types: single | double

Search criteria for primitive polynomials, specified as one of the following:

  • 'min': Returns one primitive polynomial with the smallest possible number of nonzero terms.

  • 'max': Returns one primitive polynomial with the greatest possible number of nonzero terms.

  • 'all': Returns all primitive polynomials for GF(pm).

  • Positive integer (e.g., 3, 4, ...): Returns all primitive polynomials that have exactly that number of nonzero terms.

Data Types: char | double

Prime number, specified as a positive integer.

Data Types: single | double

Output Arguments

collapse all

Coefficients of one or more primitive polynomial in ascending order, returned as a row vector or a matrix.

  • If the function returns a single polynomial, pol is a row vector of coefficients.

  • If the function returns multiple polynomials are, pol is a matrix where each row is a polynomial.

Data Types: double

Algorithms

gfprimfd tests for primitivity using gfprimck. If opt is 'min', 'max', or omitted, polynomials are constructed by converting decimal integers to base p. Based on the decimal ordering, gfprimfd returns the first polynomial it finds that satisfies the appropriate conditions.

Version History

Introduced before R2006a