Communications Toolbox | ![]() ![]() |
Matrix Manipulation in Galois Fields
Some basic operations that you would perform on an ordinary MATLAB array are available for Galois arrays. This section illustrates how to perform basic manipulations and how to get basic information.
Basic Manipulations of Galois Arrays
Basic array operations that you can perform on a Galois array include those in the table below. The results of these operations are Galois arrays in the same field. The functionality of these operations is analogous to the MATLAB operations having the same syntax.
The code below uses some of these syntaxes.
m = 4; a = gf([0:15],m); a(1:2) = [13 13]; % Replace some elements of the vector a. b = reshape(a,2,8); % Create 2-by-8 matrix. c = [b([1 1 2],1:3); a(4:6)]; % Create 4-by-3 matrix. d = [c, a(1:4)']; % Create 4-by-4 matrix. dvec = diag(d); % Extract main diagonal of d. dmat = diag(a(5:9)); % Create 5-by-5 diagonal matrix dtril = tril(d); % Extract upper and lower triangular dtriu = triu(d); % parts of d.
Basic Information About Galois Arrays
You can determine the length of a Galois vector or the size of any Galois array using the length
and size functions. The functionality for Galois arrays is analogous to that of the MATLAB operations on ordinary arrays, except that the output arguments from size
and length
are always integers, not Galois arrays. The code below illustrates the use of these functions.
m = 4; e = gf([0:5],m); f = reshape(e,2,3); lne = length(e); % Vector length of e szf = size(f); % Size of f, returned as a two-element row [nr,nc] = size(f); % Size of f, returned as two scalars nc2 = size(f,2); % Another way to compute number of columns
Positions of Nonzero Elements. Another type of information you might want to determine from a Galois array is the positions of nonzero elements. For an ordinary MATLAB array, you might use the find
function. However, for a Galois array you should use find
in conjunction with the ~=
operator, as illustrated.
x = [0 1 2 1 0 2]; m = 2; g = gf(x,m); nzx = find(x); % Find nonzero values in the ordinary array x. nzg = find(g~=0); % Find nonzero values in the Galois array g.
![]() | Logical Operations in Galois Fields | Linear Algebra in Galois Fields | ![]() |