31 #include <m4ri/m4ri.h>
35 #if defined(DLL_EXPORT) && defined(M4RIE_BUILDING_M4RIE)
36 #define M4RIE_DLL_EXPORT __declspec(dllexport)
37 #elif defined(M4RI_USE_DLL) && !defined(M4RIE_BUILDING_M4RIE)
38 #define M4RIE_DLL_EXPORT __declspec(dllimport)
40 #define M4RIE_DLL_EXPORT
43 #define M4RIE_DLL_EXPORT
50 #define M4RIE_MAX_DEGREE 16
70 word (*
inv)(
const gf2e *ff,
const word a);
71 word (*
mul)(
const gf2e *ff,
const word a,
const word b);
103 return ff->
_mul[a][b];
119 static inline word
gf2e_mul(
const gf2e *ff,
const word a,
const word b) {
120 if( ff->
_mul != NULL )
154 m4ri_die(
"degree %d not supported.\n",ff->
degree);
167 word *mul = (word*)m4ri_mm_calloc(1<<16,
sizeof(word));
170 const word mask_w = (1<<w)-1;
175 for(word i=0; i<1<<16; i++) {
178 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;
179 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;
188 mul[i] =
gf2e_mul(ff, a, (i&mask_w));
void gf2e_free(gf2e *ff)
Definition: gf2e.c:56
static word _gf2e_mul_table(const gf2e *ff, const word a, const word b)
a*b in using a table lookups.
Definition: gf2e.h:102
static size_t gf2e_degree_to_w(const gf2e *ff)
Definition: gf2e.h:132
gf2e * gf2e_init(const word minpoly)
Definition: gf2e.c:4
static void gf2e_t16_free(word *mul)
Free multiplication table.
Definition: gf2e.h:201
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:110
static word * gf2e_t16_init(const gf2e *ff, const word a)
Definition: gf2e.h:166
static word gf2e_mul(const gf2e *ff, const word a, const word b)
a*b in .
Definition: gf2e.h:119
M4RIE_DLL_EXPORT const word * irreducible_polynomials[17]
all Irreducible polynomials over GF(2) up to degree 16.
Definition: gf2e.c:85
static word gf2e_inv(const gf2e *ff, word a)
a^(-1) % minpoly
Definition: gf2e.h:94
int deg_t
Definition: gf2x.h:37
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 gf2x_invmod(word a, word b, const deg_t d)
a^(-1) % b with deg(a), deg(b) <= d.
Definition: gf2x.h:152
deg_t degree
Definition: gf2e.h:63
word ** _mul
Definition: gf2e.h:68
word minpoly
Definition: gf2e.h:64
word * red
Definition: gf2e.h:67
word(* inv)(const gf2e *ff, const word a)
Definition: gf2e.h:70
word * pow_gen
Definition: gf2e.h:66
word(* mul)(const gf2e *ff, const word a, const word b)
Definition: gf2e.h:71