<< gf_is_zero Element arithmetic gf_power >>

Galois Fields >> Galois Fields > Element arithmetic > gf_multiply

gf_multiply

Multiplies elements of a finite field

Syntax

c = gf_multiply(F, a, b)

Arguments

F

A field created by gf_create_field.

a, b

Field elements.

  • In GF(p) (n = 1): a matrix of integers in 0 .. p-1, of any size.

  • In GF(p^n), n > 1: a matrix with n columns, one element per row. Each row holds the coefficients of a polynomial in α of degree < n, constant term first.

Coefficients outside 0 .. p-1 are rejected; reduce them first with gf_mod if needed.

c

The result, in the same form as the operands.

Description

gf_multiply(F, a, b) computes a × b in the field F. For n > 1 the operands are multiplied as polynomials in α and the product is reduced modulo the field's primitive polynomial. In exponential notation, α^i × α^j = α^((i + j) mod (p^n - 1)).

Both operands must contain the same number of elements, or one of them must be a single element; a single element is combined with each element of the other operand. The result has the shape of the operand that holds several elements (of a when both have the same number).

Examples

F = gf_create_field(2, 4);
a = [0 1 0 0];                    // alpha
b = [1 1 0 0];                    // 1 + alpha = alpha^4
c = gf_multiply(F, a, b)          // [0 1 1 0]
gf_to_exponential(F, c)           // 5

// alpha times alpha^0, alpha^1, alpha^2
gf_multiply(F, F(4)(2:4, :), a)

P = gf_create_field(7, 1);
gf_multiply(P, [3 4 5], 6)        // [4 3 2]

See also

History

VersionDescription
2.0.0

Refactoring of the function/toolbox. Accepts several elements at once; invalid arguments raise errors.


Report an issue
<< gf_is_zero Element arithmetic gf_power >>