Add polynomials over Galois field
c = gfadd(a,b)
c = gfadd(a,b,p)
c = gfadd(a,b,p,len)
c = gfadd(a,b,field)
Note: This function performs computations in GF(pm) where p is prime. To work in GF(2m), apply the + operator to Galois arrays of equal size. For details, see Example: Addition and Subtraction.
c = gfadd(a,b) adds
two GF(2) polynomials,
which can be either polynomial strings or
numeric vectors. If
vectors of the same orientation but different lengths, then the shorter
vector is zero-padded. If
matrices they must be of the same size.
c = gfadd(a,b,p) adds
p) polynomials, where
a prime number.
row vectors that give the coefficients of the corresponding polynomials
in order of ascending powers. Each coefficient is between 0 and
b are matrices of the
same size, the function treats each row independently.
c = gfadd(a,b,p,len) adds
b as in the
previous syntax, except that it returns a row vector of length
c is a truncated or extended representation
of the sum. If the row vector corresponding to the sum has fewer than
(including zeros), extra zeros are added at the end; if it has more
len entries, entries from the end are removed.
c = gfadd(a,b,field) adds
two GF(pm) elements, where m is a positive
b are the exponential
format of the two elements, relative to some primitive element of
field is the
matrix listing all elements of GF(pm),
arranged relative to the same primitive element.
the exponential format of the sum, relative to the same primitive
element. See Representing Elements of Galois Fields for an explanation
of these formats. If
matrices of the same size, the function treats each element independently.
In the code below,
sum5 is the sum of 2 + 3x + x2 and
4 + 2x + 3x2 over
linpart is the degree-one part of
sum5 = gfadd([2 3 1],[4 2 3],5) linpart = gfadd([2 3 1],[4 2 3],5,2)
The output is
sum5 = 1 0 4 linpart = 1 0
The code below shows that A2 + A4 = A1, where A is a root of the primitive polynomial 2 + 2x + x2 for GF(9).
p = 3; m = 2; prim_poly = [2 2 1]; field = gftuple([-1:p^m-2]',prim_poly,p); g = gfadd(2,4,field)
The output is
g = 1
Other examples are in Arithmetic in Galois Fields.