| Communications Toolbox | ![]() |
Add elements of a Galois field of characteristic two
Syntax
k = gfplus(a,b,fvec,ivec);
Description
k = gfplus(a,b,fvec,ivec)
adds a and b in GF(2m), using the exponential format to represent inputs and outputs. If a and b are matrices, then they must have the same dimensions, and gfplus adds them element-by-element. See Representing Elements of Galois Fields for an explanation of the exponential format.
fvec and ivec are vectors of length 2m. The entries in both are integers between 0 and 2m-1. fvec contains the same information as the field parameter as used by gfadd, except that fvec has been condensed into a vector. To compute fvec and ivec, define m and then use the commands below.
fvec = gftuple([-1 : 2^m-2]',m) * 2.^[0 : m-1]'; ivec(fvec + 1) = 0 : 2^m - 1;
Alternatively, define a primitive polynomial vector pol and then use the commands below. See gfprimfd for information about defining pol.
fvec = gftuple([-1 : 2^m-2]',pol) * 2.^[0 : m-1]'; ivec(fvec + 1) = 0 : 2^m - 1;
Examples
This example adds two matrices, each of which contains random nonzero elements of GF(25).
m = 5;
a = randint(3,6,2^m-1,1234); % Create a 3-by-6 matrix in GF(2^5).
b = randint(3,6,2^m-1);
fvec = gftuple([-1 : 2^m - 2]',m)*2.^[0 : m-1]';
ivec(fvec + 1) = 0 : 2^m - 1;
aplusb = gfplus(a,b,fvec,ivec) % Add.
aplusb =
22 25 4 23 9 29
9 30 24 23 -Inf 19
15 17 10 12 25 30
| gfmul | gfpretty | ![]() |