]>
git.proxmox.com Git - ceph.git/blob - ceph/src/erasure-code/jerasure/gf-complete/examples/gf_example_3.c
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 * Identical to example_2 except it works in GF(2^64)
18 #include "gf_complete.h"
23 fprintf(stderr
, "usage: gf_example_3\n");
27 int main(int argc
, char **argv
)
34 if (argc
!= 1) usage(NULL
);
36 /* Get two random numbers in a and b */
42 /* Create the proper instance of the gf_t object using defaults: */
44 gf_init_easy(&gf
, 64);
46 /* And multiply a and b using the galois field: */
48 c
= gf
.multiply
.w64(&gf
, a
, b
);
49 printf("%llx * %llx = %llx\n", (long long unsigned int) a
, (long long unsigned int) b
, (long long unsigned int) c
);
51 /* Divide the product by a and b */
53 printf("%llx / %llx = %llx\n", (long long unsigned int) c
, (long long unsigned int) a
, (long long unsigned int) gf
.divide
.w64(&gf
, c
, a
));
54 printf("%llx / %llx = %llx\n", (long long unsigned int) c
, (long long unsigned int) b
, (long long unsigned int) gf
.divide
.w64(&gf
, c
, b
));
56 r1
= (uint64_t *) malloc(32);
57 r2
= (uint64_t *) malloc(32);
61 for (i
= 1; i
< 4; i
++) r1
[i
] = MOA_Random_64();
63 gf
.multiply_region
.w64(&gf
, r1
, r2
, a
, 32, 0);
65 printf("\nmultiply_region by %llx\n\n", (long long unsigned int) a
);
66 printf("R1 (the source): ");
67 for (i
= 0; i
< 4; i
++) printf(" %016llx", (long long unsigned int) r1
[i
]);
69 printf("\nR2 (the product): ");
70 for (i
= 0; i
< 4; i
++) printf(" %016llx", (long long unsigned int) r2
[i
]);