flint-sys 0.9.0

Bindings to the FLINT C library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
/*
    Copyright (C) 2020 Daniel Schultz

    This file is part of FLINT.

    FLINT is free software: you can redistribute it and/or modify it under
    the terms of the GNU Lesser General Public License (LGPL) as published
    by the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.  See <https://www.gnu.org/licenses/>.
*/

#ifndef FQ_ZECH_MPOLY_FACTOR_H
#define FQ_ZECH_MPOLY_FACTOR_H

#ifdef FQ_ZECH_MPOLY_FACTOR_INLINES_C
#define FQ_ZECH_MPOLY_FACTOR_INLINE
#else
#define FQ_ZECH_MPOLY_FACTOR_INLINE static inline
#endif

#include "fq_zech_mpoly.h"

#ifdef __cplusplus
 extern "C" {
#endif

typedef struct
{
    fq_zech_poly_struct * coeffs;
    slong alloc;
    slong length;
} fq_zech_bpoly_struct;

typedef fq_zech_bpoly_struct fq_zech_bpoly_t[1];


typedef struct
{
    fq_zech_bpoly_struct * coeffs;
    slong alloc;
    slong length;
} fq_zech_tpoly_struct;

typedef fq_zech_tpoly_struct fq_zech_tpoly_t[1];


typedef struct
{
    ulong * exps;
    fq_zech_struct * coeffs;
    slong length;
    slong alloc;
} fq_zech_polyu_struct;

typedef fq_zech_polyu_struct fq_zech_polyu_t[1];


typedef struct
{
    fq_zech_poly_struct * coeffs;
    ulong * exps;
    slong length;
    slong alloc;
} fq_zech_polyun_struct;

typedef fq_zech_polyun_struct fq_zech_polyun_t[1];


/*****************************************************************************/

FQ_ZECH_MPOLY_FACTOR_INLINE
void fq_zech_bpoly_init(fq_zech_bpoly_t A, const fq_zech_ctx_t FLINT_UNUSED(ctx))
{
    A->coeffs = NULL;
    A->alloc = 0;
    A->length = 0;
}

void fq_zech_bpoly_clear(fq_zech_bpoly_t A, const fq_zech_ctx_t ctx);

FQ_ZECH_MPOLY_FACTOR_INLINE
void fq_zech_bpoly_swap(fq_zech_bpoly_t A, fq_zech_bpoly_t B, const fq_zech_ctx_t FLINT_UNUSED(ctx))
{
    fq_zech_bpoly_struct t = *A;
    *A = *B;
    *B = t;
}

void fq_zech_bpoly_normalise(fq_zech_bpoly_t A, const fq_zech_ctx_t ctx);

void fq_zech_bpoly_realloc(fq_zech_bpoly_t A, slong len, const fq_zech_ctx_t ctx);

FQ_ZECH_MPOLY_FACTOR_INLINE
void fq_zech_bpoly_fit_length(fq_zech_bpoly_t A, slong len, const fq_zech_ctx_t ctx)
{
    if (len > A->alloc)
        fq_zech_bpoly_realloc(A, len, ctx);
}

FQ_ZECH_MPOLY_FACTOR_INLINE
void fq_zech_bpoly_zero(fq_zech_bpoly_t A, const fq_zech_ctx_t FLINT_UNUSED(ctx))
{
    A->length = 0;
}

FQ_ZECH_MPOLY_FACTOR_INLINE
int fq_zech_bpoly_is_zero(const fq_zech_bpoly_t A, const fq_zech_ctx_t FLINT_UNUSED(ctx))
{
    return A->length == 0;
}

int fq_zech_bpoly_equal(const fq_zech_bpoly_t A, const fq_zech_bpoly_t B, const fq_zech_ctx_t ctx);

void fq_zech_bpoly_get_coeff(fq_zech_t c, const fq_zech_bpoly_t A, slong e0, slong e1, const fq_zech_ctx_t ctx);

FQ_ZECH_MPOLY_FACTOR_INLINE
slong fq_zech_bpoly_degree0(const fq_zech_bpoly_t A, const fq_zech_ctx_t FLINT_UNUSED(ctx))
{
    return A->length - 1;
}

slong fq_zech_bpoly_degree1(const fq_zech_bpoly_t A, const fq_zech_ctx_t FLINT_UNUSED(ctx));

void fq_zech_bpoly_set_poly_var1(fq_zech_bpoly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx);

void fq_zech_bpoly_set_poly_var0(fq_zech_bpoly_t A, const fq_zech_poly_t B, const fq_zech_ctx_t ctx);

void fq_zech_bpoly_print_pretty(const fq_zech_bpoly_t A,
                const char * var0, const char * var1, const fq_zech_ctx_t ctx);

int fq_zech_bpoly_is_canonical(const fq_zech_bpoly_t A, const fq_zech_ctx_t ctx);

int fq_zech_bpoly_fq_equal(
    const fq_zech_bpoly_t A,
    const fq_zech_bpoly_t B,
    const fq_zech_ctx_t ctx);

void fq_zech_bpoly_set_coeff_fq_zech(
    fq_zech_bpoly_t A,
    slong xi,
    slong yi,
    const fq_zech_t c,
    const fq_zech_ctx_t ctx);

void fq_zech_bpoly_set_fq_zech_poly_var0(
    fq_zech_bpoly_t A,
    const fq_zech_poly_t B,
    const fq_zech_ctx_t ctx);

void fq_zech_bpoly_set_fq_zech_poly_var1(
    fq_zech_bpoly_t A,
    const fq_zech_poly_t B,
    const fq_zech_ctx_t ctx);

void fq_zech_bpoly_make_monic(
    fq_zech_bpoly_t A,
    slong order,
    const fq_zech_ctx_t ctx);

void fq_zech_bpoly_mul(
    fq_zech_bpoly_t A,
    const fq_zech_bpoly_t B,
    const fq_zech_bpoly_t C,
    const fq_zech_ctx_t ctx);

void fq_zech_bpoly_mul_series(
    fq_zech_bpoly_t A,
    const fq_zech_bpoly_t B,
    const fq_zech_bpoly_t C,
    slong order,
    const fq_zech_ctx_t ctx);

void fq_zech_bpoly_add(
    fq_zech_bpoly_t A,
    const fq_zech_bpoly_t B,
    const fq_zech_bpoly_t C,
    const fq_zech_ctx_t ctx);

void fq_zech_bpoly_one(
    fq_zech_bpoly_t A,
    const fq_zech_ctx_t ctx);

void fq_zech_bpoly_sub(
    fq_zech_bpoly_t A,
    const fq_zech_bpoly_t B,
    const fq_zech_bpoly_t C,
    const fq_zech_ctx_t ctx);

void fq_zech_bpoly_derivative(
    fq_zech_bpoly_t A,
    const fq_zech_bpoly_t B,
    const fq_zech_ctx_t ctx);

void fq_zech_bpoly_divrem_series(
    fq_zech_bpoly_t Q,
    fq_zech_bpoly_t R,
    const fq_zech_bpoly_t A,
    const fq_zech_bpoly_t B,
    slong order,
    const fq_zech_ctx_t ctx);

int fq_zech_bpoly_divides(
    fq_zech_bpoly_t Q,
    const fq_zech_bpoly_t A,
    const fq_zech_bpoly_t B,
    const fq_zech_ctx_t ctx);

void fq_zech_bpoly_set(
    fq_zech_bpoly_t A,
    const fq_zech_bpoly_t B,
    const fq_zech_ctx_t ctx);

void fq_zech_bpoly_make_primitive(
    fq_zech_poly_t g,
    fq_zech_bpoly_t A,
    const fq_zech_ctx_t ctx);

void fq_zech_bpoly_taylor_shift_var1(
    fq_zech_bpoly_t A,
    const fq_zech_bpoly_t B,
    const fq_zech_t c_,
    const fq_zech_ctx_t ctx);

void fq_zech_bpoly_taylor_shift_var0(
    fq_zech_bpoly_t A,
    const fq_zech_t alpha,
    const fq_zech_ctx_t ctx);

void fq_zech_mpoly_get_fq_zech_bpoly(
    fq_zech_bpoly_t A,
    const fq_zech_mpoly_t B,
    slong varx,
    slong vary,
    const fq_zech_mpoly_ctx_t ctx);

void fq_zech_mpoly_set_fq_zech_bpoly(
    fq_zech_mpoly_t A,
    flint_bitcnt_t Abits,
    const fq_zech_bpoly_t B,
    slong varx,
    slong vary,
    const fq_zech_mpoly_ctx_t ctx);


int fq_zech_bpoly_factor_smprime(
    fq_zech_poly_t c,
    fq_zech_tpoly_t F,
    fq_zech_bpoly_t B,
    int allow_shift,
    const fq_zech_ctx_t ctx);

int fq_zech_bpoly_factor_lgprime(
    fq_zech_poly_t c,
    fq_zech_tpoly_t F,
    fq_zech_bpoly_t B,
    const fq_zech_ctx_t ctx,
    flint_rand_t state);

/*****************************************************************************/

FQ_ZECH_MPOLY_FACTOR_INLINE
void fq_zech_tpoly_init(fq_zech_tpoly_t A, const fq_zech_ctx_t FLINT_UNUSED(ctx))
{
    A->coeffs = NULL;
    A->alloc = 0;
    A->length = 0;
}

FQ_ZECH_MPOLY_FACTOR_INLINE
void fq_zech_tpoly_swap(fq_zech_tpoly_t A, fq_zech_tpoly_t B, const fq_zech_ctx_t FLINT_UNUSED(ctx))
{
    fq_zech_tpoly_struct t = *A;
    *A = *B;
    *B = t;
}

void fq_zech_tpoly_fit_length(fq_zech_tpoly_t A, slong len, const fq_zech_ctx_t ctx);

void fq_zech_tpoly_clear(fq_zech_tpoly_t A, const fq_zech_ctx_t ctx);


/*****************************************************************************/

FQ_ZECH_MPOLY_FACTOR_INLINE
void fq_zech_polyu_init(fq_zech_polyu_t A, const fq_zech_ctx_t FLINT_UNUSED(ctx))
{
    A->coeffs = NULL;
    A->exps = NULL;
    A->length = 0;
    A->alloc = 0;
}

void fq_zech_polyu_clear(fq_zech_polyu_t A, const fq_zech_ctx_t FLINT_UNUSED(ctx));

void fq_zech_polyu_realloc(fq_zech_polyu_t A, slong len, const fq_zech_ctx_t ctx);

FQ_ZECH_MPOLY_FACTOR_INLINE
void fq_zech_polyu_fit_length(fq_zech_polyu_t A, slong len, const fq_zech_ctx_t ctx)
{
    FLINT_ASSERT(A->alloc >= 0);
    if (len > A->alloc)
        fq_zech_polyu_realloc(A, len, ctx);
}

FQ_ZECH_MPOLY_FACTOR_INLINE
void fq_zech_polyu_swap(fq_zech_polyu_t A, fq_zech_polyu_t B, const fq_zech_ctx_t FLINT_UNUSED(ctx))
{
    fq_zech_polyu_struct t = *B;
    *B = *A;
    *A = t;
}

void fq_zech_polyu3_print_pretty(
    const fq_zech_polyu_t A,
    const char * var0,
    const char * var1,
    const char * var2,
    const fq_zech_ctx_t ctx);

void fq_zech_polyu3_degrees(
    slong * deg0,
    slong * deg1,
    slong * deg2,
    const fq_zech_polyu_t A);

int fq_zech_polyu_is_canonical(
    const fq_zech_polyu_t A,
    const fq_zech_ctx_t ctx);

/*****************************************************************************/

FQ_ZECH_MPOLY_FACTOR_INLINE
void fq_zech_polyun_init(fq_zech_polyun_t A, const fq_zech_ctx_t FLINT_UNUSED(ctx))
{
    A->coeffs = NULL;
    A->exps = NULL;
    A->length = 0;
    A->alloc = 0;
}

void fq_zech_polyun_clear(fq_zech_polyun_t A, const fq_zech_ctx_t ctx);

void fq_zech_polyun_realloc(fq_zech_polyun_t A, slong len, const fq_zech_ctx_t ctx);

FQ_ZECH_MPOLY_FACTOR_INLINE
void fq_zech_polyun_fit_length(fq_zech_polyun_t A, slong len, const fq_zech_ctx_t ctx)
{
    if (len > A->alloc)
        fq_zech_polyun_realloc(A, len, ctx);
}

FQ_ZECH_MPOLY_FACTOR_INLINE
void fq_zech_polyun_swap(fq_zech_polyun_t A, fq_zech_polyun_t B, const fq_zech_ctx_t FLINT_UNUSED(ctx))
{
    fq_zech_polyun_struct t = *B;
    *B = *A;
    *A = t;
}

void fq_zech_polyu2n_print_pretty(
    const fq_zech_polyun_t A,
    const char * var0,
    const char * var1,
    const char * varlast,
    const fq_zech_ctx_t ctx);

void fq_zech_polyu3n_print_pretty(
    const fq_zech_polyun_t A,
    const char * var0,
    const char * var1,
    const char * var2,
    const char * varlast,
    const fq_zech_ctx_t ctx);

int fq_zech_polyun_is_canonical(
    const fq_zech_polyun_t A,
    const fq_zech_ctx_t ctx);

/*****************************************************************************/

int fq_zech_mpoly_is_fq_zech_poly(
    const fq_zech_mpoly_t A,
    slong var,
    const fq_zech_mpoly_ctx_t ctx);

int fq_zech_mpoly_get_fq_zech_poly(
    fq_zech_poly_t A,
    const fq_zech_mpoly_t B,
    slong var,
    const fq_zech_mpoly_ctx_t ctx);

void _fq_zech_mpoly_set_fq_zech_poly(
    fq_zech_mpoly_t A,
    flint_bitcnt_t Abits,
    const fq_zech_struct * Bcoeffs,
    slong Blen,
    slong var,
    const fq_zech_mpoly_ctx_t ctx);

void fq_zech_mpoly_set_fq_zech_poly(
    fq_zech_mpoly_t A,
    const fq_zech_poly_t B,
    slong var,
    const fq_zech_mpoly_ctx_t ctx);

/*****************************************************************************/

typedef struct {
    fq_zech_t constant;
    fq_zech_mpoly_struct * poly;
    fmpz * exp;
    slong num;
    slong alloc;
} fq_zech_mpoly_factor_struct;

typedef fq_zech_mpoly_factor_struct fq_zech_mpoly_factor_t[1];

void fq_zech_mpoly_factor_init(fq_zech_mpoly_factor_t f,
                                                const fq_zech_mpoly_ctx_t ctx);

void fq_zech_mpoly_factor_realloc(fq_zech_mpoly_factor_t f,
                                   slong alloc, const fq_zech_mpoly_ctx_t ctx);

void fq_zech_mpoly_factor_fit_length(fq_zech_mpoly_factor_t f,
                                     slong len, const fq_zech_mpoly_ctx_t ctx);

void fq_zech_mpoly_factor_clear(fq_zech_mpoly_factor_t f,
                                                const fq_zech_mpoly_ctx_t ctx);

void fq_zech_mpoly_factor_set(fq_zech_mpoly_factor_t a,
                const fq_zech_mpoly_factor_t b, const fq_zech_mpoly_ctx_t ctx);

void fq_zech_mpoly_factor_print_pretty(const fq_zech_mpoly_factor_t f,
                            const char ** vars, const fq_zech_mpoly_ctx_t ctx);

void fq_zech_mpoly_factor_append_ui(fq_zech_mpoly_factor_t f,
              const fq_zech_mpoly_t A, ulong e, const fq_zech_mpoly_ctx_t ctx);

void fq_zech_mpoly_factor_append_fmpz(fq_zech_mpoly_factor_t f,
       const fq_zech_mpoly_t A, const fmpz_t e, const fq_zech_mpoly_ctx_t ctx);

int fq_zech_mpoly_factor_squarefree(fq_zech_mpoly_factor_t f,
                       const fq_zech_mpoly_t A, const fq_zech_mpoly_ctx_t ctx);

int fq_zech_mpoly_factor(fq_zech_mpoly_factor_t f,
                       const fq_zech_mpoly_t A, const fq_zech_mpoly_ctx_t ctx);

FQ_ZECH_MPOLY_FACTOR_INLINE
void fq_zech_mpoly_factor_swap(fq_zech_mpoly_factor_t A,
                       fq_zech_mpoly_factor_t B, const fq_zech_mpoly_ctx_t FLINT_UNUSED(ctx))
{
   fq_zech_mpoly_factor_struct t = *A;
   *A = *B;
   *B = t;
}

void fq_zech_mpoly_factor_one(fq_zech_mpoly_factor_t a, const fq_zech_mpoly_ctx_t ctx);

int fq_zech_mpoly_factor_expand(fq_zech_mpoly_t A,
                const fq_zech_mpoly_factor_t f, const fq_zech_mpoly_ctx_t ctx);


FQ_ZECH_MPOLY_FACTOR_INLINE
int fq_zech_mpoly_factor_matches(const fq_zech_mpoly_t a, const fq_zech_mpoly_factor_t f, const fq_zech_mpoly_ctx_t ctx)
{
    int matches;
    fq_zech_mpoly_t t;
    fq_zech_mpoly_init(t, ctx);
    fq_zech_mpoly_factor_expand(t, f, ctx);
    matches = fq_zech_mpoly_equal(t, a, ctx);
    fq_zech_mpoly_clear(t, ctx);
    return matches;
}

void _fq_zech_mpoly_get_lead0(
    fq_zech_mpoly_t c,
    const fq_zech_mpoly_t A,
    const fq_zech_mpoly_ctx_t ctx);

void _fq_zech_mpoly_set_lead0(
    fq_zech_mpoly_t A,
    const fq_zech_mpoly_t B,
    const fq_zech_mpoly_t c,
    const fq_zech_mpoly_ctx_t ctx);

/*****************************************************************************/

typedef struct
{
    fq_zech_mpoly_struct * coeffs;
    slong alloc;
    slong length;
} fq_zech_mpolyv_struct;

typedef fq_zech_mpolyv_struct fq_zech_mpolyv_t[1];

FQ_ZECH_MPOLY_FACTOR_INLINE
void fq_zech_mpolyv_init(fq_zech_mpolyv_t A, const fq_zech_mpoly_ctx_t FLINT_UNUSED(ctx))
{
    A->coeffs = NULL;
    A->alloc = 0;
    A->length = 0;
}

FQ_ZECH_MPOLY_FACTOR_INLINE
void fq_zech_mpolyv_swap(fq_zech_mpolyv_t A, fq_zech_mpolyv_t B,
                                                 const fq_zech_mpoly_ctx_t FLINT_UNUSED(ctx))
{
   fq_zech_mpolyv_struct t = *A;
   *A = *B;
   *B = t;
}

void fq_zech_mpolyv_clear(fq_zech_mpolyv_t A,
                                                const fq_zech_mpoly_ctx_t ctx);

void fq_zech_mpolyv_print_pretty(const fq_zech_mpolyv_t poly,
                               const char ** x, const fq_zech_mpoly_ctx_t ctx);

void fq_zech_mpolyv_fit_length(fq_zech_mpolyv_t A, slong length,
                                                const fq_zech_mpoly_ctx_t ctx);

void fq_zech_mpolyv_set_coeff(
    fq_zech_mpolyv_t A,
    slong i,
    fq_zech_mpoly_t c,
    const fq_zech_mpoly_ctx_t ctx);

void fq_zech_mpoly_to_mpolyv(
    fq_zech_mpolyv_t A,
    const fq_zech_mpoly_t B,
    const fq_zech_mpoly_t xalpha,
    const fq_zech_mpoly_ctx_t ctx);

void fq_zech_mpoly_from_mpolyv(
    fq_zech_mpoly_t A,
    const fq_zech_mpolyv_t B,
    const fq_zech_mpoly_t xalpha,
    const fq_zech_mpoly_ctx_t ctx);

/*****************************************************************************/

int fq_zech_mpoly_univar_content_mpoly(
    fq_zech_mpoly_t g,
    const fq_zech_mpoly_univar_t A,
    const fq_zech_mpoly_ctx_t ctx);

void fq_zech_mpoly_univar_divexact_mpoly(
    fq_zech_mpoly_univar_t A,
    const fq_zech_mpoly_t b,
    const fq_zech_mpoly_ctx_t ctx);

/*****************************************************************************/

int fq_zech_mpoly_factor_lcc_wang(
    fq_zech_mpoly_struct * lc_divs,
    const fq_zech_mpoly_factor_t lcAfac,
    const fq_zech_poly_t Auc,
    const fq_zech_bpoly_struct * Auf,
    slong r,
    const fq_zech_poly_struct * alpha,
    const fq_zech_mpoly_ctx_t ctx);

int fq_zech_mpoly_factor_irred_smprime_zassenhaus(
    fq_zech_mpolyv_t fac,
    const fq_zech_mpoly_t A,
    const fq_zech_mpoly_ctx_t ctx,
    flint_rand_t state);

int fq_zech_mpoly_factor_irred_lgprime_zassenhaus(
    fq_zech_mpolyv_t fac,
    const fq_zech_mpoly_t A,
    const fq_zech_mpoly_ctx_t ctx,
    flint_rand_t state);

int fq_zech_mpoly_factor_irred_smprime_wang(
    fq_zech_mpolyv_t fac,
    const fq_zech_mpoly_t A,
    const fq_zech_mpoly_factor_t lcAfac,
    const fq_zech_mpoly_t lcA,
    const fq_zech_mpoly_ctx_t ctx,
    flint_rand_t state);

int fq_zech_mpoly_factor_irred_lgprime_wang(
    fq_zech_mpolyv_t Af,
    const fq_zech_mpoly_t A,
    const fq_zech_mpoly_factor_t lcAfac,
    const fq_zech_mpoly_t lcA,
    const fq_zech_mpoly_ctx_t ctx,
    flint_rand_t state);

int fq_zech_mpoly_factor_irred_smprime_zippel(
    fq_zech_mpolyv_t fac,
    const fq_zech_mpoly_t A,
    const fq_zech_mpoly_factor_t lcAfac,
    const fq_zech_mpoly_t lcA,
    const fq_zech_mpoly_ctx_t ctx,
    flint_rand_t state);

int fq_zech_mpoly_factor_irred_lgprime_zippel(
    fq_zech_mpolyv_t Af,
    const fq_zech_mpoly_t A,
    const fq_zech_mpoly_factor_t lcAfac,
    const fq_zech_mpoly_t lcA,
    const fq_zech_mpoly_ctx_t ctx,
    flint_rand_t state);

/*****************************************************************************/

typedef struct {
    flint_bitcnt_t bits;
    slong w;
    slong r;
    fq_zech_poly_struct * inv_prod_dbetas;
    fq_zech_mpoly_struct * inv_prod_dbetas_mvar;
    fq_zech_poly_struct * dbetas;
    fq_zech_mpoly_struct * dbetas_mvar;
    fq_zech_mpoly_struct * prod_mbetas;
    fq_zech_mpolyv_struct * prod_mbetas_coeffs;
    fq_zech_mpoly_struct * mbetas;
    fq_zech_mpoly_struct * deltas;
    fq_zech_mpoly_struct * xalpha;
    fq_zech_mpoly_struct * q;
    fq_zech_mpoly_struct * qt;
    fq_zech_mpoly_struct * newt;
    fq_zech_mpolyv_struct * delta_coeffs;
    fq_zech_mpoly_t T;
    fq_zech_mpoly_t Q;
    fq_zech_mpoly_t R;
} fq_zech_mpoly_pfrac_struct;

typedef fq_zech_mpoly_pfrac_struct fq_zech_mpoly_pfrac_t[1];


int fq_zech_mpoly_pfrac_init(
    fq_zech_mpoly_pfrac_t Iv,
    flint_bitcnt_t bits,
    slong l, slong r,
    const fq_zech_mpoly_struct * betas,
    const fq_zech_struct * alpha,
    const fq_zech_mpoly_ctx_t ctx);

void fq_zech_mpoly_pfrac_clear(
    fq_zech_mpoly_pfrac_t Iv,
    const fq_zech_mpoly_ctx_t ctx);

int fq_zech_mpoly_pfrac(
    slong r,
    fq_zech_mpoly_t t,
    const slong * deg,
    fq_zech_mpoly_pfrac_t Iv,
    const fq_zech_mpoly_ctx_t ctx);

int fq_zech_mpoly_hlift(
    slong m,
    fq_zech_mpoly_struct * f, /* length r */
    slong r,
    const fq_zech_struct * alpha,
    const fq_zech_mpoly_t A,
    const slong * degs,
    const fq_zech_mpoly_ctx_t ctx);

int fq_zech_bpoly_hlift2(
    fq_zech_bpoly_t A, /* clobbered (shifted by alpha) */
    fq_zech_bpoly_t B0,
    fq_zech_bpoly_t B1,
    const fq_zech_t alpha,
    slong degree_inner, /* required degree in x */
    const fq_zech_ctx_t ctx);

int fq_zech_bpoly_hlift(
    slong r,
    fq_zech_bpoly_t A, /* clobbered (shifted by alpha) */
    fq_zech_bpoly_struct * B,
    const fq_zech_t alpha,
    slong degree_inner, /* required degree in x */
    const fq_zech_ctx_t ctx);

int fq_zech_polyu3_hlift(
    slong r,
    fq_zech_polyun_struct * BB,
    fq_zech_polyu_t A,
    fq_zech_polyu_struct * B,
    const fq_zech_t beta,
    slong degree_inner, /* required degree in x */
    const fq_zech_ctx_t ctx);

int fq_zech_mpoly_factor_algo(fq_zech_mpoly_factor_t f,
    const fq_zech_mpoly_t A, const fq_zech_mpoly_ctx_t ctx, unsigned int algo);

int fq_zech_mpoly_factor_zassenhaus(fq_zech_mpoly_factor_t f,
                       const fq_zech_mpoly_t A, const fq_zech_mpoly_ctx_t ctx);

int fq_zech_mpoly_factor_wang(fq_zech_mpoly_factor_t f,
                       const fq_zech_mpoly_t A, const fq_zech_mpoly_ctx_t ctx);

int fq_zech_mpoly_factor_zippel(fq_zech_mpoly_factor_t f,
                       const fq_zech_mpoly_t A, const fq_zech_mpoly_ctx_t ctx);

void fq_zech_poly_product_roots_fq_zech(
    fq_zech_poly_t master,
    const fq_zech_struct * monomials,
    slong mlength,
    const fq_zech_ctx_t ctx);

void _fq_zech_mpoly_monomial_evals(
    fq_zech_struct * E,
    const ulong * Aexps,
    flint_bitcnt_t Abits,
    slong Alen,
    const fq_zech_struct * alpha,
    slong vstart,
    const fq_zech_mpoly_ctx_t ctx);

int _fq_zech_mpoly_eval_rest_fq_zech_poly(
    fq_zech_poly_struct * E,
    slong * starts,
    slong * ends,
    slong * stops,
    ulong * es,
    const fq_zech_struct * Acoeffs,
    const ulong * Aexps,
    slong Alen,
    slong var,
    const fq_zech_poly_struct * alphas,
    const slong * offsets,
    const slong * shifts,
    slong N,
    ulong mask,
    slong nvars,
    const fq_zech_ctx_t ctx);

void _fq_zech_mpoly_eval_to_bpoly(
    fq_zech_bpoly_t E,
    const fq_zech_mpoly_t A,
    const fq_zech_poly_struct * alphabetas,
    const fq_zech_mpoly_ctx_t ctx);

void _fq_zech_mpoly_set_fq_zech_bpoly_var1_zero(
    fq_zech_mpoly_t A,
    flint_bitcnt_t Abits,
    const fq_zech_bpoly_t B,
    slong var,
    const fq_zech_mpoly_ctx_t ctx);

/* misc **********************************************************************/

int fq_zech_next(fq_zech_t x, const fq_zech_ctx_t FLINT_UNUSED(ctx));

#ifdef __cplusplus
}
#endif

#endif