Main Content

gf

Galois field array

Description

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.

example

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

Use the genpoly2b function to return the corresponding Galois field array value and the generator polynomial validity indication.

Create a valid Galois field array object.

genpoly = gf([1 1 6],3)
 
genpoly = GF(2^3) array. Primitive polynomial = D^3+D+1 (11 decimal)
 
Array elements = 
 
   1   1   6
[b,ecode] = genpoly2b(genpoly,3,11)
b = 
1
ecode = 
1

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

Version History

Introduced before R2006a