This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Logarithm in Galois field


y = log(x)


y = log(x) computes the logarithm of each element in the Galois array x. y is an integer array that solves the equation A.^y = x, where A is the primitive element used to represent elements in x. More explicitly, the base A of the logarithm is gf(2,x.m) or gf(2,x.m,x.prim_poly). All elements in x must be nonzero because the logarithm of zero is undefined.


The code below illustrates how the logarithm operation inverts exponentiation.

m = 4; x = gf([8 1 6; 3 5 7; 4 9 2],m);
y = log(x);
primel = gf(2,m); % Primitive element in the field
z = primel .^ y; % This is now the same as x.
ck = isequal(x,z)

The output is

ck =


The code below shows that the logarithm of 1 is 0 and that the logarithm of the base (primel) is 1.

m = 4; primel = gf(2,m);
yy = log([1, primel])

The output is

yy =

     0     1

See Also

Introduced before R2006a