Reference index

Galois field expression calculator

GF expression can be calculated using gfexpr Tcl command. It accepts the following types of data:

The expression string can contain nested Tcl commands or Tcl variables.

The following table displays the list of supported operators.

operatortypedescription
unary operators
--valuenegate GF value, (-x)
-matrixnegate each element of the matrix
~~valueget inverse GF value, x-1
~matrixinvert matrix
binary operators
+value+valueadd in GF, x + y
value+polytreat GF element as a polynomial and add the polynomials
poly+value
poly+polyadd polynomials
matrix+matrixadd matrices
+value-valuesubtract in GF, x - y
value-polytreat GF element as a polynomial and subtract the polynomials
poly-value
poly-polysubtract polynomials
matrix-matrixsubtract matrices
*value*valuemultiply in GF, x·y
value*polytreat GF element as a polynomial and multiply the polynomials
poly*value
poly*polymultiply polynomials
value*matrixmultiply matrix by value
matrix*value
matrix*matrixmultiply matrices
/value/valuedivide GF values, x·y-1
value/polytreat GF element as a polynomial and divide the polynomials
poly/value
poly/polydivide polynomials
%value/valuealways 0
value%polytreat GF element as a polynomial and and find the remainder of division
poly%value
poly%polyfind remainder of the polynomial division
**matrix**matrixKronecker product of two matrices
^value^integerexponentiate GF value, xn
poly^integerexponentiate polynomial
 
( ) change operator precdence

Examples

gfexpr -gf [gf 4] A*(B-1)

Calculates A(B - 1) over GF(4).

set_default_gf [gf 2]
set p1 [poly 101]
set p2 [poly 11]
gfexpr $p1*$p2

Multiplies polynimials of transcendental x: (x2 + 1)(x+1) over GF(2).

rm_radix_model -in 4 -out 4
set_default_gf [gf 4]
set d [vector BBAABB1ABBAABB1A]
set s0 [rm_get_smatrix 0]
set w0 [gfexpr ~$s0]
gfexpr ($w0**$w0)*d

Manually compute zero-polarity quaternary Reed-Muller expansion.