# gf

Galois field array

## Syntax

``x_gf = gf(x)``
``x_gf = gf(x,m)``
``x_gf = gf(x,m,prim_poly)``

## Description

example

````x_gf = gf(x)` creates a Galois field (GF) array, GF(2), from matrix `x`.```

example

````x_gf = gf(x,m)` creates a Galois field array from matrix `x`. The Galois field has 2`m` elements, where `m` is an integer from 1 through 16.```

example

````x_gf = gf(x,m,prim_poly)` creates a Galois field array from matrix `x` by using the primitive polynomial `prim_poly`.```

## Examples

collapse all

Specify a matrix of `0`s and `1`s.

`x = [0 1 1; 0 1 0; 1 1 1];`

Create a GF(2) array from `x`.

`x_gf = gf(x)`
``` x_gf = GF(2) array. Array elements = 0 1 1 0 1 0 1 1 1 ```

Set the order of the Galois field to 16, where the order equals ${2}^{m}$. Specify a matrix of elements that range from 0 to ${2}^{m}-1$. Create the Galois field array.

```m = 4; x = [3 2 9; 1 2 1]; y = gf(x,m)```
``` y = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal) Array elements = 3 2 9 1 2 1 ```

Create a sequence of integers. Create a Galois field array in GF(${2}^{5}$).

```x = [17 8 11 27]; y = gf(x,5)```
``` y = GF(2^5) array. Primitive polynomial = D^5+D^2+1 (37 decimal) Array elements = 17 8 11 27 ```

Determine all possible primitive polynomials for GF(${2}^{5}$).

`pp = 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 ```
```pp = 6×1 37 41 47 55 59 61 ```

Create a Galois field array using the primitive polynomial that has a decimal equivalent of 59.

`z = gf(x,5,'D5+D4+D3+D+1')`
``` z = GF(2^5) array. Primitive polynomial = D^5+D^4+D^3+D+1 (59 decimal) Array elements = 17 8 11 27 ```

## Input Arguments

collapse all

Input matrix, specified as a matrix with values greater than or equal to zero. The function uses this value to create a GF array.

• If you do not specify the `prim_poly` input argument, each element of `x` must be an integer in the range [0, 2`m`–1].

• If you specify `prim_poly` input argument, each element of `x` must be `0` or `1`.

Data Types: `double`

Order of primitive polynomial, specified as a positive integer from 1 through 16. The function uses this value to calculate the distinct number of elements in the GF.

Data Types: `double`

Primitive polynomial, specified as one of these options:

• Binary row vector — This vector specifies coefficients of `prim_poly` in the order of ascending powers.

• Character vector or a string scalar — This value defines `prim_poly` in a textual representation. For more details, refer to polynomial character vector.

• Positive integer — This value defines `prim_poly` in the range [(2m + 1), (2m+1 – 1)].

If `prim_poly` is not specified, see Default Primitive Polynomials for the list of default primitive polynomial used for each Galois field array GF(2`m`).

Data Types: `double` | `char` | `string`

## Output Arguments

collapse all

Galois field array, returned as a variable that MATLAB recognizes as a Galois field array, rather than an array of integers. As a result, when you manipulate the variable, MATLAB works within the Galois field the variable specifies. For example, if you apply the `log` function to a Galois array, MATLAB computes the logarithm in the Galois field for that Galois array and not in the field of real or complex numbers.

## More About

collapse all

### Default Primitive Polynomials

This table lists the default primitive polynomial used for each Galois field array GF(2`m`). To use a different primitive polynomial, specify `prim_poly` as an input argument. `prim_poly` must be in the range [(2`m` + 1), (2`m`+1 – 1)] and must indicate an irreducible polynomial. For more information, see Primitive Polynomials and Element Representations.

Value of mDefault Primitive PolynomialInteger Representation
`1`D + 13
`2`D2 + D + 17
`3`D3 + D + 111
`4`D4 + D + 119
`5`D5 + D2 + 137
`6`D6 + D + 167
`7`D7 + D3 + 1137
`8`D8 + D4 + D3 + D2 + 1285
`9`D9 + D4 + 1529
`10`D10 + D3 + 11033
`11`D11 + D2 + 12053
`12`D12 + D6 + D4 + D + 14179
`13`D13 + D4 + D3 + D + 18219
`14`D14 + D10 + D6 + D + 117475
`15`D15 + D + 132771
`16`D16 + D12 + D3 + D + 169643

### Galois Computations

This table lists the operations supported for Galois field arrays.

OperationDescription
+ -Addition and subtraction of Galois arrays
* / \Matrix multiplication and division of Galois arrays
.* ./ .\Elementwise multiplication and division of Galois arrays
^Matrix exponentiation of Galois array
.^Elementwise exponentiation of Galois array
' .'Transpose of Galois array
==, ~=Relational operators for Galois arrays
allTrue if all elements of a Galois vector are nonzero
anyTrue if any element of a Galois vector is nonzero
convConvolution of Galois vectors
`convmtx`Convolution matrix of Galois field vector
deconvDeconvolution and polynomial division
detDeterminant of square Galois matrix
`dftmtx`Discrete Fourier transform matrix in a Galois field
diagDiagonal Galois matrices and diagonals of a Galois matrix
`fft`Discrete Fourier transform
`filter (gf)`One-dimensional digital filter over a Galois field
`ifft`Inverse discrete Fourier transform
invInverse of Galois matrix
lengthLength of Galois vector
`log`Logarithm in a Galois field
luLower-Upper triangular factorization of Galois array
`minpol`Find the minimal polynomial for a Galois element
`mldivide`Matrix left division \ of Galois arrays
polyvalEvaluate polynomial in Galois field
rankRank of a Galois array
reshapeReshape Galois array
rootsFind polynomial roots across a Galois field
sizeSize of Galois array
trilExtract lower triangular part of Galois array
triuExtract upper triangular part of Galois array

## See Also

### Topics

Introduced before R2006a

## Support

#### Bridging Wireless Communications Design and Testing with MATLAB

Download white paper