Matrix Manipulation in Galois Fields
Basic Manipulations of Galois Arrays
Basic array operations on Galois arrays are in the table below.
The functionality of these operations is analogous to the MATLAB operations
having the same syntax.
| Operation | Syntax |
| Index into array, possibly using colon
operator instead of a vector of explicit indices | a(vector) or a(vector,vector1),
where vector and/or vector1 can
be ":" instead of a vector |
| Transpose array | a' |
| Concatenate matrices | [a,b] or [a;b] |
| Create array having specified diagonal
elements | diag(vector) or diag(vector,k) |
| Extract diagonal elements | diag(a) or diag(a,k) |
| Extract lower triangular part | tril(a) or tril(a,k) |
| Extract upper triangular part | triu(a) or triu(a,k) |
| Change shape of array | reshape(a,k1,k2) |
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.
Back to Top
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 are 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.
Back to Top
 | Logical Operations in Galois Fields | | Linear Algebra in Galois Fields |  |
How much time do you spend on testing to ensure implementation meets system-level requirements?
Learn more