<< gf_are_equal Element arithmetic gf_is_one >>

Galois Fields >> Galois Fields > Element arithmetic > gf_divide

gf_divide

Divides elements of a finite field

Syntax

c = gf_divide(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_divide(F, a, b) computes a / b = a × b^(-1) in the field F. An error is raised if any divisor is zero.

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);
c = gf_divide(F, [0 1 0 0], [1 1 0 0])   // alpha / alpha^4 = alpha^12 = [1 1 1 1]
gf_to_exponential(F, c)                  // 12

// Inverses of the non-zero elements of GF(7)
P = gf_create_field(7, 1);
gf_divide(P, 1, 1:6)                     // [1 4 5 2 3 6]

try
    gf_divide(F, [0 1 0 0], [0 0 0 0]);
catch
    disp(lasterror())                    // gf_divide: Division by zero.
end

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_are_equal Element arithmetic gf_is_one >>