2 * GF-Complete: A Comprehensive Open Source Library for Galois Field Arithmetic
3 * James S. Plank, Ethan L. Miller, Kevin M. Greenan,
4 * Benjamin A. Arnold, John A. Burnum, Adam W. Disney, Allen C. McBride.
8 * Demonstrates using the procedures for examples in GF(2^w) for w <= 32.
18 #include "gf_complete.h"
23 fprintf(stderr, "usage: gf_example_1 w - w must be between 1 and 32\n");
27 int main(int argc, char **argv)
33 if (argc != 2) usage(NULL);
35 if (w <= 0 || w > 32) usage("Bad w");
37 /* Get two random numbers in a and b */
40 a = MOA_Random_W(w, 0);
41 b = MOA_Random_W(w, 0);
43 /* Create the proper instance of the gf_t object using defaults: */
47 /* And multiply a and b using the galois field: */
49 c = gf.multiply.w32(&gf, a, b);
50 printf("%u * %u = %u\n", a, b, c);
52 /* Divide the product by a and b */
54 printf("%u / %u = %u\n", c, a, gf.divide.w32(&gf, c, a));
55 printf("%u / %u = %u\n", c, b, gf.divide.w32(&gf, c, b));