| Communications Toolbox | ![]() |
The code below creates a row vector whose entries are in the field GF(4), and then adds the row to itself.
x = 0:3; % A row vector containing integers m = 2; % Work in the field GF(2^2), or, GF(4). a = gf(x,m) % Create a Galois array in GF(2^m). b = a + a % Add a to itself, creating b.
The output is
a = GF(2^2) array. Primitive polynomial = D^2+D+1 (7 decimal)
Array elements =
0 1 2 3
b = GF(2^2) array. Primitive polynomial = D^2+D+1 (7 decimal)
Array elements =
0 0 0 0
The output shows the values of the Galois arrays named a and b. Notice that each output section indicates
The field containing the variable, namely, GF(2^2) = GF(4).
The primitive polynomial for the field. In this case, it is the toolbox's default primitive polynomial for GF(4).
The array of Galois field values that the variable contains. In particular, the array elements in a are exactly the elements of the vector x, while the array elements in b are four instances of the zero element in GF(4).
The command that creates b shows how, having defined the variable a as a Galois array, you can add a to itself by using the ordinary + operator. MATLAB performs the vectorized addition operation in the field GF(4). Notice from the output that
Compared to a, b is in the same field and uses the same primitive polynomial. It is not necessary to indicate the field when defining the sum, b, because MATLAB remembers that information from the definition of the addends, a.
The array elements of b are zeros because the sum of any value with itself, in a Galois field of characteristic two, is zero. This result differs from the sum x + x, which represents an addition operation in the infinite field of integers.
| Creating a Galois Array | Example: Representing Elements of GF(8) | ![]() |
© 1994-2005 The MathWorks, Inc.