[Previous] [Up] [Next]

A Tour of NTL: Examples: Extension Rings and Fields


NTL also supports extension rings and fields over finite fields, and polynomial arithmetic over such extensions. Here is a little program that illustrates this.

#include <NTL/ZZ_pXFactoring.h>
#include <NTL/ZZ_pEX.h>

NTL_CLIENT

int main()
{
   ZZ_p::init(to_ZZ(17)); // define GF(17)

   ZZ_pX P;
   BuildIrred(P, 10); // generate an irreducible polynomial P
                      // of degree 10 over GF(17)

   ZZ_pE::init(P); // define GF(17^10)

   ZZ_pEX f, g, h;  // declare polynomials over GF(17^10)

   random(f, 20);  // f is a random, monic polynomial of degree 20
   SetCoeff(f, 20);

   random(h, 20); // h is a random polynomial of degree less than 20

   g = MinPolyMod(h, f); // compute the minimum polynomial of h modulo f

   if (g == 0) Error("oops (1)"); // check that g != 0

   if (CompMod(g, h, f) != 0) // check that g(h) = 0 mod f
      Error("oops (2)");
}

This example illustrates building extension rings over ZZ_p. One can also use zz_p and GF2 as base classes; the syntax is exactly the same.

See ZZ_pE.txt for the basics of the extension ring ZZ_pE over ZZ_p. Also see ZZ_pEX.txt for polynomial arithmetic over ZZ_pE, and ZZ_pEXFactoring.txt for factoring routines over ZZ_pE. See vec_ZZ_pE.txt for vectors over ZZ_pE, and mat_ZZ_pE.txt for matrices over ZZ_pE.

See lzz_pE.txt for the basics of the extension ring zz_pE over zz_p. Also see lzz_pEX.txt for polynomial arithmetic over zz_pE, and lzz_pEXFactoring.txt for factoring routines over zz_pE. See vec_lzz_pE.txt for vectors over zz_pE, and mat_lzz_pE.txt for matrices over zz_pE.

See GF2E.txt for the basics of the extension ring GF2E over GF2. Also see GF2EX.txt for polynomial arithmetic over GF2E, and GF2EXFactoring.txt for factoring routines over GF2E. See vec_GF2E.txt for vectors over GF2E, and mat_GF2E.txt for matrices over GF2E.

[Previous] [Up] [Next]