| Communications Toolbox | ![]() |
Subtract polynomials over a Galois field
Syntax
c = gfsub(a,b); c = gfsub(a,b,p); c = gfsub(a,b,p,len); c = gfsub(a,b,field);
Description
c = gfsub(a,b)
calculates a minus b, where a and b represent polynomials over GF(2). The inputs and output are row vectors that give the coefficients of the corresponding polynomials in order of ascending powers. Each coefficient is either 0 or 1, since the field is GF(2). If a and b are matrices of the same size, then the function treats each row independently.
c = gfsub(a,b,p)
calculates a minus b, where a and b represent polynomials over GF(p) and p is a prime number. a, b, and c are row vectors that give the coefficients of the corresponding polynomials in order of ascending powers. Each coefficient is between 0 and p-1. If a and b are matrices of the same size, then the function treats each row independently.
c = gfsub(a,b,p,len)
subtracts row vectors as in the syntax above, except that it returns a row vector of length len. The output c is a truncated or extended representation of the answer. If the row vector corresponding to the answer has fewer than len entries (including zeros), then extra zeros are added at the end; if it has more than len entries, then entries from the end are removed.
c = gfsub(a,b,field)
calculates a minus b, where a and b are the exponential format of two elements of GF(pm), relative to some primitive element of GF(pm). p is a prime number and m is a positive integer. field is the matrix listing all elements of GF(pm), arranged relative to the same primitive element. c is the exponential format of the answer, relative to the same primitive element. See Representing Elements of Galois Fields for an explanation of these formats. If a and b are matrices of the same size, then the function treats each element independently.
Examples
In the code below, differ is the difference of 2 + 3x + x2 and 4 + 2x + 3x2 over GF(5), and linpart is the degree-one part of differ.
differ = gfsub([2 3 1],[4 2 3],5)
differ =
3 1 3
linpart = gfsub([2 3 1],[4 2 3],5,2)
linpart =
3 1
The code below shows that
, where
is a root of the primitive polynomial 2 + 2x + x2 for GF(9).
p = 3; m = 2;
primpoly = [2 2 1];
field = gftuple([-1:p^m-2]',primpoly,p);
d = gfsub(2,4,field)
d =
7
See Also
gfadd, gfmul, gfconv, gfdiv, gfdeconv, gftuple
| gfroots | gftrunc | ![]() |