Create Galois field array


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


x_gf = gf(x,m) creates a Galois field array from the matrix x. The Galois field has 2^m elements, where m is an integer between 1 and 16. The elements of x must be integers between 0 and 2^m-1. The output x_gf is a variable that MATLAB recognizes as a Galois field array, rather than an array of integers. As a result, when you manipulate x_gf using operators or functions such as + or det, MATLAB works within the Galois field you have specified.


To learn how to manipulate x_gf using familiar MATLAB operators and functions, see Galois Field Computations. To learn how the integers in x represent elements of GF(2^m), see How Integers Correspond to Galois Field Elements.

x_gf = gf(x,m,prim_poly) is the same as the previous syntax, except it uses the primitive polynomial prim_poly to define the field. prim_poly is a polynomial character vector or the integer representation of a primitive polynomial. For example, the number 37 represents the polynomial D^5+D^2+1 because the binary form of 37 is 1 0 0 1 0 1. For more information, see Default Primitive Polynomials.

x_gf = gf(x) creates a GF(2) array from the matrix x. Each element of x must be 0 or 1.


collapse all

Set the order of the Galois field to 16, where the order equals 2m. The elements of x must range from 0 to 2m-1.

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

Create a sequence of integers. Create a Galois field array, where m = 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) = 
pp = 6×1


Generate a GF 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

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), (2(M+1)-1)] and must indicate an irreducible polynomial. For more information, see Specifying the Primitive Polynomial.

MDefault Primitive PolynomialInteger Representation
1D + 13
2D^2 + D + 17
3D^3 + D + 111
4D^4 + D + 119
5D^5 + D^2 + 137
6D^6 + D + 167
7D^7 + D^3 + 1137
8D^8 + D^4 + D^3 + D^2 + 1285
9D^9 + D^4 + 1529
10D^10 + D^3 + 11033
11D^11 + D^2 + 12053
12D^12 + D^6 + D^4 + D + 14179
13D^13 + D^4 + D^3 + D + 18219
14D^14 + D^10 + D^6 + D + 117475
15D^15 + D + 132771
16D^16 + D^12 + D^3 + D + 169643

Galois Computations

Operations supported for Galois field arrays include:

+ -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