<< gf_is_prime Integer utilities

Galois Fields >> Galois Fields > Integer utilities > gf_mod

gf_mod

Non-negative remainder of integers modulo m

Syntax

r = gf_mod(x, m)

Arguments

x

Matrix of integers, positive or negative, smaller than 2^53 in absolute value.

m

Modulus: a positive integer scalar.

r

Matrix of the same size as x, with entries in 0 .. m-1.

Description

gf_mod(x, m) returns the remainder of each entry of x modulo m, always in 0 .. m-1. This is the representative in GF(p) of an integer when m = p, so it converts arbitrary integers to valid coefficients for the other functions of the toolbox.

Scilab's modulo keeps the sign of x for negative values; gf_mod gives the same result as pmodulo.

Examples

gf_mod([-7 -1 0 4 12], 5)      // [3 4 0 4 2]
modulo([-7 -1 0 4 12], 5)      // [-2 -1 0 4 2], for comparison

// The element -alpha of GF(3^2), as valid coefficients
gf_mod(-[0 1], 3)              // [0 2]

See also

History

VersionDescription
2.0.0

Refactoring of the function/toolbox.


Report an issue
<< gf_is_prime Integer utilities