使用MATLAB的有限域计算

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Galois Field Computation in MATLAB:

Primitive Polynomial:

An Irreducible polynomial p(X) of degree m is said to be primitive if the smaller positive integer n for which p(X) divides X n + 1 is n = 2m – 1. For example, p(X) = X4 + X + 1 divides X15 +1 but not divides any X n +1 for 1 ≤ n < 15.

In Matlab you can easily find the primitive polynomials for any degree using primpoly(m) function.

Example:

m= 4; Define m = 4 for GF(24)

s = primpoly(m)

Output is:

Primitive polynomial(s) =

D^4+D^1+1

s =

19

Here it shows the primitive polynomial and an integer whose binary representation indicates the coefficients of the polynomial. Note that there could be more than one primitive polynomial for a particular degree of m.

Galois Field arithmetic:

To demonstrate Galois Field arithmetic we consider following table for degree m = 4 an primitive polynomial p(X) = 1 + X + X4

Power Representation Polynomial Represent4-Tuple Representation

0 0 0 0 0 0

1 1 1 0 0 0

αα0 1 0 0

α2 α20 0 1 0

α3 α30 0 0 1

α4 1+ α 1 1 0 0

α5 α + α2 0 1 1 0

α6 α2 + α30 0 1 1

α7 1+ α + α3 1 1 0 1

α8 1 + α2 1 0 1 0

α9 α + α30 1 0 1

α10 1+ α + α2 1 1 1 0

α11 α + α2 + α30 1 1 1

α12 1 + α + α2 + α3 1 1 1 1

α13 1 + α2 + α3 1 0 1 1

α14 1 + α3 1 0 0 1

The Matlab function gftuple(),Simplify or convert the format of elements of a Galois field. That means, you can find the tuple representation of corresponding power representation by gftuple() function.

Example:

X = gftuple(11,4);

Y= gftuple(14,4);

The output is:

X =

0 1 1 1

Y =

1 0 0 1

In Matlab you can do any Galois Field arithmetic using gf() function. Example:

X = gf(6,4) % first argument is integer equivalent of tuple

% representation and 2nd argument is degree m

Y = gf(13,4)

Z = X + Y

The output is:

X = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal) Array elements =

6

Y = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal) Array elements =

13

Z = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

11

Note: The array elements are shown in tuple representation format. To

understand it you may need to convert from tuple representation to power representation from the table.

In the above example we did the addition of α5 + α7, which is α13.

Similarly you ca do multiplication, division or subtraction.

Minimal polynomials

Minimal polynomials of elements in GF(24) generated by p(X) = X4 + X+ 1

are given in following table.

Conjugate Roots Minimal polynomials Ф(X)

0 X

1 X+1

α, α2, α4, α8X4 + X + 1

α3, α6, α9, α12X4 + X3 + X + 1

α5, α10X2 + X + 1

α7, α11, α13, α14X4 + X3 + 1

By using minpol() function in matlab you can genetare the minimal

polynomial for any root. Again using roots() function you can find the

conjugate roots for a particular minimal polynomial.

Example:

m = 4;

e = gf(6,4);

em = minpol(e) %Find minimal polynomial of e. em is in

%GF(2^m)

emr = roots(gf([0 0 1 1 1],m))%Roots of D^4+D^3+1 in GF(2^m)

The output is:

em = GF(2) array.

Array elements =

0 0 1 1 1

相关文档
最新文档