]>
git.proxmox.com Git - ceph.git/blob - ceph/src/erasure-code/jerasure/gf-complete/examples/gf_example_5.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 * Demonstrating altmap and extract_word
18 #include "gf_complete.h"
23 fprintf(stderr
, "usage: gf_example_5\n");
27 int main(int argc
, char **argv
)
33 if (gf_init_hard(&gf
, 16, GF_MULT_SPLIT_TABLE
, GF_REGION_ALTMAP
, GF_DIVIDE_DEFAULT
,
34 0, 16, 4, NULL
, NULL
) == 0) {
35 fprintf(stderr
, "gf_init_hard failed\n");
39 a
= (uint16_t *) malloc(200);
40 b
= (uint16_t *) malloc(200);
47 for (i
= 0; i
< 30; i
++) a
[i
] = MOA_Random_W(16, 1);
49 gf
.multiply_region
.w32(&gf
, a
, b
, 0x1234, 30*2, 0);
51 printf("a: 0x%lx b: 0x%lx\n", (unsigned long) a
, (unsigned long) b
);
53 for (i
= 0; i
< 30; i
+= 10) {
56 for (j
= 0; j
< 10; j
++) printf(" %4d", i
+j
);
60 for (j
= 0; j
< 10; j
++) printf(" %04x", a
[i
+j
]);
64 for (j
= 0; j
< 10; j
++) printf(" %04x", b
[i
+j
]);
69 for (i
= 0; i
< 15; i
++) {
70 printf("Word %2d: 0x%04x * 0x1234 = 0x%04x ", i
,
71 gf
.extract_word
.w32(&gf
, a
, 30*2, i
),
72 gf
.extract_word
.w32(&gf
, b
, 30*2, i
));
73 printf("Word %2d: 0x%04x * 0x1234 = 0x%04x\n", i
+15,
74 gf
.extract_word
.w32(&gf
, a
, 30*2, i
+15),
75 gf
.extract_word
.w32(&gf
, b
, 30*2, i
+15));