31 #include <m4ri/m4ri.h>
32 #include <m4rie/gf2x.h>
38 #define M4RIE_MAX_DEGREE 16
58 word (*
inv)(
const gf2e *ff,
const word a);
59 word (*
mul)(
const gf2e *ff,
const word a,
const word b);
91 return ff->
_mul[a][b];
107 static inline word
gf2e_mul(
const gf2e *ff,
const word a,
const word b) {
108 if( ff->
_mul != NULL )
142 m4ri_die(
"degree %d not supported.\n",ff->
degree);
155 word *mul = (word*)m4ri_mm_calloc(1<<16,
sizeof(word));
158 const word mask_w = (1<<w)-1;
163 for(word i=0; i<1<<16; i++) {
166 mul[i] =
gf2e_mul(ff, a, ((i>>0)&mask_w))<<0 |
gf2e_mul(ff, a, ((i>> 2)&mask_w))<< 2 |
gf2e_mul(ff, a, ((i>> 4)&mask_w))<< 4 |
gf2e_mul(ff, a, ((i>> 6)&mask_w))<< 6;
167 mul[i] |=
gf2e_mul(ff, a, ((i>>8)&mask_w))<<8 |
gf2e_mul(ff, a, ((i>>10)&mask_w))<<10 |
gf2e_mul(ff, a, ((i>>12)&mask_w))<<12 |
gf2e_mul(ff, a, ((i>>14)&mask_w))<<14;
176 mul[i] =
gf2e_mul(ff, a, (i&mask_w));
199 #endif //M4RIE_GF2E_H
static void gf2e_t16_free(word *mul)
Free multiplication table.
Definition: gf2e.h:189
int deg_t
Definition: gf2x.h:37
word(* mul)(const gf2e *ff, const word a, const word b)
Definition: gf2e.h:59
static size_t gf2e_degree_to_w(const gf2e *ff)
Definition: gf2e.h:120
word ** _mul
Definition: gf2e.h:56
deg_t degree
Definition: gf2e.h:51
static word * gf2e_t16_init(const gf2e *ff, const word a)
Definition: gf2e.h:154
void gf2e_free(gf2e *ff)
Definition: gf2e.c:56
static word gf2e_inv(const gf2e *ff, word a)
a^(-1) % minpoly
Definition: gf2e.h:82
word * red
Definition: gf2e.h:55
static word _gf2e_mul_arith(const gf2e *ff, const word a, const word b)
a*b in using a gf2x_mul() lookups.
Definition: gf2e.h:98
const word * irreducible_polynomials[17]
all Irreducible polynomials over GF(2) up to degree 16.
Definition: gf2e.c:84
gf2e * gf2e_init(const word minpoly)
Definition: gf2e.c:4
word(* inv)(const gf2e *ff, const word a)
Definition: gf2e.h:58
static word _gf2e_mul_table(const gf2e *ff, const word a, const word b)
a*b in using a table lookups.
Definition: gf2e.h:90
word minpoly
Definition: gf2e.h:52
static word gf2x_invmod(word a, word b, const deg_t d)
a^(-1) % b with deg(a), deg(b) <= d.
Definition: gf2x.h:152
word * pow_gen
Definition: gf2e.h:54
static word gf2x_mul(const word a, const word b, deg_t d)
a*b in with deg(a) and deg(b) < d.
Definition: gf2x.h:43
static word gf2e_mul(const gf2e *ff, const word a, const word b)
a*b in .
Definition: gf2e.h:107