35#include <NTL/lzz_pEX.h>
41#include "flint/fq_nmod_vec.h"
42#if __FLINT_RELEASE >= 20503
43#include "flint/fmpz_mod.h"
48#if defined(HAVE_NTL) || defined(HAVE_FLINT)
54 fmpz_poly_init2 (
result, d*(degAy + 1));
55 _fmpz_poly_set_length (
result, d*(degAy + 1));
59 if (
i.coeff().inBaseDomain())
62 for (
j=
i.coeff();
j.hasTerms();
j++)
66 _fmpz_poly_normalise(
result);
76 int degf= fmpz_poly_degree (F);
89 repLength= degfSubK + 1;
91 fmpq_poly_init2 (
buf, repLength);
92 _fmpq_poly_set_length (
buf, repLength);
93 _fmpz_vec_set (
buf->coeffs, F->coeffs +
k, repLength);
94 _fmpq_poly_normalise (
buf);
98 fmpq_poly_clear (
buf);
102 fmpq_poly_clear (
mipo);
121 int d= degAa + 1 + degBa;
123 fmpz_poly_t FLINTA,FLINTB;
127 fmpz_poly_mul (FLINTA, FLINTA, FLINTB);
132 fmpz_poly_clear (FLINTA);
133 fmpz_poly_clear (FLINTB);
148 fmpz_poly_t FLINTA,FLINTB;
151 fmpz_poly_mul (FLINTA, FLINTA, FLINTB);
155 fmpz_poly_clear (FLINTA);
156 fmpz_poly_clear (FLINTB);
184 fmpq_poly_t FLINTA,FLINTB;
188 fmpq_poly_div (FLINTA, FLINTA, FLINTB);
191 fmpq_poly_clear (FLINTA);
192 fmpq_poly_clear (FLINTB);
202 fmpq_poly_t FLINTA,FLINTB;
206 fmpq_poly_rem (FLINTA, FLINTA, FLINTB);
209 fmpq_poly_clear (FLINTA);
210 fmpq_poly_clear (FLINTB);
229 int d= degAa + 1 + degBa;
231 fmpz_poly_t FLINTA,FLINTB;
236 fmpz_poly_mullow (FLINTA, FLINTA, FLINTB,
k);
240 fmpz_poly_clear (FLINTA);
241 fmpz_poly_clear (FLINTB);
252 if (
G.inCoeffDomain())
266 fmpz_poly_t FLINTA,FLINTB;
269 fmpz_poly_mullow (FLINTA, FLINTA, FLINTB,
m);
273 fmpz_poly_clear (FLINTA);
274 fmpz_poly_clear (FLINTB);
287 while (d -
i.exp() < 0)
290 for (;
i.hasTerms() && (d -
i.exp() >= 0);
i++)
307 ASSERT (F.
mvar() ==
x,
"main variable of F and x differ");
308 ASSERT (!
g.isZero(),
"expected a unit");
321 for (
int i= 1;
i <=
l;
i++)
354 ASSERT (F.
level() ==
G.level(),
"F and G have different level");
387 ASSERT (F.
level() ==
G.level(),
"F and G have different level");
435#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
437 fmpz_mod_poly_t FLINTmipo;
439 fq_poly_t FLINTF, FLINTG;
447 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
448 fmpz_mod_ctx_t fmpz_ctx;
449 fmpz_mod_ctx_init(fmpz_ctx,FLINTp);
450 fq_ctx_init_modulus (
fq_con, FLINTmipo, fmpz_ctx,
"Z");
452 fq_ctx_init_modulus (
fq_con, FLINTmipo,
"Z");
458 fq_poly_mul (FLINTF, FLINTF, FLINTG,
fq_con);
464 fq_poly_clear (FLINTF,
fq_con);
465 fq_poly_clear (FLINTG,
fq_con);
467 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
468 fmpz_mod_poly_clear (FLINTmipo,fmpz_ctx);
469 fmpz_mod_ctx_clear(fmpz_ctx);
471 fmpz_mod_poly_clear(FLINTmipo);
478 ZZ_pE::init (NTLmipo);
481 mul (NTLf, NTLf, NTLg);
501 fmpz_mod_poly_t FLINTF, FLINTG;
504 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
505 fmpz_mod_ctx_t fmpz_ctx;
506 fmpz_mod_ctx_init(fmpz_ctx,FLINTpk);
507 fmpz_mod_poly_mul (FLINTF, FLINTF, FLINTG, fmpz_ctx);
509 fmpz_mod_poly_mul (FLINTF, FLINTF, FLINTG);
512 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
513 fmpz_mod_poly_clear (FLINTG,fmpz_ctx);
514 fmpz_mod_poly_clear (FLINTF,fmpz_ctx);
515 fmpz_mod_ctx_clear(fmpz_ctx);
517 fmpz_mod_poly_clear (FLINTG);
518 fmpz_mod_poly_clear (FLINTF);
520 fmpz_clear (FLINTpk);
531 ZZ_pX NTLf= to_ZZ_pX (ZZf);
532 ZZ_pX NTLg= to_ZZ_pX (ZZg);
533 mul (NTLf, NTLf, NTLg);
545#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
547 fmpz_mod_poly_t FLINTmipo;
561 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
562 fmpz_mod_ctx_t fmpz_ctx;
563 fmpz_mod_ctx_init(fmpz_ctx,FLINTp);
564 fq_ctx_init_modulus (
fq_con, FLINTmipo, fmpz_ctx,
"Z");
566 fq_ctx_init_modulus (
fq_con, FLINTmipo,
"Z");
578 fq_poly_scalar_mul_fq (FLINTG, FLINTG, FLINTF,
fq_con);
581 fmpz_poly_clear (FLINTF);
582 fq_poly_clear (FLINTG,
fq_con);
592 fq_poly_scalar_mul_fq (FLINTF, FLINTF, FLINTG,
fq_con);
595 fmpz_poly_clear (FLINTG);
596 fq_poly_clear (FLINTF,
fq_con);
605 fq_mul (FLINTF, FLINTF, FLINTG,
fq_con);
608 fq_clear (FLINTF,
fq_con);
609 fq_clear (FLINTG,
fq_con);
613 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
614 fmpz_mod_poly_clear (FLINTmipo,fmpz_ctx);
615 fmpz_mod_ctx_clear(fmpz_ctx);
617 fmpz_mod_poly_clear (FLINTmipo);
626 ZZ_pE::init (NTLmipo);
632 mul (NTLg, to_ZZ_pE (NTLf), NTLg);
639 mul (NTLf, NTLf, to_ZZ_pE (NTLg));
647 mul (
result, to_ZZ_pE (NTLg), to_ZZ_pE (NTLf));
660 ASSERT (F.
level() ==
G.level(),
"expected polys of same level");
662#if (!defined(HAVE_FLINT) || __FLINT_RELEASE < 20400)
681#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
682 nmod_poly_t FLINTmipo;
690 fq_nmod_poly_t FLINTF, FLINTG;
694 fq_nmod_poly_mul (FLINTF, FLINTF, FLINTG,
fq_con);
703#elif defined(AHVE_NTL)
705 zz_pE::init (NTLMipo);
708 mul (NTLF, NTLF, NTLG);
716 nmod_poly_t FLINTF, FLINTG;
719 nmod_poly_mul (FLINTF, FLINTF, FLINTG);
728 mul (NTLF, NTLF, NTLG);
770 fmpz_mod_poly_t FLINTF, FLINTG;
773 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
774 fmpz_mod_ctx_t fmpz_ctx;
775 fmpz_mod_ctx_init(fmpz_ctx,FLINTpk);
776 fmpz_mod_poly_divrem (FLINTG, FLINTF, FLINTF, FLINTG, fmpz_ctx);
778 fmpz_mod_poly_divrem (FLINTG, FLINTF, FLINTF, FLINTG);
781 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
782 fmpz_mod_poly_clear (FLINTG, fmpz_ctx);
783 fmpz_mod_poly_clear (FLINTF, fmpz_ctx);
784 fmpz_mod_ctx_clear(fmpz_ctx);
786 fmpz_mod_poly_clear (FLINTG);
787 fmpz_mod_poly_clear (FLINTF);
789 fmpz_clear (FLINTpk);
799 ZZ_pX NTLf= to_ZZ_pX (ZZf);
800 ZZ_pX NTLg= to_ZZ_pX (ZZg);
801 rem (NTLf, NTLf, NTLg);
811#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
813 fmpz_mod_poly_t FLINTmipo;
815 fq_poly_t FLINTF, FLINTG;
829 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
830 fmpz_mod_ctx_t fmpz_ctx;
831 fmpz_mod_ctx_init(fmpz_ctx,FLINTp);
832 fq_ctx_init_modulus (
fq_con, FLINTmipo, fmpz_ctx,
"Z");
834 fq_ctx_init_modulus (
fq_con, FLINTmipo,
"Z");
840 fq_poly_rem (FLINTF, FLINTF, FLINTG,
fq_con);
846 fq_poly_clear (FLINTF,
fq_con);
847 fq_poly_clear (FLINTG,
fq_con);
849 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
850 fmpz_mod_poly_clear (FLINTmipo, fmpz_ctx);
851 fmpz_mod_ctx_clear(fmpz_ctx);
853 fmpz_mod_poly_clear (FLINTmipo);
860 ZZ_pE::init (NTLmipo);
863 rem (NTLf, NTLf, NTLg);
878 ASSERT (F.
level() ==
G.level(),
"expected polys of same level");
879#if (!defined(HAVE_FLINT) || __FLINT_RELEASE < 20400)
890#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
891 nmod_poly_t FLINTmipo;
899 fq_nmod_poly_t FLINTF, FLINTG;
903 fq_nmod_poly_rem (FLINTF, FLINTF, FLINTG,
fq_con);
913 zz_pE::init (NTLMipo);
916 rem (NTLF, NTLF, NTLG);
923 nmod_poly_t FLINTF, FLINTG;
926 nmod_poly_divrem (FLINTG, FLINTF, FLINTF, FLINTG);
933 rem (NTLF, NTLF, NTLG);
958#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
960 fmpz_mod_poly_t FLINTmipo;
969 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
970 fmpz_mod_ctx_t fmpz_ctx;
971 fmpz_mod_ctx_init(fmpz_ctx,FLINTp);
972 fq_ctx_init_modulus (
fq_con, FLINTmipo, fmpz_ctx,
"Z");
974 fq_ctx_init_modulus (
fq_con, FLINTmipo,
"Z");
980 fq_inv (FLINTG, FLINTG,
fq_con);
981 fq_mul (FLINTF, FLINTF, FLINTG,
fq_con);
986 fq_clear (FLINTF,
fq_con);
987 fq_clear (FLINTG,
fq_con);
989 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
990 fmpz_mod_poly_clear (FLINTmipo, fmpz_ctx);
991 fmpz_mod_ctx_clear(fmpz_ctx);
993 fmpz_mod_poly_clear (FLINTmipo);
999 ZZ_pE::init (NTLmipo);
1003 div (
result, to_ZZ_pE (NTLf), to_ZZ_pE (NTLg));
1007 return b(
div (F,
G));
1015 if (!
G.inBaseDomain())
1019#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
1021 fmpz_mod_poly_t FLINTmipo;
1031 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
1032 fmpz_mod_ctx_t fmpz_ctx;
1033 fmpz_mod_ctx_init(fmpz_ctx,FLINTp);
1034 fq_ctx_init_modulus (
fq_con, FLINTmipo, fmpz_ctx,
"Z");
1036 fq_ctx_init_modulus (
fq_con, FLINTmipo,
"Z");
1042 fq_inv (FLINTG, FLINTG,
fq_con);
1043 fq_poly_scalar_mul_fq (FLINTF, FLINTF, FLINTG,
fq_con);
1048 fmpz_clear (FLINTp);
1049 fq_poly_clear (FLINTF,
fq_con);
1050 fq_clear (FLINTG,
fq_con);
1052 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
1053 fmpz_mod_poly_clear (FLINTmipo, fmpz_ctx);
1054 fmpz_mod_ctx_clear(fmpz_ctx);
1056 fmpz_mod_poly_clear (FLINTmipo);
1062 ZZ_pE::init (NTLmipo);
1065 div (NTLf, NTLf, to_ZZ_pE (NTLg));
1069 return b(
div (F,
G));
1084 fmpz_init (FLINTpk);
1086 fmpz_mod_poly_t FLINTF, FLINTG;
1089 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
1090 fmpz_mod_ctx_t fmpz_ctx;
1091 fmpz_mod_ctx_init(fmpz_ctx,FLINTpk);
1092 fmpz_mod_poly_divrem (FLINTF, FLINTG, FLINTF, FLINTG, fmpz_ctx);
1094 fmpz_mod_poly_divrem (FLINTF, FLINTG, FLINTF, FLINTG);
1097 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
1098 fmpz_mod_poly_clear (FLINTG, fmpz_ctx);
1099 fmpz_mod_poly_clear (FLINTF, fmpz_ctx);
1100 fmpz_mod_ctx_clear(fmpz_ctx);
1102 fmpz_mod_poly_clear (FLINTG);
1103 fmpz_mod_poly_clear (FLINTF);
1105 fmpz_clear (FLINTpk);
1115 ZZ_pX NTLf= to_ZZ_pX (ZZf);
1116 ZZ_pX NTLg= to_ZZ_pX (ZZg);
1117 div (NTLf, NTLf, NTLg);
1127#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
1129 fmpz_mod_poly_t FLINTmipo;
1131 fq_poly_t FLINTF, FLINTG;
1138 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
1139 fmpz_mod_ctx_t fmpz_ctx;
1140 fmpz_mod_ctx_init(fmpz_ctx,FLINTp);
1141 fq_ctx_init_modulus (
fq_con, FLINTmipo, fmpz_ctx,
"Z");
1143 fq_ctx_init_modulus (
fq_con, FLINTmipo,
"Z");
1149 fq_poly_divrem (FLINTF, FLINTG, FLINTF, FLINTG,
fq_con);
1154 fmpz_clear (FLINTp);
1155 fq_poly_clear (FLINTF,
fq_con);
1156 fq_poly_clear (FLINTG,
fq_con);
1158 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
1159 fmpz_mod_poly_clear (FLINTmipo, fmpz_ctx);
1160 fmpz_mod_ctx_clear(fmpz_ctx);
1162 fmpz_mod_poly_clear (FLINTmipo);
1168 ZZ_pE::init (NTLmipo);
1171 div (NTLf, NTLf, NTLg);
1186 ASSERT (F.
level() ==
G.level(),
"expected polys of same level");
1187#if (!defined(HAVE_FLINT) || __FLINT_RELEASE < 20400)
1198#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
1199 nmod_poly_t FLINTmipo;
1207 fq_nmod_poly_t FLINTF, FLINTG;
1211 fq_nmod_poly_divrem (FLINTF, FLINTG, FLINTF, FLINTG,
fq_con);
1221 zz_pE::init (NTLMipo);
1224 div (NTLF, NTLF, NTLG);
1231 nmod_poly_t FLINTF, FLINTG;
1234 nmod_poly_div (FLINTF, FLINTF, FLINTG);
1241 div (NTLF, NTLF, NTLG);
1257 result->length= d*(degAy + 1);
1258 flint_mpn_zero (
result->coeffs, d*(degAy+1));
1267 flint_mpn_copyi (
result->coeffs+
k,
buf->coeffs, nmod_poly_length(
buf));
1271 _nmod_poly_normalise (
result);
1274#if ( __FLINT_RELEASE >= 20400)
1277 const fq_nmod_ctx_t
fq_con)
1281 _fq_nmod_poly_set_length (
result, d*(degAy + 1),
fq_con);
1282 _fq_nmod_vec_zero (
result->coeffs, d*(degAy + 1),
fq_con);
1284 fq_nmod_poly_t
buf1;
1292 if (
i.coeff().inCoeffDomain())
1361 fmpz_poly_init2 (
result, d1*(degAy + 1));
1362 _fmpz_poly_set_length (
result, d1*(degAy + 1));
1370 if (
i.coeff().inCoeffDomain())
1374 _fmpz_vec_set (
result->coeffs +
k,
buf->coeffs,
buf->length);
1375 fmpz_poly_clear (
buf);
1379 for (
j=
i.coeff();
j.hasTerms();
j++)
1384 _fmpz_vec_set (
result->coeffs +
k,
buf->coeffs,
buf->length);
1385 fmpz_poly_clear (
buf);
1389 _fmpz_poly_normalise (
result);
1403 int k, kk,
j, bufRepLength;
1409 kk= (degAy -
i.exp())*d;
1410 bufRepLength= (int) nmod_poly_length (
buf);
1411 for (
j= 0;
j < bufRepLength;
j++)
1413 nmod_poly_set_coeff_ui (subA1,
j +
k,
1414 n_addmod (nmod_poly_get_coeff_ui (subA1,
j+
k),
1415 nmod_poly_get_coeff_ui (
buf,
j),
1419 nmod_poly_set_coeff_ui (subA2,
j + kk,
1420 n_addmod (nmod_poly_get_coeff_ui (subA2,
j + kk),
1421 nmod_poly_get_coeff_ui (
buf,
j),
1428 _nmod_poly_normalise (subA1);
1429 _nmod_poly_normalise (subA2);
1432#if ( __FLINT_RELEASE >= 20400)
1438 fq_nmod_poly_init2 (subA1, d*(degAy + 2),
fq_con);
1439 fq_nmod_poly_init2 (subA2, d*(degAy + 2),
fq_con);
1441 _fq_nmod_poly_set_length (subA1, d*(degAy + 2),
fq_con);
1442 _fq_nmod_vec_zero (subA1->coeffs, d*(degAy + 2),
fq_con);
1444 _fq_nmod_poly_set_length (subA2, d*(degAy + 2),
fq_con);
1445 _fq_nmod_vec_zero (subA2->coeffs, d*(degAy + 2),
fq_con);
1447 fq_nmod_poly_t
buf1;
1454 if (
i.coeff().inCoeffDomain())
1465 kk= (degAy -
i.exp())*d;
1466 _fq_nmod_vec_add (subA1->coeffs+
k, subA1->coeffs+
k,
buf1->coeffs,
1468 _fq_nmod_vec_add (subA2->coeffs+kk, subA2->coeffs+kk,
buf1->coeffs,
1473 _fq_nmod_poly_normalise (subA1,
fq_con);
1474 _fq_nmod_poly_normalise (subA2,
fq_con);
1483 fmpz_poly_init2 (subA1, d*(degAy + 2));
1484 fmpz_poly_init2 (subA2, d*(degAy + 2));
1494 kk= (degAy -
i.exp())*d;
1495 _fmpz_vec_add (subA1->coeffs+
k, subA1->coeffs +
k,
buf->coeffs,
buf->length);
1496 _fmpz_vec_add (subA2->coeffs+kk, subA2->coeffs + kk,
buf->coeffs,
buf->length);
1497 fmpz_poly_clear (
buf);
1500 _fmpz_poly_normalise (subA1);
1501 _fmpz_poly_normalise (subA2);
1512 int degf= fmpz_poly_degree(F);
1514 int degfSubK, repLength;
1521 repLength= degfSubK + 1;
1523 fmpz_poly_init2 (
buf, repLength);
1524 _fmpz_poly_set_length (
buf, repLength);
1525 _fmpz_vec_set (
buf->coeffs, F->coeffs+
k, repLength);
1526 _fmpz_poly_normalise (
buf);
1531 fmpz_poly_clear (
buf);
1611 const fmpq_poly_t
mipo)
1619 int degf= fmpz_poly_degree(F);
1629 repLength= degfSubK + 1;
1633 while (
j*d2 < repLength)
1635 fmpq_poly_init2 (
buf, d2);
1636 _fmpq_poly_set_length (
buf, d2);
1637 _fmpz_vec_set (
buf->coeffs, F->coeffs +
k +
j*d2, d2);
1638 _fmpq_poly_normalise (
buf);
1642 fmpq_poly_clear (
buf);
1644 if (repLength -
j*d2 != 0 &&
j*d2 - repLength < d2)
1648 fmpq_poly_init2 (
buf, repLength);
1649 _fmpq_poly_set_length (
buf, repLength);
1651 _fmpz_vec_set (
buf->coeffs, F->coeffs +
k +
j*d2, repLength);
1652 _fmpq_poly_normalise (
buf);
1655 fmpq_poly_clear (
buf);
1676 nmod_poly_set (
f, F);
1677 nmod_poly_set (
g,
G);
1678 int degf= nmod_poly_degree(
f);
1679 int degg= nmod_poly_degree(
g);
1684 if (nmod_poly_length (
f) < (
long) d*(
k+1))
1685 nmod_poly_fit_length (
f,(
long)d*(
k+1));
1691 int degfSubLf= degf;
1692 int deggSubLg=
degg-lg;
1693 int repLengthBuf2, repLengthBuf1, ind, tmp;
1694 while (degf >= lf || lg >= 0)
1698 else if (degfSubLf < 0)
1701 repLengthBuf1= degfSubLf + 1;
1704 for (ind= 0; ind < repLengthBuf1; ind++)
1705 nmod_poly_set_coeff_ui (
buf1, ind, nmod_poly_get_coeff_ui (
f, ind+lf));
1706 _nmod_poly_normalise (
buf1);
1708 repLengthBuf1= nmod_poly_length (
buf1);
1710 if (deggSubLg >= d - 1)
1711 repLengthBuf2= d - 1;
1712 else if (deggSubLg < 0)
1715 repLengthBuf2= deggSubLg + 1;
1718 for (ind= 0; ind < repLengthBuf2; ind++)
1719 nmod_poly_set_coeff_ui (
buf2, ind, nmod_poly_get_coeff_ui (
g, ind + lg));
1721 _nmod_poly_normalise (
buf2);
1722 repLengthBuf2= nmod_poly_length (
buf2);
1725 for (ind= 0; ind < repLengthBuf1; ind++)
1726 nmod_poly_set_coeff_ui (buf3, ind, nmod_poly_get_coeff_ui (
buf1, ind));
1727 for (ind= repLengthBuf1; ind < d; ind++)
1728 nmod_poly_set_coeff_ui (buf3, ind, 0);
1729 for (ind= 0; ind < repLengthBuf2; ind++)
1730 nmod_poly_set_coeff_ui (buf3, ind+d, nmod_poly_get_coeff_ui (
buf2, ind));
1731 _nmod_poly_normalise (buf3);
1738 degfSubLf= degf - lf;
1741 deggSubLg=
degg - lg;
1743 if (lg >= 0 && deggSubLg > 0)
1745 if (repLengthBuf2 > degfSubLf + 1)
1746 degfSubLf= repLengthBuf2 - 1;
1747 tmp=
tmin (repLengthBuf1, deggSubLg + 1);
1748 for (ind= 0; ind < tmp; ind++)
1749 nmod_poly_set_coeff_ui (
g, ind + lg,
1750 n_submod (nmod_poly_get_coeff_ui (
g, ind + lg),
1751 nmod_poly_get_coeff_ui (
buf1, ind),
1765 for (ind= 0; ind < repLengthBuf2; ind++)
1766 nmod_poly_set_coeff_ui (
f, ind + lf,
1767 n_submod (nmod_poly_get_coeff_ui (
f, ind + lf),
1768 nmod_poly_get_coeff_ui (
buf2, ind),
1784#if ( __FLINT_RELEASE >= 20400)
1792 fq_nmod_poly_t
f,
g;
1793 int degf= fq_nmod_poly_degree(F,
fq_con);
1800 fq_nmod_poly_set (
f, F,
fq_con);
1802 if (fq_nmod_poly_length (
f,
fq_con) < (
long) d*(
k + 1))
1803 fq_nmod_poly_fit_length (
f, (
long) d*(
k + 1),
fq_con);
1809 int degfSubLf= degf;
1810 int deggSubLg=
degg-lg;
1811 int repLengthBuf2, repLengthBuf1, tmp;
1812 while (degf >= lf || lg >= 0)
1816 else if (degfSubLf < 0)
1819 repLengthBuf1= degfSubLf + 1;
1820 fq_nmod_poly_init2 (
buf1, repLengthBuf1,
fq_con);
1821 _fq_nmod_poly_set_length (
buf1, repLengthBuf1,
fq_con);
1823 _fq_nmod_vec_set (
buf1->coeffs,
f->coeffs + lf, repLengthBuf1,
fq_con);
1826 repLengthBuf1= fq_nmod_poly_length (
buf1,
fq_con);
1828 if (deggSubLg >= d - 1)
1829 repLengthBuf2= d - 1;
1830 else if (deggSubLg < 0)
1833 repLengthBuf2= deggSubLg + 1;
1835 fq_nmod_poly_init2 (
buf2, repLengthBuf2,
fq_con);
1836 _fq_nmod_poly_set_length (
buf2, repLengthBuf2,
fq_con);
1837 _fq_nmod_vec_set (
buf2->coeffs,
g->coeffs + lg, repLengthBuf2,
fq_con);
1840 repLengthBuf2= fq_nmod_poly_length (
buf2,
fq_con);
1842 fq_nmod_poly_init2 (buf3, repLengthBuf2 + d,
fq_con);
1843 _fq_nmod_poly_set_length (buf3, repLengthBuf2 + d,
fq_con);
1844 _fq_nmod_vec_set (buf3->coeffs,
buf1->coeffs, repLengthBuf1,
fq_con);
1845 _fq_nmod_vec_set (buf3->coeffs + d,
buf2->coeffs, repLengthBuf2,
fq_con);
1847 _fq_nmod_poly_normalise (buf3,
fq_con);
1854 degfSubLf= degf - lf;
1857 deggSubLg=
degg - lg;
1859 if (lg >= 0 && deggSubLg > 0)
1861 if (repLengthBuf2 > degfSubLf + 1)
1862 degfSubLf= repLengthBuf2 - 1;
1863 tmp=
tmin (repLengthBuf1, deggSubLg + 1);
1864 _fq_nmod_vec_sub (
g->coeffs + lg,
g->coeffs + lg,
buf1->
coeffs,
1875 _fq_nmod_vec_sub (
f->coeffs + lf,
f->coeffs + lf,
buf2->coeffs,
1898 fmpz_poly_set (
f, F);
1899 fmpz_poly_set (
g,
G);
1900 int degf= fmpz_poly_degree(
f);
1901 int degg= fmpz_poly_degree(
g);
1905 if (fmpz_poly_length (
f) < (
long) d*(
k+1))
1906 fmpz_poly_fit_length (
f,(
long)d*(
k+1));
1912 int degfSubLf= degf;
1913 int deggSubLg=
degg-lg;
1914 int repLengthBuf2, repLengthBuf1, ind, tmp;
1916 while (degf >= lf || lg >= 0)
1920 else if (degfSubLf < 0)
1923 repLengthBuf1= degfSubLf + 1;
1925 fmpz_poly_init2 (
buf1, repLengthBuf1);
1927 for (ind= 0; ind < repLengthBuf1; ind++)
1929 fmpz_poly_get_coeff_fmpz (
tmp1,
f, ind + lf);
1930 fmpz_poly_set_coeff_fmpz (
buf1, ind,
tmp1);
1932 _fmpz_poly_normalise (
buf1);
1934 repLengthBuf1= fmpz_poly_length (
buf1);
1936 if (deggSubLg >= d - 1)
1937 repLengthBuf2= d - 1;
1938 else if (deggSubLg < 0)
1941 repLengthBuf2= deggSubLg + 1;
1943 fmpz_poly_init2 (
buf2, repLengthBuf2);
1945 for (ind= 0; ind < repLengthBuf2; ind++)
1947 fmpz_poly_get_coeff_fmpz (
tmp1,
g, ind + lg);
1948 fmpz_poly_set_coeff_fmpz (
buf2, ind,
tmp1);
1951 _fmpz_poly_normalise (
buf2);
1952 repLengthBuf2= fmpz_poly_length (
buf2);
1954 fmpz_poly_init2 (buf3, repLengthBuf2 + d);
1955 for (ind= 0; ind < repLengthBuf1; ind++)
1957 fmpz_poly_get_coeff_fmpz (
tmp1,
buf1, ind);
1958 fmpz_poly_set_coeff_fmpz (buf3, ind,
tmp1);
1960 for (ind= repLengthBuf1; ind < d; ind++)
1961 fmpz_poly_set_coeff_ui (buf3, ind, 0);
1962 for (ind= 0; ind < repLengthBuf2; ind++)
1964 fmpz_poly_get_coeff_fmpz (
tmp1,
buf2, ind);
1965 fmpz_poly_set_coeff_fmpz (buf3, ind + d,
tmp1);
1967 _fmpz_poly_normalise (buf3);
1974 degfSubLf= degf - lf;
1977 deggSubLg=
degg - lg;
1979 if (lg >= 0 && deggSubLg > 0)
1981 if (repLengthBuf2 > degfSubLf + 1)
1982 degfSubLf= repLengthBuf2 - 1;
1983 tmp=
tmin (repLengthBuf1, deggSubLg + 1);
1984 for (ind= 0; ind < tmp; ind++)
1986 fmpz_poly_get_coeff_fmpz (
tmp1,
g, ind + lg);
1987 fmpz_poly_get_coeff_fmpz (
tmp2,
buf1, ind);
1989 fmpz_poly_set_coeff_fmpz (
g, ind + lg,
tmp1);
1994 fmpz_poly_clear (
buf1);
1995 fmpz_poly_clear (
buf2);
1996 fmpz_poly_clear (buf3);
2001 for (ind= 0; ind < repLengthBuf2; ind++)
2003 fmpz_poly_get_coeff_fmpz (
tmp1,
f, ind + lf);
2004 fmpz_poly_get_coeff_fmpz (
tmp2,
buf2, ind);
2006 fmpz_poly_set_coeff_fmpz (
f, ind + lf,
tmp1);
2009 fmpz_poly_clear (
buf1);
2010 fmpz_poly_clear (
buf2);
2011 fmpz_poly_clear (buf3);
2014 fmpz_poly_clear (
f);
2015 fmpz_poly_clear (
g);
2022#if ( __FLINT_RELEASE >= 20400)
2025 const fq_nmod_ctx_t
fq_con)
2033 int degf= fq_nmod_poly_degree(F,
fq_con);
2035 int degfSubK, repLength;
2042 repLength= degfSubK + 1;
2044 fq_nmod_poly_init2 (
buf, repLength,
fq_con);
2045 _fq_nmod_poly_set_length (
buf, repLength,
fq_con);
2046 _fq_nmod_vec_set (
buf->coeffs, F->coeffs+
k, repLength,
fq_con);
2069 int degf= nmod_poly_degree(F);
2071 int degfSubK, repLength,
j;
2078 repLength= degfSubK + 1;
2081 for (
j= 0;
j < repLength;
j++)
2082 nmod_poly_set_coeff_ui (
buf,
j, nmod_poly_get_coeff_ui (F,
j +
k));
2083 _nmod_poly_normalise (
buf);
2109 nmod_poly_mullow (
F1,
F1, G1, (
long)
k);
2116 int b= nmod_poly_degree (
F2) + nmod_poly_degree (G2) -
k - degtailF - degtailG
2117 + d1*(2+taildegF + taildegG);
2118 nmod_poly_mulhigh (
F2,
F2, G2,
b);
2119 nmod_poly_shift_right (
F2,
F2,
b);
2120 int d2=
tmax (nmod_poly_degree (
F2)/d1, nmod_poly_degree (
F1)/d1);
2143 int d1= degAx + 1 + degBx;
2144 int d2=
tmax (degAy, degBy);
2146 if (d1 > 128 && d2 > 160 && (degAy == degBy) && (2*degAy >
degree (
M)))
2149 nmod_poly_t FLINTA, FLINTB;
2154 nmod_poly_mullow (FLINTA, FLINTA, FLINTB, (
long)
k);
2163#if ( __FLINT_RELEASE >= 20400)
2167 const fq_nmod_ctx_t
fq_con)
2173 fq_nmod_poly_t
F1,
F2;
2176 fq_nmod_poly_t G1, G2;
2180 fq_nmod_poly_mullow (
F1,
F1, G1, (
long)
k,
fq_con);
2187 int b=
k + degtailF + degtailG - d1*(2+taildegF + taildegG);
2190 fq_nmod_poly_reverse (G2, G2, fq_nmod_poly_length (G2,
fq_con),
fq_con);
2195 fq_nmod_poly_degree (
F1,
fq_con)/d1);
2209 const fq_nmod_ctx_t
fq_con)
2218 int d1= degAx + 1 + degBx;
2219 int d2=
tmax (degAy, degBy);
2221 if (d1 > 128 && d2 > 160 && (degAy == degBy) && (2*degAy >
degree (
M)))
2224 fq_nmod_poly_t FLINTA, FLINTB;
2229 fq_nmod_poly_mullow (FLINTA, FLINTA, FLINTB, (
long)
k,
fq_con);
2254 fmpz_poly_mullow (
F1,
F1, G1, (
long)
k);
2261 int b= fmpz_poly_degree (
F2) + fmpz_poly_degree (G2) -
k - degtailF - degtailG
2262 + d1*(2+taildegF + taildegG);
2263 fmpz_poly_mulhigh_n (
F2,
F2, G2,
b);
2264 fmpz_poly_shift_right (
F2,
F2,
b);
2265 int d2=
tmax (fmpz_poly_degree (
F2)/d1, fmpz_poly_degree (
F1)/d1);
2269 fmpz_poly_clear (
F1);
2270 fmpz_poly_clear (
F2);
2271 fmpz_poly_clear (G1);
2272 fmpz_poly_clear (G2);
2285 int d1= degAx + 1 + degBx;
2292 fmpz_poly_t FLINTA, FLINTB;
2297 fmpz_poly_mullow (FLINTA, FLINTA, FLINTB, (
long)
k);
2299 fmpz_poly_clear (FLINTA);
2300 fmpz_poly_clear (FLINTB);
2345 int degFx=
degree (F, 1);
2346 int degFa=
degree (F, a);
2350 int d2= degFa+degGa+1;
2351 int d1= degFx + 1 + degGx;
2359 fmpz_poly_t FLINTF, FLINTG;
2363 fmpz_poly_mullow (FLINTF, FLINTF, FLINTG, d1*
degree (
M));
2368 fmpz_poly_clear (FLINTF);
2369 fmpz_poly_clear (FLINTG);
2380 result.rep.SetLength (d*(degAy + 1));
2383 resultp=
result.rep.elts();
2386 int j,
k, bufRepLength;
2390 if (
i.coeff().inCoeffDomain())
2396 bufp=
buf.rep.elts();
2397 bufRepLength= (int)
buf.rep.length();
2398 for (
j= 0;
j < bufRepLength;
j++)
2399 resultp [
j +
k]= bufp [
j];
2407#if (!(HAVE_FLINT && __FLINT_RELEASE >= 20400))
2412 result.rep.SetLength (d*(degAy + 1));
2416 resultp=
result.rep.elts();
2421 int j,
k, buf1RepLength;
2425 if (
i.coeff().inCoeffDomain())
2434 buf1p=
buf1.rep.elts();
2435 buf1RepLength= (int)
buf1.rep.length();
2436 for (
j= 0;
j < buf1RepLength;
j++)
2437 resultp [
j +
k]= buf1p [
j];
2449 subA1.rep.SetLength ((
long) d*(degAy + 2));
2450 subA2.rep.SetLength ((
long) d*(degAy + 2));
2455 subA1p= subA1.rep.elts();
2456 subA2p= subA2.rep.elts();
2461 int j,
k, kk, bufRepLength;
2465 if (
i.coeff().inCoeffDomain())
2468 buf= to_zz_pEX (to_zz_pE (
buf2));
2474 kk= (degAy -
i.exp())*d;
2475 bufp=
buf.rep.elts();
2476 bufRepLength= (int)
buf.rep.length();
2477 for (
j= 0;
j < bufRepLength;
j++)
2479 subA1p [
j +
k] += bufp [
j];
2480 subA2p [
j + kk] += bufp [
j];
2493 subA1.rep.SetLength ((
long) d*(degAy + 2));
2494 subA2.rep.SetLength ((
long) d*(degAy + 2));
2498 subA1p= subA1.rep.elts();
2499 subA2p= subA2.rep.elts();
2502 int j,
k, kk, bufRepLength;
2509 kk= (degAy -
i.exp())*d;
2510 bufp=
buf.rep.elts();
2511 bufRepLength= (int)
buf.rep.length();
2512 for (
j= 0;
j < bufRepLength;
j++)
2514 subA1p [
j +
k] += bufp [
j];
2515 subA2p [
j + kk] += bufp [
j];
2523#if (!(HAVE_FLINT && __FLINT_RELEASE >= 20400))
2543 if (
f.rep.length() < (
long) d*(
k+1))
2544 f.rep.SetLength ((
long)d*(
k+1));
2546 zz_pE *
gp=
g.rep.elts();
2547 zz_pE *
fp=
f.rep.elts();
2552 int degfSubLf= degf;
2553 int deggSubLg=
degg-lg;
2554 int repLengthBuf2, repLengthBuf1, ind, tmp;
2555 zz_pE zzpEZero= zz_pE();
2557 while (degf >= lf || lg >= 0)
2561 else if (degfSubLf < 0)
2564 repLengthBuf1= degfSubLf + 1;
2565 buf1.rep.SetLength((
long) repLengthBuf1);
2567 buf1p=
buf1.rep.elts();
2568 for (ind= 0; ind < repLengthBuf1; ind++)
2569 buf1p [ind]=
fp [ind + lf];
2572 repLengthBuf1=
buf1.rep.length();
2574 if (deggSubLg >= d - 1)
2575 repLengthBuf2= d - 1;
2576 else if (deggSubLg < 0)
2579 repLengthBuf2= deggSubLg + 1;
2581 buf2.rep.SetLength ((
long) repLengthBuf2);
2582 buf2p=
buf2.rep.elts();
2583 for (ind= 0; ind < repLengthBuf2; ind++)
2584 buf2p [ind]=
gp [ind + lg];
2587 repLengthBuf2=
buf2.rep.length();
2589 buf3.rep.SetLength((
long) repLengthBuf2 + d);
2590 buf3p= buf3.rep.elts();
2591 buf2p=
buf2.rep.elts();
2592 buf1p=
buf1.rep.elts();
2593 for (ind= 0; ind < repLengthBuf1; ind++)
2594 buf3p [ind]= buf1p [ind];
2595 for (ind= repLengthBuf1; ind < d; ind++)
2596 buf3p [ind]= zzpEZero;
2597 for (ind= 0; ind < repLengthBuf2; ind++)
2598 buf3p [ind + d]= buf2p [ind];
2606 degfSubLf= degf - lf;
2609 deggSubLg=
degg - lg;
2611 buf1p=
buf1.rep.elts();
2613 if (lg >= 0 && deggSubLg > 0)
2615 if (repLengthBuf2 > degfSubLf + 1)
2616 degfSubLf= repLengthBuf2 - 1;
2617 tmp=
tmin (repLengthBuf1, deggSubLg + 1);
2618 for (ind= 0; ind < tmp; ind++)
2619 gp [ind + lg] -= buf1p [ind];
2625 buf2p=
buf2.rep.elts();
2628 for (ind= 0; ind < repLengthBuf2; ind++)
2629 fp [ind + lf] -= buf2p [ind];
2657 if (
f.rep.length() < (
long) d*(
k+1))
2658 f.rep.SetLength ((
long)d*(
k+1));
2660 zz_p *
gp=
g.rep.elts();
2661 zz_p *
fp=
f.rep.elts();
2666 int degfSubLf= degf;
2667 int deggSubLg=
degg-lg;
2668 int repLengthBuf2, repLengthBuf1, ind, tmp;
2669 zz_p zzpZero= zz_p();
2670 while (degf >= lf || lg >= 0)
2674 else if (degfSubLf < 0)
2677 repLengthBuf1= degfSubLf + 1;
2678 buf1.rep.SetLength((
long) repLengthBuf1);
2680 buf1p=
buf1.rep.elts();
2681 for (ind= 0; ind < repLengthBuf1; ind++)
2682 buf1p [ind]=
fp [ind + lf];
2685 repLengthBuf1=
buf1.rep.length();
2687 if (deggSubLg >= d - 1)
2688 repLengthBuf2= d - 1;
2689 else if (deggSubLg < 0)
2692 repLengthBuf2= deggSubLg + 1;
2694 buf2.rep.SetLength ((
long) repLengthBuf2);
2695 buf2p=
buf2.rep.elts();
2696 for (ind= 0; ind < repLengthBuf2; ind++)
2697 buf2p [ind]=
gp [ind + lg];
2701 repLengthBuf2=
buf2.rep.length();
2704 buf3.rep.SetLength((
long) repLengthBuf2 + d);
2705 buf3p= buf3.rep.elts();
2706 buf2p=
buf2.rep.elts();
2707 buf1p=
buf1.rep.elts();
2708 for (ind= 0; ind < repLengthBuf1; ind++)
2709 buf3p [ind]= buf1p [ind];
2710 for (ind= repLengthBuf1; ind < d; ind++)
2711 buf3p [ind]= zzpZero;
2712 for (ind= 0; ind < repLengthBuf2; ind++)
2713 buf3p [ind + d]= buf2p [ind];
2721 degfSubLf= degf - lf;
2724 deggSubLg=
degg - lg;
2726 buf1p=
buf1.rep.elts();
2728 if (lg >= 0 && deggSubLg > 0)
2730 if (repLengthBuf2 > degfSubLf + 1)
2731 degfSubLf= repLengthBuf2 - 1;
2732 tmp=
tmin (repLengthBuf1, deggSubLg + 1);
2733 for (ind= 0; ind < tmp; ind++)
2734 gp [ind + lg] -= buf1p [ind];
2739 buf2p=
buf2.rep.elts();
2742 for (ind= 0; ind < repLengthBuf2; ind++)
2743 fp [ind + lf] -= buf2p [ind];
2751#if (!(HAVE_FLINT && __FLINT_RELEASE >= 20400))
2758 zz_pE *
fp=
f.rep.elts();
2766 int degfSubK, repLength,
j;
2773 repLength= degfSubK + 1;
2775 buf.rep.SetLength ((
long) repLength);
2776 bufp=
buf.rep.elts();
2777 for (
j= 0;
j < repLength;
j++)
2778 bufp [
j]=
fp [
j +
k];
2797 zz_p *
fp=
f.rep.elts();
2805 int degfSubK, repLength,
j;
2812 repLength= degfSubK + 1;
2814 buf.rep.SetLength ((
long) repLength);
2815 bufp=
buf.rep.elts();
2816 for (
j= 0;
j < repLength;
j++)
2817 bufp [
j]=
fp [
j +
k];
2843 MulTrunc (
F1,
F1, G1, (
long)
k);
2849 int b=
k + degtailF + degtailG - d1*(2+taildegF+taildegG);
2853 MulTrunc (
F2,
F2, G2,
b + 1);
2856 int d2=
tmax (deg (
F2)/d1, deg (
F1)/d1);
2872 int d1= degAx + 1 + degBx;
2873 int d2=
tmax (degAy, degBy);
2875 if (d1 > 128 && d2 > 160 && (degAy == degBy) && (2*degAy >
degree (
M)))
2876 return mulMod2NTLFpReci (
A,
B,
M);
2882 MulTrunc (NTLA, NTLA, NTLB, (
long)
k);
2890#if (!(HAVE_FLINT && __FLINT_RELEASE >= 20400))
2906 MulTrunc (
F1,
F1, G1, (
long)
k);
2912 int b=
k + degtailF + degtailG - d1*(2+taildegF+taildegG);
2916 MulTrunc (
F2,
F2, G2,
b + 1);
2919 int d2=
tmax (deg (
F2)/d1, deg (
F1)/d1);
2940#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
2941 nmod_poly_t FLINTmipo;
2955 int d1= degAx + degBx + 1;
2956 int d2=
tmax (degAy, degBy);
2963 zz_pE::init (NTLMipo);
2966 if ((d1 > 128/degMipo) && (d2 > 160/degMipo) && (degAy == degBy) &&
2968 return mulMod2NTLFqReci (
A,
B,
M,
alpha);
2975 MulTrunc (NTLA, NTLA, NTLB, (
long)
k);
2985 A= mulMod2NTLFp (
A,
B,
M);
2997 ASSERT (
M.isUnivariate(),
"M must be univariate");
3003 if (
G.inCoeffDomain())
3010 if ((degF < 1 && degG < 1) && (F.
isUnivariate() &&
G.isUnivariate()) &&
3011 (F.
level() ==
G.level()))
3016 else if (degF <= 1 && degG <= 1)
3022 int sizeF=
size (F);
3023 int sizeG=
size (
G);
3025 int fallBackToNaive= 50;
3026 if (sizeF < fallBackToNaive || sizeG < fallBackToNaive)
3029 return mod (
G*F,
M);
3031 return mod (F*
G,
M);
3040 (((degF-degG) < 50 && degF > degG) || ((degG-degF) < 50 && degF <= degG)))
3043 int m= (int) ceil (
degree (
M)/2.0);
3044 if (degF >=
m || degG >=
m)
3055 return F0G0 + MLo*(F0G1 + F1G0);
3059 m= (int) ceil (
tmax (degF, degG)/2.0);
3068 return H11*yToM*yToM + (H01 - H11 - H00)*yToM + H00;
3070 DEBOUTLN (cerr,
"fatal end in mulMod2");
3099 if (
G.inCoeffDomain())
3102 int sizeF=
size (F);
3103 int sizeG=
size (
G);
3105 if (sizeF / MOD.
length() < 100 || sizeG / MOD.
length() < 100)
3108 return mod (
G*F, MOD);
3110 return mod (F*
G, MOD);
3117 if ((degF <= 1 && F.
level() <=
M.level()) &&
3118 (degG <= 1 &&
G.level() <=
M.level()))
3122 if (degF == 1 && degG == 1)
3133 return H11*
y*
y + (H01 - H00 - H11)*
y + H00;
3145 else if (degF == 1 && degG == 0)
3147 else if (degF == 0 && degG == 1)
3152 int m= (int) ceil (
degree (
M)/2.0);
3153 if (degF >=
m || degG >=
m)
3167 return F0G0 + MLo*(F0G1 + F1G0);
3171 m= (
tmax(degF, degG)+1)/2;
3180 return H11*yToM*yToM + (H01 - H11 - H00)*yToM + H00;
3182 DEBOUTLN (cerr,
"fatal end in mulMod");
3202 for (
int j= 1;
j <=
l;
j++,
i++)
3216 else if (L.
length() == 1)
3218 else if (L.
length() == 2)
3226 for (
int j= 1;
j <=
l;
j++,
i++)
3251 while (d -
i.exp() < 0)
3254 for (;
i.hasTerms() && (d -
i.exp() >= 0);
i++)
3269 ASSERT (!
g.isZero(),
"expected a unit");
3285 for (
int i= 1;
i <=
l;
i++)
3354#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
3355 nmod_poly_t FLINTmipo;
3364 fq_nmod_poly_t FLINTA, FLINTB;
3368 fq_nmod_poly_divrem (FLINTA, FLINTB, FLINTA, FLINTB,
fq_con);
3377 bool zz_pEbak= zz_pE::initialized();
3385 div (NTLA, NTLA, NTLB);
3437#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
3438 nmod_poly_t FLINTmipo;
3446 fq_nmod_poly_t FLINTA, FLINTB;
3450 fq_nmod_poly_divrem (FLINTA, FLINTB, FLINTA, FLINTB,
fq_con);
3465 DivRem (NTLQ, NTLR, NTLA, NTLB);
3481 else if (
x.
level() !=
A.level())
3487 int j= (int) floor ((
double)
degree (
A)/
m);
3492 while (
i.hasTerms() &&
i.exp() -
j*
m >= 0)
3535 int m= (int) ceil ((
double) (degB + 1)/2.0) + 1;
3536 ASSERT (4*
m >= degA,
"expected degree (F, 1) < 2*degree (G, 1)");
3538 if (splitA.
length() == 3)
3540 if (splitA.
length() == 2)
3545 if (splitA.
length() == 1)
3567 if (splitR.
length() == 1)
3606 int m= (int) ceil ((
double) (degB + 1)/ 2.0);
3607 ASSERT (3*
m > degA,
"expected degree (F, 1) < 3*degree (G, 1)");
3611 if (splitA.
length() == 2)
3615 if (splitA.
length() == 1)
3645 Q +=
LC (
R,
x)*xToM;
3704 H=
i.getItem()*xToDegB;
3714 H=
R*xToDegB +
i.getItem();
3748 H=
i.getItem()*xToDegB;
3756 H=
R*xToDegB +
i.getItem();
3775 if (
A.inCoeffDomain())
3782#if (!defined(HAVE_FLINT) || __FLINT_RELEASE < 20400)
3792#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
3793 nmod_poly_t FLINTmipo;
3801 fq_nmod_poly_t FLINTA, FLINTB;
3804 int result= fq_nmod_poly_divides (FLINTA, FLINTB, FLINTA,
fq_con);
3812 zz_pE::init (NTLMipo);
3815 return divide (NTLB, NTLA);
3819 nmod_poly_t FLINTA, FLINTB;
3822 nmod_poly_divrem (FLINTB, FLINTA, FLINTB, FLINTA);
3823 bool result= nmod_poly_is_zero (FLINTA);
3830 return divide (NTLB, NTLA);
3840 fmpq_poly_t FLINTA,FLINTB;
3843 fmpq_poly_rem (FLINTA, FLINTB, FLINTA);
3844 bool result= fmpq_poly_is_zero (FLINTA);
3845 fmpq_poly_clear (FLINTA);
3846 fmpq_poly_clear (FLINTB);
CanonicalForm convertFq_poly_t2FacCF(const fq_poly_t p, const Variable &x, const Variable &alpha, const fq_ctx_t ctx)
conversion of a FLINT poly over Fq (for non-word size p) to a CanonicalForm with alg....
void convertFacCF2Fq_t(fq_t result, const CanonicalForm &f, const fq_ctx_t ctx)
conversion of a factory element of F_q (for non-word size p) to a FLINT fq_t
CanonicalForm convertFq_nmod_poly_t2FacCF(const fq_nmod_poly_t p, const Variable &x, const Variable &alpha, const fq_nmod_ctx_t ctx)
conversion of a FLINT poly over Fq to a CanonicalForm with alg. variable alpha and polynomial variabl...
CanonicalForm convertFq_t2FacCF(const fq_t poly, const Variable &alpha)
conversion of a FLINT element of F_q with non-word size p to a CanonicalForm with alg....
CanonicalForm convertFmpq_poly_t2FacCF(const fmpq_poly_t p, const Variable &x)
conversion of a FLINT poly over Q to CanonicalForm
CanonicalForm convertFmpz_mod_poly_t2FacCF(const fmpz_mod_poly_t poly, const Variable &x, const modpk &b)
conversion of a FLINT poly over Z/p (for non word size p) to a CanonicalForm over Z
CanonicalForm convertnmod_poly_t2FacCF(const nmod_poly_t poly, const Variable &x)
conversion of a FLINT poly over Z/p to CanonicalForm
void convertFacCF2Fmpz_mod_poly_t(fmpz_mod_poly_t result, const CanonicalForm &f, const fmpz_t p)
conversion of a factory univariate poly over Z to a FLINT poly over Z/p (for non word size p)
void convertFacCF2Fq_nmod_poly_t(fq_nmod_poly_t result, const CanonicalForm &f, const fq_nmod_ctx_t ctx)
conversion of a factory univariate poly over F_q to a FLINT fq_nmod_poly_t
CanonicalForm convertFmpz_poly_t2FacCF(const fmpz_poly_t poly, const Variable &x)
conversion of a FLINT poly over Z to CanonicalForm
void convertFacCF2Fmpq_poly_t(fmpq_poly_t result, const CanonicalForm &f)
conversion of a factory univariate polynomials over Q to fmpq_poly_t
void convertFacCF2Fmpz_poly_t(fmpz_poly_t result, const CanonicalForm &f)
conversion of a factory univariate polynomial over Z to a fmpz_poly_t
void convertCF2initFmpz(fmpz_t result, const CanonicalForm &f)
conversion of a factory integer to fmpz_t(init.)
void convertFacCF2Fq_poly_t(fq_poly_t result, const CanonicalForm &f, const fq_ctx_t ctx)
conversion of a factory univariate poly over F_q (for non-word size p) to a FLINT fq_poly_t
This file defines functions for conversion to FLINT (www.flintlib.org) and back.
ZZX convertFacCF2NTLZZX(const CanonicalForm &f)
zz_pEX convertFacCF2NTLzz_pEX(const CanonicalForm &f, const zz_pX &mipo)
CanonicalForm convertNTLzz_pEX2CF(const zz_pEX &f, const Variable &x, const Variable &alpha)
ZZ_pEX convertFacCF2NTLZZ_pEX(const CanonicalForm &f, const ZZ_pX &mipo)
CanonicalForm in Z_p(a)[X] to NTL ZZ_pEX.
CanonicalForm convertNTLzzpX2CF(const zz_pX &poly, const Variable &x)
CanonicalForm convertNTLZZpX2CF(const ZZ_pX &poly, const Variable &x)
NAME: convertNTLZZpX2CF.
CanonicalForm convertNTLZZX2CF(const ZZX &polynom, const Variable &x)
CanonicalForm convertNTLZZ_pEX2CF(const ZZ_pEX &f, const Variable &x, const Variable &alpha)
zz_pX convertFacCF2NTLzzpX(const CanonicalForm &f)
ZZ_pX convertFacCF2NTLZZpX(const CanonicalForm &f)
NAME: convertFacCF2NTLZZpX.
ZZ convertFacCF2NTLZZ(const CanonicalForm &f)
NAME: convertFacCF2NTLZZX.
Conversion to and from NTL.
CanonicalForm cd(bCommonDen(FF))
CanonicalForm bCommonDen(const CanonicalForm &f)
CanonicalForm bCommonDen ( const CanonicalForm & f )
bool fdivides(const CanonicalForm &f, const CanonicalForm &g)
bool fdivides ( const CanonicalForm & f, const CanonicalForm & g )
declarations of higher level algorithms.
#define ASSERT(expression, message)
static const int SW_RATIONAL
set to 1 for computations over Q
#define GaloisFieldDomain
Iterators for CanonicalForm's.
class to iterate through CanonicalForm's
CF_NO_INLINE int exp() const
get the current exponent
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
CF_NO_INLINE int hasTerms() const
check if iterator has reached the end of CanonicalForm
factory's class for variables
class to do operations mod p^k for int's p and k
functions to print debug output
#define DEBOUTLN(stream, objects)
const CanonicalForm int const CFList const Variable & y
CanonicalForm divide(const CanonicalForm &ff, const CanonicalForm &f, const CFList &as)
const Variable & v
< [in] a sqrfree bivariate poly
fq_nmod_ctx_clear(fq_con)
nmod_poly_init(FLINTmipo, getCharacteristic())
fq_nmod_ctx_init_modulus(fq_con, FLINTmipo, "Z")
fq_nmod_poly_init(prod, fq_con)
convertFacCF2nmod_poly_t(FLINTmipo, M)
nmod_poly_clear(FLINTmipo)
fq_nmod_poly_clear(prod, fq_con)
CanonicalForm mod(const CanonicalForm &F, const CFList &M)
reduce F modulo elements in M.
CanonicalForm uniReverse(const CanonicalForm &F, int d, const Variable &x)
void newtonDivrem(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Q, CanonicalForm &R)
division with remainder of univariate polynomials over Q and Q(a) using Newton inversion,...
void kronSubFq(fq_nmod_poly_t result, const CanonicalForm &A, int d, const fq_nmod_ctx_t fq_con)
CanonicalForm mulNTL(const CanonicalForm &F, const CanonicalForm &G, const modpk &b)
multiplication of univariate polys using FLINT/NTL over F_p, F_q, Z/p^k, Z/p^k[t]/(f),...
void divrem(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Q, CanonicalForm &R, const CFList &MOD)
division with remainder of F by G wrt Variable (1) modulo MOD. Uses an algorithm based on Burnikel,...
bool uniFdivides(const CanonicalForm &A, const CanonicalForm &B)
divisibility test for univariate polys
CanonicalForm divFLINTQ(const CanonicalForm &F, const CanonicalForm &G)
void kronSubQa(fmpz_poly_t result, const CanonicalForm &A, int d)
CanonicalForm reverseSubstFp(const nmod_poly_t F, int d)
static CFList split(const CanonicalForm &F, const int m, const Variable &x)
static void divrem32(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Q, CanonicalForm &R, const CFList &M)
CanonicalForm mulMod2FLINTQ(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M)
CanonicalForm reverse(const CanonicalForm &F, int d)
CanonicalForm mulMod2(const CanonicalForm &A, const CanonicalForm &B, const CanonicalForm &M)
Karatsuba style modular multiplication for bivariate polynomials.
CanonicalForm mulMod2FLINTFqReci(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M, const Variable &alpha, const fq_nmod_ctx_t fq_con)
CanonicalForm mulFLINTQ(const CanonicalForm &F, const CanonicalForm &G)
CanonicalForm mulMod2FLINTFpReci(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M)
CanonicalForm mulMod2FLINTFq(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M, const Variable &alpha, const fq_nmod_ctx_t fq_con)
CanonicalForm reverseSubstReciproFq(const fq_nmod_poly_t F, const fq_nmod_poly_t G, int d, int k, const Variable &alpha, const fq_nmod_ctx_t fq_con)
CanonicalForm modFLINTQ(const CanonicalForm &F, const CanonicalForm &G)
void kronSubReciproQ(fmpz_poly_t subA1, fmpz_poly_t subA2, const CanonicalForm &A, int d)
void kronSubReciproFq(fq_nmod_poly_t subA1, fq_nmod_poly_t subA2, const CanonicalForm &A, int d, const fq_nmod_ctx_t fq_con)
CanonicalForm reverseSubstQ(const fmpz_poly_t F, int d)
CanonicalForm mulMod2FLINTQReci(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M)
CanonicalForm reverseSubstFq(const fq_nmod_poly_t F, int d, const Variable &alpha, const fq_nmod_ctx_t fq_con)
CanonicalForm mulMod(const CanonicalForm &A, const CanonicalForm &B, const CFList &MOD)
Karatsuba style modular multiplication for multivariate polynomials.
CanonicalForm mulFLINTQTrunc(const CanonicalForm &F, const CanonicalForm &G, int m)
CanonicalForm mulFLINTQa(const CanonicalForm &F, const CanonicalForm &G, const Variable &alpha)
CanonicalForm reverseSubstReciproQ(const fmpz_poly_t F, const fmpz_poly_t G, int d, int k)
static void divrem21(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Q, CanonicalForm &R, const CFList &M)
CanonicalForm newtonInverse(const CanonicalForm &F, const int n, const Variable &x)
void newtonDiv(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Q)
void divrem2(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Q, CanonicalForm &R, const CanonicalForm &M)
division with remainder of F by G wrt Variable (1) modulo M. Uses an algorithm based on Burnikel,...
CanonicalForm reverseSubstQa(const fmpz_poly_t F, int d, const Variable &x, const Variable &alpha, const CanonicalForm &den)
void kronSubReciproFp(nmod_poly_t subA1, nmod_poly_t subA2, const CanonicalForm &A, int d)
CanonicalForm divNTL(const CanonicalForm &F, const CanonicalForm &G, const modpk &b)
division of univariate polys using FLINT/NTL over F_p, F_q, Z/p^k, Z/p^k[t]/(f), Z,...
CanonicalForm mulFLINTQaTrunc(const CanonicalForm &F, const CanonicalForm &G, const Variable &alpha, int m)
CanonicalForm modNTL(const CanonicalForm &F, const CanonicalForm &G, const modpk &b)
mod of univariate polys using FLINT/NTL over F_p, F_q, Z/p^k, Z/p^k[t]/(f), Z, Q, Q(a),...
CanonicalForm prodMod(const CFList &L, const CanonicalForm &M)
product of all elements in L modulo M via divide-and-conquer.
CanonicalForm reverseSubstReciproFp(const nmod_poly_t F, const nmod_poly_t G, int d, int k)
void kronSubFp(nmod_poly_t result, const CanonicalForm &A, int d)
CanonicalForm mulMod2FLINTFp(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M)
CanonicalForm mulMod2NTLFq(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M)
CanonicalForm mulMod2FLINTQa(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M)
This file defines functions for fast multiplication and division with remainder.
CanonicalForm getMipo(const Variable &alpha, const Variable &x)
some useful template functions.
template CanonicalForm tmax(const CanonicalForm &, const CanonicalForm &)
template CanonicalForm tmin(const CanonicalForm &, const CanonicalForm &)
template List< Variable > Difference(const List< Variable > &, const List< Variable > &)
void rem(unsigned long *a, unsigned long *q, unsigned long p, int °a, int degq)
gmp_float exp(const gmp_float &a)
The main handler for Singular numbers which are suitable for Singular polynomials.
int status int void * buf
int F1(int a1, int &r1)
F1.
void F2(int a2, int &r2)
F2.
bool getReduce(const Variable &alpha)