# gfprimfd

Find primitive polynomials for Galois field

## Syntax

```pol = gfprimfd(m,opt,p) ```

## Description

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.

• If `m` = 1, `pol` = [1 1].

• A polynomial is represented as a row containing the coefficients in order of ascending powers.

`pol = gfprimfd(m,opt,p) ` searches for one or more primitive polynomials for GF(`p^m`), where `p` is a prime number and `m` is a positive integer. If `m` = 1, `pol` = [1 1]. If `m `> 1, the output `pol` depends on the argument `opt` as shown in the table below. Each polynomial is represented in `pol` as a row containing the coefficients in order of ascending powers.

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

## Examples

The code below seeks primitive polynomials for GF(81) having various other properties. Notice that `fourterms` is empty because no primitive polynomial for GF(81) has exactly four nonzero terms. Also notice that `fewterms` represents a single polynomial having three terms, while `threeterms` represents all of the three-term primitive polynomials for GF(81).

```p = 3; m = 4; % Work in GF(81). fewterms = gfprimfd(m,'min',p) threeterms = gfprimfd(m,3,p) fourterms = gfprimfd(m,4,p)```

The output is below.

```fewterms = 2 1 0 0 1 threeterms = 2 1 0 0 1 2 2 0 0 1 2 0 0 1 1 2 0 0 2 1 No primitive polynomial satisfies the given constraints. fourterms = [] ```

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