Main Content

gfdiv

Divide elements of Galois field

Description

quot = gfdiv(b,a) divides b by a in GF(2) element-by-element. Each entry in a and b represents an element of GF(2).

example

quot = gfdiv(b,a,p) divides b by a in GF(p) and returns the quotient. p is a prime number. If a and b are matrices of the same size, the function treats each element independently. All entries of b, a, and quot are between 0 and p-1.

quot = gfdiv(b,a,field) divides b by a in GF(pm) and returns the quotient. p is a prime number and m is a positive integer. If a and b are matrices of the same size, then the function treats each element independently. All entries of b, a, and quot are the exponential formats of elements of GF(pm) relative to some primitive element of GF(pm). field is the matrix listing all elements of GF(pm), arranged relative to the same primitive element. See Representing Elements of Galois Fields for an explanation of these formats.

Examples

collapse all

Find inverses of nonzero elements of GF(5).

p = 5;
b = ones(p-1,1);
a = (1:p-1)';
quot1 = gfdiv(b,a,p);
disp('Inverses in GF(5):')
Inverses in GF(5):
disp('element  inverse')
element  inverse
disp([a, quot1])
     1     1
     2     3
     3     2
     4     4

Find inverses of nonzero elements of GF(25).

m = 2;
field = gftuple((-1:p^m-2)',m,p);
b = zeros(p^m-1,1); % Numerator is zero since 1 = alpha^0.
a = (0:p^m-2)';
quot2 = gfdiv(b,a,field);
disp('Inverses in GF(25), expressed in EXPONENTIAL FORMAT with')
Inverses in GF(25), expressed in EXPONENTIAL FORMAT with
disp('respect to a root of the default primitive polynomial:')
respect to a root of the default primitive polynomial:
disp('element  inverse')
element  inverse
disp([a, quot2])
     0     0
     1    23
     2    22
     3    21
     4    20
     5    19
     6    18
     7    17
     8    16
     9    15
    10    14
    11    13
    12    12
    13    11
    14    10
    15     9
    16     8
    17     7
    18     6
    19     5
    20     4
    21     3
    22     2
    23     1

Input Arguments

collapse all

Galois field polynomial, specified as a row vector, character vector, or string. b can be either a Representation of Polynomials in Communications Toolbox or numeric vector.

a and b must both be GF(p) polynomials or GF(pm) polynomials, where p is prime. The value of p is as specified when included, 2 when omitted, or implied when field is specified.

Example: '1 + x' is a polynomial in GF(24) expressed as a character vector.

Data Types: double | char | string

Galois field polynomial, specified as a row vector, character vector, or string. a can be either a Representation of Polynomials in Communications Toolbox or numeric vector.

a and b must both be GF(p) polynomials or GF(pm) polynomials, where p is prime. The value of p is as specified when included, 2 when omitted, or implied when field is specified.

Example: [1 2 3 4] is the polynomial 1+2x+3x2+4x3 in GF(5) expressed as a row vector.

Data Types: double | char | string

Prime number, specified as a scalar prime number.

Data Types: double

m-tuple of all elements in GF(pm), specified as a matrix. field is the matrix listing all elements of GF(pm), arranged relative to the same primitive element. To generate the m-tuple of all elements in GF(pm), use

field =gftuple([-1:p^m-2]',m,p)
where m is a positive integer. The coefficients, specified in exponential format, represent the field elements in GF(pm). For an explanation of these formats, see Representing Elements of Galois Fields.

Data Types: double

Output Arguments

collapse all

Galois field polynomial, returned as a row vector of the polynomial coefficients in order of ascending powers.

Version History

Introduced before R2006a