<< gf_poly_add Polynomials over GF(p) gf_poly_multiply >>

Galois Fields >> Galois Fields > Polynomials over GF(p) > gf_poly_divide

gf_poly_divide

Division with remainder of polynomials over GF(p)

Syntax

r = gf_poly_divide(a, b, p)
[r, q] = gf_poly_divide(a, b, p)

Arguments

a

Dividend. Polynomial over GF(p): a row vector of integer coefficients in 0 .. p-1, constant term first. For instance [1 0 1 1] is 1 + x² + x³.

b

Divisor, not zero. Same form as a; the two can have different lengths.

p

Prime number: the characteristic of the field.

r

Remainder, of degree lower than b. Result as a row of coefficients, constant term first, trimmed to its degree (no trailing zeros). The zero polynomial is returned as 0.

q

Quotient, in the same form as r.

Description

gf_poly_divide(a, b, p) divides a by b over GF(p): it finds q and r such that a = q × b + r with deg r < deg b. The remainder is returned first; the quotient is the optional second output.

b does not need to be monic. An error is raised if b is the zero polynomial.

Examples

// (1 + x^2 + x^3) / (1 + x) over GF(2)
[r, q] = gf_poly_divide([1 0 1 1], [1 1], 2)   // r = 1, q = [0 0 1] (x^2)

// x^2 + 2 = (x + 2)(x + 1) over GF(3)
[r, q] = gf_poly_divide([2 0 1], [1 1], 3)     // r = 0, q = [2 1]

// The dividend has lower degree than the divisor
[r, q] = gf_poly_divide([1 1], [1 0 1], 2)     // r = [1 1], q = 0

See also

History

VersionDescription
2.0.0

Refactoring of the function/toolbox.


Report an issue
<< gf_poly_add Polynomials over GF(p) gf_poly_multiply >>