<< gf_check_field Fields gf_degree >>

Galois Fields >> Galois Fields > Fields > gf_create_field

gf_create_field

Creates the finite field GF(p^n) from a primitive polynomial

Syntax

F = gf_create_field(p, n)
F = gf_create_field(p, n, f)

Arguments

p

Prime number: the characteristic of the field, at most 2^20.

n

Degree of the field over GF(p): an integer from 1 to 20, with p^n ≤ 2^20.

f

Primitive polynomial of degree n over GF(p): a row of n + 1 integer coefficients in 0 .. p-1, constant term first, with a non-zero last coefficient. It does not need to be monic. When it is omitted, the polynomial returned by gf_default_primitive_polynomial is used.

F

The field: list(p, n, f, elements).

  • F(1) is p and F(2) is n.

  • F(3) is the primitive polynomial (n + 1 coefficients, constant term first).

  • F(4) is the table of all the elements. For n = 1 it is the row 0:p-1. For n > 1 it is a p^n × n matrix: row 1 is the zero element and row k + 2 is α^k, α being a root of f.

Description

gf_create_field builds the field of order p^n used by the other functions of the toolbox.

The polynomial f must be primitive, not only irreducible: its roots must generate the multiplicative group of the field, so that every non-zero element is a power of α. gf_is_primitive_polynomial tests this, and gf_primitive_polynomials lists all the monic primitive polynomials of a given degree. An error is raised when f is not primitive.

For n = 1, f has degree 1 and its root -f(1)/f(2) is a primitive root modulo p.

The element table is computed once, when the field is created. It has p^n rows of n doubles.

Examples

// GF(16) with the default primitive polynomial 1 + x + x^4
F = gf_create_field(2, 4);
F(3)              // [1 1 0 0 1]
F(4)(1:6, :)      // 0, 1, alpha, alpha^2, alpha^3, alpha^4 = 1 + alpha

// The same field built from another primitive polynomial: 1 + x^3 + x^4
G = gf_create_field(2, 4, [1 0 0 1 1]);

// 1 + x + x^2 + x^3 + x^4 is irreducible but not primitive
try
    gf_create_field(2, 4, [1 1 1 1 1]);
catch
    disp(lasterror())
end

// The prime field GF(7); its default polynomial is x - 3 = x + 4
P = gf_create_field(7, 1);
P(3)              // [4 1]

See also

History

VersionDescription
2.0.0

Refactoring of the function/toolbox. A default primitive polynomial is now used for any n (it was only available for n = 1). Invalid arguments raise errors.


Report an issue
<< gf_check_field Fields gf_degree >>