Main Content

gf

Galois field array

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 2m 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 0s and 1s.

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 2m. Specify a matrix of elements that range from 0 to 2m-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(25).

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(25).

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, 2m–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(2m).

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(2m). To use a different primitive polynomial, specify prim_poly as an input argument. prim_poly must be in the range [(2m + 1), (2m+1 – 1)] and must indicate an irreducible polynomial. For more information, see Primitive Polynomials and Element Representations.

Value of mDefault Primitive PolynomialInteger Representation
1D + 13
2D2 + D + 17
3D3 + D + 111
4D4 + D + 119
5D5 + D2 + 137
6D6 + D + 167
7D7 + D3 + 1137
8D8 + D4 + D3 + D2 + 1285
9D9 + D4 + 1529
10D10 + D3 + 11033
11D11 + D2 + 12053
12D12 + D6 + D4 + D + 14179
13D13 + D4 + D3 + D + 18219
14D14 + D10 + D6 + D + 117475
15D15 + D + 132771
16D16 + 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
convmtxConvolution matrix of Galois field vector
deconvDeconvolution and polynomial division
detDeterminant of square Galois matrix
dftmtxDiscrete Fourier transform matrix in a Galois field
diagDiagonal Galois matrices and diagonals of a Galois matrix
fftDiscrete Fourier transform
filter (gf)One-dimensional digital filter over a Galois field
ifftInverse discrete Fourier transform
invInverse of Galois matrix
lengthLength of Galois vector
logLogarithm in a Galois field
luLower-Upper triangular factorization of Galois array
minpolFind the minimal polynomial for a Galois element
mldivideMatrix 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
Introduced before R2006a