Go to the first, previous, next, last section, table of contents.

### `setmod_ff`

`setmod_ff([p|defpoly2])`
`setmod_ff([defpolyp,p])`
`setmod_ff([p,n])`
  :: Sets/Gets the current base fields.

return
  number or polynomial
p
  prime
defpoly2
  univariate polynomial irreducible over GF(2)
defpolyp
  univariate polynomial irreducible over GF(p)
n
  the extension degree

- If the argument is a non-negative integer p, GF(p) is set as the current base field.
- If the argument is a polynomial defpoly2, GF(2^deg(defpoly2 mod 2)) = GF(2)[t]/(defpoly2(t) mod2) is set as the current base field.
- If the arguments are a polynomial defpolyp and a prime p, GF(p^deg(defpolyp)) = GF(p)[t]/(defpolyp(t)) is set as the current base field.
- If the arguments are a prime p and an extension degree n, GF(p^n) is set as the current base field. p^n must be less than 2^29 and if p is greater than or equal to 2^14, then n must be equal to 1.
- If no argument is specified, the modulus indicating the current base field is returned. If the current base field is GF(p), p is returned. If it is GF(2^n), the defining polynomial is returned. If it is GF(p^n) defined by `setmod_ff(defpoly,p)`, [defpolyp,p] is returned. If it is GF(p^n) defined by `setmod_ff(p,n)`, [p,defpoly,prim_elem] is returned. Here, defpoly is the defining polynomial of the n-th extension, and prim_elem is the generator of the multiplicative group of GF(p^n).
- Any irreducible univariate polynomial over GF(2) is available to set GF(2^n). However the use of `defpoly_mod2()` is recommended for efficiency.

    [174] defpoly_mod2(100);
    x^100+x^15+1
    [175] setmod_ff(@@);
    x^100+x^15+1
    [176] setmod_ff();
    x^100+x^15+1
    [177] setmod_ff(x^4+x+1,547);
    [1*x^4+1*x+1,547]
    [178] setmod_ff(2,5);
    [2,x^5+x^2+1,x]

`References`
  section `defpoly_mod2`

Go to the first, previous, next, last section, table of contents.