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 * Demonstrating extract_word and Cauchy
18 #include "gf_complete.h"
23 fprintf(stderr, "usage: gf_example_7\n");
27 int main(int argc, char **argv)
33 if (gf_init_hard(&gf, 3, GF_MULT_TABLE, GF_REGION_CAUCHY, GF_DIVIDE_DEFAULT, 0, 0, 0, NULL, NULL) == 0) {
34 fprintf(stderr, "gf_init_hard failed\n");
38 a = (uint8_t *) malloc(3);
39 b = (uint8_t *) malloc(3);
43 for (i = 0; i < 3; i++) a[i] = MOA_Random_W(8, 1);
45 gf.multiply_region.w32(&gf, a, b, 5, 3, 0);
47 printf("a: 0x%lx b: 0x%lx\n", (unsigned long) a, (unsigned long) b);
50 printf("a: 0x%02x 0x%02x 0x%02x\n", a[0], a[1], a[2]);
51 printf("b: 0x%02x 0x%02x 0x%02x\n", b[0], b[1], b[2]);
55 for (i = 0; i < 3; i++) {
57 for (j = 7; j >= 0; j--) printf("%c", (a[i] & (1 << j)) ? '1' : '0');
62 for (i = 0; i < 3; i++) {
64 for (j = 7; j >= 0; j--) printf("%c", (b[i] & (1 << j)) ? '1' : '0');
69 for (i = 0; i < 8; i++) {
70 printf("Word %2d: %d * 5 = %d\n", i,
71 gf.extract_word.w32(&gf, a, 3, i),
72 gf.extract_word.w32(&gf, b, 3, i));