9 #ifndef M4RIE_MZD_POLY_H
10 #define M4RIE_MZD_POLY_H
31 #include <m4ri/m4ri.h>
61 _mzd_ptr_add(C->
x+offset, (
const mzd_t**)A->
x, (
const mzd_t**)B->
x, A->
depth);
92 A->
x = (mzd_t**)m4ri_mm_malloc(
sizeof(mzd_t*)*(d+1));
98 for(
int i=0; i<A->
depth; i++)
99 A->
x[i] = mzd_init(m,n);
112 for(
int i=0; i<A->
depth; i++)
128 if (new_depth < A->depth) {
129 for(
int i=new_depth; i<A->
depth; i++) {
134 for(
int i=A->
depth; i<new_depth; i++) {
138 A->
depth = new_depth;
156 for(
unsigned int i=0; i<A->
depth; i++) {
157 for(
unsigned int j=0; j<B->
depth; j++) {
158 mzd_addmul(C->
x[i+j], A->
x[i], B->
x[j], 0);
182 m4ri_die(
"depth 0: seriously?");
183 case 1: mzd_addmul(C->
x[0], A->
x[0], B->
x[0], 0);
break;
185 case 3: _mzd_ptr_addmul_karatsuba3(NULL, C->
x, (
const mzd_t**)A->
x, (
const mzd_t**)B->
x);
break;
186 case 4: _mzd_ptr_addmul_karatsuba4(NULL, C->
x, (
const mzd_t**)A->
x, (
const mzd_t**)B->
x);
break;
187 case 5: _mzd_ptr_addmul_karatsuba5(NULL, C->
x, (
const mzd_t**)A->
x, (
const mzd_t**)B->
x);
break;
188 case 6: _mzd_ptr_addmul_karatsuba6(NULL, C->
x, (
const mzd_t**)A->
x, (
const mzd_t**)B->
x);
break;
189 case 7: _mzd_ptr_addmul_karatsuba7(NULL, C->
x, (
const mzd_t**)A->
x, (
const mzd_t**)B->
x);
break;
190 case 8: _mzd_ptr_addmul_karatsuba8(NULL, C->
x, (
const mzd_t**)A->
x, (
const mzd_t**)B->
x);
break;
191 case 9: _mzd_ptr_addmul_karatsuba9(NULL, C->
x, (
const mzd_t**)A->
x, (
const mzd_t**)B->
x);
break;
192 case 10: _mzd_ptr_addmul_karatsuba10(NULL, C->
x, (
const mzd_t**)A->
x, (
const mzd_t**)B->
x);
break;
193 case 11: _mzd_ptr_addmul_karatsuba11(NULL, C->
x, (
const mzd_t**)A->
x, (
const mzd_t**)B->
x);
break;
194 case 12: _mzd_ptr_addmul_karatsuba12(NULL, C->
x, (
const mzd_t**)A->
x, (
const mzd_t**)B->
x);
break;
195 case 13: _mzd_ptr_addmul_karatsuba13(NULL, C->
x, (
const mzd_t**)A->
x, (
const mzd_t**)B->
x);
break;
196 case 14: _mzd_ptr_addmul_karatsuba14(NULL, C->
x, (
const mzd_t**)A->
x, (
const mzd_t**)B->
x);
break;
197 case 15: _mzd_ptr_addmul_karatsuba15(NULL, C->
x, (
const mzd_t**)A->
x, (
const mzd_t**)B->
x);
break;
198 case 16: _mzd_ptr_addmul_karatsuba16(NULL, C->
x, (
const mzd_t**)A->
x, (
const mzd_t**)B->
x);
break;
200 m4ri_die(
"Not implemented\n");
211 assert(f->
F->ncols == A->
depth && f->
G->ncols == B->
depth);
260 for(
int i=0; i<A->
depth; i++)
261 r |= mzd_cmp(A->
x[i],B->
x[i]);
276 for(
int i=0; i<A->
depth; i++)
277 mzd_randomize(A->
x[i]);
280 #endif //M4RIE_MZD_POLY_H
will be the data type for matrices over [x] in the future
Definition: mzd_poly.h:40
static mzd_poly_t * _mzd_poly_addmul_blm(mzd_poly_t *C, mzd_poly_t *A, mzd_poly_t *B, const blm_t *f)
C += A*B by applying the bilinear maps f, i.e. f->H*((f->F*A) x (f->G*B)).
Definition: mzd_poly.h:209
Bilinear Maps on Matrices over GF(2).
Definition: blm.h:51
mzd_t * F
Definition: blm.h:55
rci_t ncols
Definition: mzd_poly.h:43
int deg_t
Definition: gf2x.h:37
blm_t * blm_init_crt(const gf2e *ff, const deg_t f_ncols, const deg_t g_ncols, const int *p, int djb)
Definition: blm.c:487
static mzd_poly_t * mzd_poly_add(mzd_poly_t *C, const mzd_poly_t *A, const mzd_poly_t *B)
C += (A+B)
Definition: mzd_poly.h:75
rci_t nrows
Definition: mzd_poly.h:42
mzd_poly_t * _mzd_poly_addmul_ext1(mzd_poly_t *C, mzd_poly_t *A, mzd_poly_t *B)
C += A*B using arithmetic in GF(2^log2(d)) if C has degree d.
Definition: mzd_poly.c:12
static void _mzd_ptr_apply_blm(mzd_t **X, const mzd_t **A, const mzd_t **B, const blm_t *f)
Apply f on A and B, writing to X.
Definition: blm.h:153
static mzd_poly_t * _mzd_poly_adapt_depth(mzd_poly_t *A, const deg_t new_depth)
change depth of A to new_depth.
Definition: mzd_poly.h:127
int * crt_init(const deg_t f_len, const deg_t g_len)
Definition: blm.c:105
mzd_t ** x
Definition: mzd_poly.h:41
static mzd_poly_t * _mzd_poly_addmul_crt(mzd_poly_t *C, mzd_poly_t *A, mzd_poly_t *B)
C += A*B using the Chinese Remainder Theorem.
Definition: mzd_poly.h:225
void blm_free(blm_t *f)
Definition: blm.c:611
mzd_t * G
Definition: blm.h:58
static int mzd_poly_cmp(mzd_poly_t *A, mzd_poly_t *B)
Return -1,0,1 if if A < B, A == B or A > B respectively.
Definition: mzd_poly.h:252
static mzd_poly_t * mzd_poly_init(const deg_t d, const rci_t m, const rci_t n)
Create a new polynomial of degree d with m x n matrices as coefficients.
Definition: mzd_poly.h:90
static void mzd_poly_free(mzd_poly_t *A)
Free polynomial A.
Definition: mzd_poly.h:111
deg_t depth
Definition: mzd_poly.h:44
void _mzd_ptr_addmul_karatsuba2(const gf2e *ff, mzd_t **X, const mzd_t **A, const mzd_t **B)
over using 3 multiplications over and 2 temporary matrices.
Definition: karatsuba.c:4
static mzd_poly_t * _mzd_poly_add(mzd_poly_t *C, const mzd_poly_t *A, const mzd_poly_t *B, unsigned int offset)
C += (A+B)*x^offset.
Definition: mzd_poly.h:60
Bilinear Maps on Matrices over GF(2).
static void mzd_poly_randomize(mzd_poly_t *A)
Fill matrix A with random elements.
Definition: mzd_poly.h:275
static mzd_poly_t * _mzd_poly_addmul_naive(mzd_poly_t *C, const mzd_poly_t *A, const mzd_poly_t *B)
C += A*B using naive polynomial multiplication.
Definition: mzd_poly.h:152
static mzd_poly_t * _mzd_poly_addmul_karatsubs_balanced(mzd_poly_t *C, const mzd_poly_t *A, const mzd_poly_t *B)
C += A*B using Karatsuba multiplication on balanced inputs.
Definition: mzd_poly.h:175