Communications Toolbox | ![]() ![]() |
Arithmetic in Galois Fields
You can add, subtract, multiply, and divide elements of Galois fields using the functions gfadd
, gfsub
, gfmul
, and gfdiv
, respectively. Each of these functions has a mode for prime fields and a mode for extension fields.
Arithmetic in Prime Fields
Arithmetic in GF(p) is the same as arithmetic modulo p. The functions gfadd
, gfmul
, gfsub
, and gfdiv
accept two arguments that represent elements of GF(p) as integers between 0 and p-1. The third argument specifies p.
Example: Addition Table for GF(5)
The code below constructs an addition table for GF(5). If a
and b
are between 0 and 4, then the element gfp_add(a+1,b+1)
represents the sum a+b
in GF(5). For example, gfp_add(3,5) = 1
because 2+4 is 1 modulo 5.
p = 5; row = 0:p-1; table = ones(p,1)*row; gfp_add = gfadd(table,table',p) gfp_add = 0 1 2 3 4 1 2 3 4 0 2 3 4 0 1 3 4 0 1 2 4 0 1 2 3
Other values of p
produce tables for different prime fields GF(p
). Replacing gfadd
by gfmul
, gfsub
, or gfdiv
produces a table for the corresponding arithmetic operation in GF(p
).
![]() | Converting to Simplest Exponential Format | Arithmetic in Extension Fields | ![]() |