34#include <NTL/lzz_pEX.h>
40#include "flint/fq_nmod_vec.h"
41#include "flint/fmpz_mod.h"
45#if defined(HAVE_NTL) || defined(HAVE_FLINT)
51 fmpz_poly_init2 (
result, d*(degAy + 1));
52 _fmpz_poly_set_length (
result, d*(degAy + 1));
56 if (
i.coeff().inBaseDomain())
59 for (
j=
i.coeff();
j.hasTerms();
j++)
63 _fmpz_poly_normalise(
result);
73 int degf= fmpz_poly_degree (F);
86 repLength= degfSubK + 1;
88 fmpq_poly_init2 (
buf, repLength);
89 _fmpq_poly_set_length (
buf, repLength);
90 _fmpz_vec_set (
buf->coeffs, F->coeffs +
k, repLength);
91 _fmpq_poly_normalise (
buf);
95 fmpq_poly_clear (
buf);
99 fmpq_poly_clear (
mipo);
118 int d= degAa + 1 + degBa;
120 fmpz_poly_t FLINTA,FLINTB;
124 fmpz_poly_mul (FLINTA, FLINTA, FLINTB);
129 fmpz_poly_clear (FLINTA);
130 fmpz_poly_clear (FLINTB);
145 fmpz_poly_t FLINTA,FLINTB;
148 fmpz_poly_mul (FLINTA, FLINTA, FLINTB);
152 fmpz_poly_clear (FLINTA);
153 fmpz_poly_clear (FLINTB);
181 fmpq_poly_t FLINTA,FLINTB;
185 fmpq_poly_div (FLINTA, FLINTA, FLINTB);
188 fmpq_poly_clear (FLINTA);
189 fmpq_poly_clear (FLINTB);
199 fmpq_poly_t FLINTA,FLINTB;
203 fmpq_poly_rem (FLINTA, FLINTA, FLINTB);
206 fmpq_poly_clear (FLINTA);
207 fmpq_poly_clear (FLINTB);
226 int d= degAa + 1 + degBa;
228 fmpz_poly_t FLINTA,FLINTB;
233 fmpz_poly_mullow (FLINTA, FLINTA, FLINTB,
k);
237 fmpz_poly_clear (FLINTA);
238 fmpz_poly_clear (FLINTB);
249 if (
G.inCoeffDomain())
263 fmpz_poly_t FLINTA,FLINTB;
266 fmpz_poly_mullow (FLINTA, FLINTA, FLINTB,
m);
270 fmpz_poly_clear (FLINTA);
271 fmpz_poly_clear (FLINTB);
284 while (d -
i.exp() < 0)
287 for (;
i.hasTerms() && (d -
i.exp() >= 0);
i++)
304 ASSERT (F.
mvar() ==
x,
"main variable of F and x differ");
305 ASSERT (!
g.isZero(),
"expected a unit");
318 for (
int i= 1;
i <=
l;
i++)
351 ASSERT (F.
level() ==
G.level(),
"F and G have different level");
384 ASSERT (F.
level() ==
G.level(),
"F and G have different level");
432#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
434 fmpz_mod_poly_t FLINTmipo;
436 fq_poly_t FLINTF, FLINTG;
444 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
445 fmpz_mod_ctx_t fmpz_ctx;
446 fmpz_mod_ctx_init(fmpz_ctx,FLINTp);
447 fq_ctx_init_modulus (
fq_con, FLINTmipo, fmpz_ctx,
"Z");
449 fq_ctx_init_modulus (
fq_con, FLINTmipo,
"Z");
455 fq_poly_mul (FLINTF, FLINTF, FLINTG,
fq_con);
461 fq_poly_clear (FLINTF,
fq_con);
462 fq_poly_clear (FLINTG,
fq_con);
464 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
465 fmpz_mod_poly_clear (FLINTmipo,fmpz_ctx);
466 fmpz_mod_ctx_clear(fmpz_ctx);
468 fmpz_mod_poly_clear(FLINTmipo);
478 mul (NTLf, NTLf, NTLg);
498 fmpz_mod_poly_t FLINTF, FLINTG;
501 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
502 fmpz_mod_ctx_t fmpz_ctx;
503 fmpz_mod_ctx_init(fmpz_ctx,FLINTpk);
504 fmpz_mod_poly_mul (FLINTF, FLINTF, FLINTG, fmpz_ctx);
506 fmpz_mod_poly_mul (FLINTF, FLINTF, FLINTG);
509 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
510 fmpz_mod_poly_clear (FLINTG,fmpz_ctx);
511 fmpz_mod_poly_clear (FLINTF,fmpz_ctx);
512 fmpz_mod_ctx_clear(fmpz_ctx);
514 fmpz_mod_poly_clear (FLINTG);
515 fmpz_mod_poly_clear (FLINTF);
517 fmpz_clear (FLINTpk);
528 ZZ_pX NTLf= to_ZZ_pX (ZZf);
529 ZZ_pX NTLg= to_ZZ_pX (ZZg);
530 mul (NTLf, NTLf, NTLg);
542#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
544 fmpz_mod_poly_t FLINTmipo;
558 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
559 fmpz_mod_ctx_t fmpz_ctx;
560 fmpz_mod_ctx_init(fmpz_ctx,FLINTp);
561 fq_ctx_init_modulus (
fq_con, FLINTmipo, fmpz_ctx,
"Z");
563 fq_ctx_init_modulus (
fq_con, FLINTmipo,
"Z");
575 fq_poly_scalar_mul_fq (FLINTG, FLINTG, FLINTF,
fq_con);
578 fmpz_poly_clear (FLINTF);
579 fq_poly_clear (FLINTG,
fq_con);
589 fq_poly_scalar_mul_fq (FLINTF, FLINTF, FLINTG,
fq_con);
592 fmpz_poly_clear (FLINTG);
593 fq_poly_clear (FLINTF,
fq_con);
602 fq_mul (FLINTF, FLINTF, FLINTG,
fq_con);
605 fq_clear (FLINTF,
fq_con);
606 fq_clear (FLINTG,
fq_con);
610 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
611 fmpz_mod_poly_clear (FLINTmipo,fmpz_ctx);
612 fmpz_mod_ctx_clear(fmpz_ctx);
614 fmpz_mod_poly_clear (FLINTmipo);
629 mul (NTLg, to_ZZ_pE (NTLf), NTLg);
636 mul (NTLf, NTLf, to_ZZ_pE (NTLg));
644 mul (
result, to_ZZ_pE (NTLg), to_ZZ_pE (NTLf));
657 ASSERT (F.
level() ==
G.level(),
"expected polys of same level");
659#if (!defined(HAVE_FLINT) || __FLINT_RELEASE < 20400)
678#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
679 nmod_poly_t FLINTmipo;
687 fq_nmod_poly_t FLINTF, FLINTG;
691 fq_nmod_poly_mul (FLINTF, FLINTF, FLINTG,
fq_con);
700#elif defined(AHVE_NTL)
705 mul (NTLF, NTLF, NTLG);
713 nmod_poly_t FLINTF, FLINTG;
716 nmod_poly_mul (FLINTF, FLINTF, FLINTG);
725 mul (NTLF, NTLF, NTLG);
767 fmpz_mod_poly_t FLINTF, FLINTG;
770 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
771 fmpz_mod_ctx_t fmpz_ctx;
772 fmpz_mod_ctx_init(fmpz_ctx,FLINTpk);
773 fmpz_mod_poly_divrem (FLINTG, FLINTF, FLINTF, FLINTG, fmpz_ctx);
775 fmpz_mod_poly_divrem (FLINTG, FLINTF, FLINTF, FLINTG);
778 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
779 fmpz_mod_poly_clear (FLINTG, fmpz_ctx);
780 fmpz_mod_poly_clear (FLINTF, fmpz_ctx);
781 fmpz_mod_ctx_clear(fmpz_ctx);
783 fmpz_mod_poly_clear (FLINTG);
784 fmpz_mod_poly_clear (FLINTF);
786 fmpz_clear (FLINTpk);
796 ZZ_pX NTLf= to_ZZ_pX (ZZf);
797 ZZ_pX NTLg= to_ZZ_pX (ZZg);
798 rem (NTLf, NTLf, NTLg);
808#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
810 fmpz_mod_poly_t FLINTmipo;
812 fq_poly_t FLINTF, FLINTG;
826 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
827 fmpz_mod_ctx_t fmpz_ctx;
828 fmpz_mod_ctx_init(fmpz_ctx,FLINTp);
829 fq_ctx_init_modulus (
fq_con, FLINTmipo, fmpz_ctx,
"Z");
831 fq_ctx_init_modulus (
fq_con, FLINTmipo,
"Z");
837 fq_poly_rem (FLINTF, FLINTF, FLINTG,
fq_con);
843 fq_poly_clear (FLINTF,
fq_con);
844 fq_poly_clear (FLINTG,
fq_con);
846 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
847 fmpz_mod_poly_clear (FLINTmipo, fmpz_ctx);
848 fmpz_mod_ctx_clear(fmpz_ctx);
850 fmpz_mod_poly_clear (FLINTmipo);
860 rem (NTLf, NTLf, NTLg);
875 ASSERT (F.
level() ==
G.level(),
"expected polys of same level");
876#if (!defined(HAVE_FLINT) || __FLINT_RELEASE < 20400)
887#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
888 nmod_poly_t FLINTmipo;
896 fq_nmod_poly_t FLINTF, FLINTG;
900 fq_nmod_poly_rem (FLINTF, FLINTF, FLINTG,
fq_con);
913 rem (NTLF, NTLF, NTLG);
920 nmod_poly_t FLINTF, FLINTG;
923 nmod_poly_divrem (FLINTG, FLINTF, FLINTF, FLINTG);
930 rem (NTLF, NTLF, NTLG);
955#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
957 fmpz_mod_poly_t FLINTmipo;
966 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
967 fmpz_mod_ctx_t fmpz_ctx;
968 fmpz_mod_ctx_init(fmpz_ctx,FLINTp);
969 fq_ctx_init_modulus (
fq_con, FLINTmipo, fmpz_ctx,
"Z");
971 fq_ctx_init_modulus (
fq_con, FLINTmipo,
"Z");
977 fq_inv (FLINTG, FLINTG,
fq_con);
978 fq_mul (FLINTF, FLINTF, FLINTG,
fq_con);
983 fq_clear (FLINTF,
fq_con);
984 fq_clear (FLINTG,
fq_con);
986 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
987 fmpz_mod_poly_clear (FLINTmipo, fmpz_ctx);
988 fmpz_mod_ctx_clear(fmpz_ctx);
990 fmpz_mod_poly_clear (FLINTmipo);
1000 div (
result, to_ZZ_pE (NTLf), to_ZZ_pE (NTLg));
1004 return b(
div (F,
G));
1012 if (!
G.inBaseDomain())
1016#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
1018 fmpz_mod_poly_t FLINTmipo;
1028 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
1029 fmpz_mod_ctx_t fmpz_ctx;
1030 fmpz_mod_ctx_init(fmpz_ctx,FLINTp);
1031 fq_ctx_init_modulus (
fq_con, FLINTmipo, fmpz_ctx,
"Z");
1033 fq_ctx_init_modulus (
fq_con, FLINTmipo,
"Z");
1039 fq_inv (FLINTG, FLINTG,
fq_con);
1040 fq_poly_scalar_mul_fq (FLINTF, FLINTF, FLINTG,
fq_con);
1045 fmpz_clear (FLINTp);
1046 fq_poly_clear (FLINTF,
fq_con);
1047 fq_clear (FLINTG,
fq_con);
1049 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
1050 fmpz_mod_poly_clear (FLINTmipo, fmpz_ctx);
1051 fmpz_mod_ctx_clear(fmpz_ctx);
1053 fmpz_mod_poly_clear (FLINTmipo);
1062 div (NTLf, NTLf, to_ZZ_pE (NTLg));
1066 return b(
div (F,
G));
1081 fmpz_init (FLINTpk);
1083 fmpz_mod_poly_t FLINTF, FLINTG;
1086 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
1087 fmpz_mod_ctx_t fmpz_ctx;
1088 fmpz_mod_ctx_init(fmpz_ctx,FLINTpk);
1089 fmpz_mod_poly_divrem (FLINTF, FLINTG, FLINTF, FLINTG, fmpz_ctx);
1091 fmpz_mod_poly_divrem (FLINTF, FLINTG, FLINTF, FLINTG);
1094 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
1095 fmpz_mod_poly_clear (FLINTG, fmpz_ctx);
1096 fmpz_mod_poly_clear (FLINTF, fmpz_ctx);
1097 fmpz_mod_ctx_clear(fmpz_ctx);
1099 fmpz_mod_poly_clear (FLINTG);
1100 fmpz_mod_poly_clear (FLINTF);
1102 fmpz_clear (FLINTpk);
1112 ZZ_pX NTLf= to_ZZ_pX (ZZf);
1113 ZZ_pX NTLg= to_ZZ_pX (ZZg);
1114 div (NTLf, NTLf, NTLg);
1124#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
1126 fmpz_mod_poly_t FLINTmipo;
1128 fq_poly_t FLINTF, FLINTG;
1135 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
1136 fmpz_mod_ctx_t fmpz_ctx;
1137 fmpz_mod_ctx_init(fmpz_ctx,FLINTp);
1138 fq_ctx_init_modulus (
fq_con, FLINTmipo, fmpz_ctx,
"Z");
1140 fq_ctx_init_modulus (
fq_con, FLINTmipo,
"Z");
1146 fq_poly_divrem (FLINTF, FLINTG, FLINTF, FLINTG,
fq_con);
1151 fmpz_clear (FLINTp);
1152 fq_poly_clear (FLINTF,
fq_con);
1153 fq_poly_clear (FLINTG,
fq_con);
1155 #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
1156 fmpz_mod_poly_clear (FLINTmipo, fmpz_ctx);
1157 fmpz_mod_ctx_clear(fmpz_ctx);
1159 fmpz_mod_poly_clear (FLINTmipo);
1168 div (NTLf, NTLf, NTLg);
1183 ASSERT (F.
level() ==
G.level(),
"expected polys of same level");
1184#if (!defined(HAVE_FLINT) || __FLINT_RELEASE < 20400)
1195#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
1196 nmod_poly_t FLINTmipo;
1204 fq_nmod_poly_t FLINTF, FLINTG;
1208 fq_nmod_poly_divrem (FLINTF, FLINTG, FLINTF, FLINTG,
fq_con);
1221 div (NTLF, NTLF, NTLG);
1228 nmod_poly_t FLINTF, FLINTG;
1231 nmod_poly_div (FLINTF, FLINTF, FLINTG);
1238 div (NTLF, NTLF, NTLG);
1254 result->length= d*(degAy + 1);
1255 flint_mpn_zero (
result->coeffs, d*(degAy+1));
1264 flint_mpn_copyi (
result->coeffs+
k,
buf->coeffs, nmod_poly_length(
buf));
1268 _nmod_poly_normalise (
result);
1271#if ( __FLINT_RELEASE >= 20400)
1274 const fq_nmod_ctx_t
fq_con)
1278 _fq_nmod_poly_set_length (
result, d*(degAy + 1),
fq_con);
1279 _fq_nmod_vec_zero (
result->coeffs, d*(degAy + 1),
fq_con);
1281 fq_nmod_poly_t
buf1;
1289 if (
i.coeff().inCoeffDomain())
1358 fmpz_poly_init2 (
result, d1*(degAy + 1));
1359 _fmpz_poly_set_length (
result, d1*(degAy + 1));
1367 if (
i.coeff().inCoeffDomain())
1371 _fmpz_vec_set (
result->coeffs +
k,
buf->coeffs,
buf->length);
1372 fmpz_poly_clear (
buf);
1376 for (
j=
i.coeff();
j.hasTerms();
j++)
1381 _fmpz_vec_set (
result->coeffs +
k,
buf->coeffs,
buf->length);
1382 fmpz_poly_clear (
buf);
1386 _fmpz_poly_normalise (
result);
1400 int k, kk,
j, bufRepLength;
1406 kk= (degAy -
i.exp())*d;
1407 bufRepLength= (int) nmod_poly_length (
buf);
1408 for (
j= 0;
j < bufRepLength;
j++)
1410 nmod_poly_set_coeff_ui (subA1,
j +
k,
1411 n_addmod (nmod_poly_get_coeff_ui (subA1,
j+
k),
1412 nmod_poly_get_coeff_ui (
buf,
j),
1416 nmod_poly_set_coeff_ui (subA2,
j + kk,
1417 n_addmod (nmod_poly_get_coeff_ui (subA2,
j + kk),
1418 nmod_poly_get_coeff_ui (
buf,
j),
1425 _nmod_poly_normalise (subA1);
1426 _nmod_poly_normalise (subA2);
1429#if ( __FLINT_RELEASE >= 20400)
1435 fq_nmod_poly_init2 (subA1, d*(degAy + 2),
fq_con);
1436 fq_nmod_poly_init2 (subA2, d*(degAy + 2),
fq_con);
1438 _fq_nmod_poly_set_length (subA1, d*(degAy + 2),
fq_con);
1439 _fq_nmod_vec_zero (subA1->coeffs, d*(degAy + 2),
fq_con);
1441 _fq_nmod_poly_set_length (subA2, d*(degAy + 2),
fq_con);
1442 _fq_nmod_vec_zero (subA2->coeffs, d*(degAy + 2),
fq_con);
1444 fq_nmod_poly_t
buf1;
1451 if (
i.coeff().inCoeffDomain())
1462 kk= (degAy -
i.exp())*d;
1463 _fq_nmod_vec_add (subA1->coeffs+
k, subA1->coeffs+
k,
buf1->coeffs,
1465 _fq_nmod_vec_add (subA2->coeffs+kk, subA2->coeffs+kk,
buf1->coeffs,
1470 _fq_nmod_poly_normalise (subA1,
fq_con);
1471 _fq_nmod_poly_normalise (subA2,
fq_con);
1480 fmpz_poly_init2 (subA1, d*(degAy + 2));
1481 fmpz_poly_init2 (subA2, d*(degAy + 2));
1491 kk= (degAy -
i.exp())*d;
1492 _fmpz_vec_add (subA1->coeffs+
k, subA1->coeffs +
k,
buf->coeffs,
buf->length);
1493 _fmpz_vec_add (subA2->coeffs+kk, subA2->coeffs + kk,
buf->coeffs,
buf->length);
1494 fmpz_poly_clear (
buf);
1497 _fmpz_poly_normalise (subA1);
1498 _fmpz_poly_normalise (subA2);
1509 int degf= fmpz_poly_degree(F);
1511 int degfSubK, repLength;
1518 repLength= degfSubK + 1;
1520 fmpz_poly_init2 (
buf, repLength);
1521 _fmpz_poly_set_length (
buf, repLength);
1522 _fmpz_vec_set (
buf->coeffs, F->coeffs+
k, repLength);
1523 _fmpz_poly_normalise (
buf);
1528 fmpz_poly_clear (
buf);
1608 const fmpq_poly_t
mipo)
1616 int degf= fmpz_poly_degree(F);
1626 repLength= degfSubK + 1;
1630 while (
j*d2 < repLength)
1632 fmpq_poly_init2 (
buf, d2);
1633 _fmpq_poly_set_length (
buf, d2);
1634 _fmpz_vec_set (
buf->coeffs, F->coeffs +
k +
j*d2, d2);
1635 _fmpq_poly_normalise (
buf);
1639 fmpq_poly_clear (
buf);
1641 if (repLength -
j*d2 != 0 &&
j*d2 - repLength < d2)
1645 fmpq_poly_init2 (
buf, repLength);
1646 _fmpq_poly_set_length (
buf, repLength);
1648 _fmpz_vec_set (
buf->coeffs, F->coeffs +
k +
j*d2, repLength);
1649 _fmpq_poly_normalise (
buf);
1652 fmpq_poly_clear (
buf);
1673 nmod_poly_set (
f, F);
1674 nmod_poly_set (
g,
G);
1675 int degf= nmod_poly_degree(
f);
1676 int degg= nmod_poly_degree(
g);
1681 if (nmod_poly_length (
f) < (
long) d*(
k+1))
1682 nmod_poly_fit_length (
f,(
long)d*(
k+1));
1688 int degfSubLf= degf;
1689 int deggSubLg=
degg-lg;
1690 int repLengthBuf2, repLengthBuf1, ind, tmp;
1691 while (degf >= lf || lg >= 0)
1695 else if (degfSubLf < 0)
1698 repLengthBuf1= degfSubLf + 1;
1701 for (ind= 0; ind < repLengthBuf1; ind++)
1702 nmod_poly_set_coeff_ui (
buf1, ind, nmod_poly_get_coeff_ui (
f, ind+lf));
1703 _nmod_poly_normalise (
buf1);
1705 repLengthBuf1= nmod_poly_length (
buf1);
1707 if (deggSubLg >= d - 1)
1708 repLengthBuf2= d - 1;
1709 else if (deggSubLg < 0)
1712 repLengthBuf2= deggSubLg + 1;
1715 for (ind= 0; ind < repLengthBuf2; ind++)
1716 nmod_poly_set_coeff_ui (
buf2, ind, nmod_poly_get_coeff_ui (
g, ind + lg));
1718 _nmod_poly_normalise (
buf2);
1719 repLengthBuf2= nmod_poly_length (
buf2);
1722 for (ind= 0; ind < repLengthBuf1; ind++)
1723 nmod_poly_set_coeff_ui (buf3, ind, nmod_poly_get_coeff_ui (
buf1, ind));
1724 for (ind= repLengthBuf1; ind < d; ind++)
1725 nmod_poly_set_coeff_ui (buf3, ind, 0);
1726 for (ind= 0; ind < repLengthBuf2; ind++)
1727 nmod_poly_set_coeff_ui (buf3, ind+d, nmod_poly_get_coeff_ui (
buf2, ind));
1728 _nmod_poly_normalise (buf3);
1735 degfSubLf= degf - lf;
1738 deggSubLg=
degg - lg;
1740 if (lg >= 0 && deggSubLg > 0)
1742 if (repLengthBuf2 > degfSubLf + 1)
1743 degfSubLf= repLengthBuf2 - 1;
1744 tmp=
tmin (repLengthBuf1, deggSubLg + 1);
1745 for (ind= 0; ind < tmp; ind++)
1746 nmod_poly_set_coeff_ui (
g, ind + lg,
1747 n_submod (nmod_poly_get_coeff_ui (
g, ind + lg),
1748 nmod_poly_get_coeff_ui (
buf1, ind),
1762 for (ind= 0; ind < repLengthBuf2; ind++)
1763 nmod_poly_set_coeff_ui (
f, ind + lf,
1764 n_submod (nmod_poly_get_coeff_ui (
f, ind + lf),
1765 nmod_poly_get_coeff_ui (
buf2, ind),
1781#if ( __FLINT_RELEASE >= 20400)
1789 fq_nmod_poly_t
f,
g;
1790 int degf= fq_nmod_poly_degree(F,
fq_con);
1797 fq_nmod_poly_set (
f, F,
fq_con);
1799 if (fq_nmod_poly_length (
f,
fq_con) < (
long) d*(
k + 1))
1800 fq_nmod_poly_fit_length (
f, (
long) d*(
k + 1),
fq_con);
1806 int degfSubLf= degf;
1807 int deggSubLg=
degg-lg;
1808 int repLengthBuf2, repLengthBuf1, tmp;
1809 while (degf >= lf || lg >= 0)
1813 else if (degfSubLf < 0)
1816 repLengthBuf1= degfSubLf + 1;
1817 fq_nmod_poly_init2 (
buf1, repLengthBuf1,
fq_con);
1818 _fq_nmod_poly_set_length (
buf1, repLengthBuf1,
fq_con);
1820 _fq_nmod_vec_set (
buf1->coeffs,
f->coeffs + lf, repLengthBuf1,
fq_con);
1823 repLengthBuf1= fq_nmod_poly_length (
buf1,
fq_con);
1825 if (deggSubLg >= d - 1)
1826 repLengthBuf2= d - 1;
1827 else if (deggSubLg < 0)
1830 repLengthBuf2= deggSubLg + 1;
1832 fq_nmod_poly_init2 (
buf2, repLengthBuf2,
fq_con);
1833 _fq_nmod_poly_set_length (
buf2, repLengthBuf2,
fq_con);
1834 _fq_nmod_vec_set (
buf2->coeffs,
g->coeffs + lg, repLengthBuf2,
fq_con);
1837 repLengthBuf2= fq_nmod_poly_length (
buf2,
fq_con);
1839 fq_nmod_poly_init2 (buf3, repLengthBuf2 + d,
fq_con);
1840 _fq_nmod_poly_set_length (buf3, repLengthBuf2 + d,
fq_con);
1841 _fq_nmod_vec_set (buf3->coeffs,
buf1->coeffs, repLengthBuf1,
fq_con);
1842 _fq_nmod_vec_set (buf3->coeffs + d,
buf2->coeffs, repLengthBuf2,
fq_con);
1844 _fq_nmod_poly_normalise (buf3,
fq_con);
1851 degfSubLf= degf - lf;
1854 deggSubLg=
degg - lg;
1856 if (lg >= 0 && deggSubLg > 0)
1858 if (repLengthBuf2 > degfSubLf + 1)
1859 degfSubLf= repLengthBuf2 - 1;
1860 tmp=
tmin (repLengthBuf1, deggSubLg + 1);
1861 _fq_nmod_vec_sub (
g->coeffs + lg,
g->coeffs + lg,
buf1->
coeffs,
1872 _fq_nmod_vec_sub (
f->coeffs + lf,
f->coeffs + lf,
buf2->coeffs,
1895 fmpz_poly_set (
f, F);
1896 fmpz_poly_set (
g,
G);
1897 int degf= fmpz_poly_degree(
f);
1898 int degg= fmpz_poly_degree(
g);
1902 if (fmpz_poly_length (
f) < (
long) d*(
k+1))
1903 fmpz_poly_fit_length (
f,(
long)d*(
k+1));
1909 int degfSubLf= degf;
1910 int deggSubLg=
degg-lg;
1911 int repLengthBuf2, repLengthBuf1, ind, tmp;
1913 while (degf >= lf || lg >= 0)
1917 else if (degfSubLf < 0)
1920 repLengthBuf1= degfSubLf + 1;
1922 fmpz_poly_init2 (
buf1, repLengthBuf1);
1924 for (ind= 0; ind < repLengthBuf1; ind++)
1926 fmpz_poly_get_coeff_fmpz (
tmp1,
f, ind + lf);
1927 fmpz_poly_set_coeff_fmpz (
buf1, ind,
tmp1);
1929 _fmpz_poly_normalise (
buf1);
1931 repLengthBuf1= fmpz_poly_length (
buf1);
1933 if (deggSubLg >= d - 1)
1934 repLengthBuf2= d - 1;
1935 else if (deggSubLg < 0)
1938 repLengthBuf2= deggSubLg + 1;
1940 fmpz_poly_init2 (
buf2, repLengthBuf2);
1942 for (ind= 0; ind < repLengthBuf2; ind++)
1944 fmpz_poly_get_coeff_fmpz (
tmp1,
g, ind + lg);
1945 fmpz_poly_set_coeff_fmpz (
buf2, ind,
tmp1);
1948 _fmpz_poly_normalise (
buf2);
1949 repLengthBuf2= fmpz_poly_length (
buf2);
1951 fmpz_poly_init2 (buf3, repLengthBuf2 + d);
1952 for (ind= 0; ind < repLengthBuf1; ind++)
1954 fmpz_poly_get_coeff_fmpz (
tmp1,
buf1, ind);
1955 fmpz_poly_set_coeff_fmpz (buf3, ind,
tmp1);
1957 for (ind= repLengthBuf1; ind < d; ind++)
1958 fmpz_poly_set_coeff_ui (buf3, ind, 0);
1959 for (ind= 0; ind < repLengthBuf2; ind++)
1961 fmpz_poly_get_coeff_fmpz (
tmp1,
buf2, ind);
1962 fmpz_poly_set_coeff_fmpz (buf3, ind + d,
tmp1);
1964 _fmpz_poly_normalise (buf3);
1971 degfSubLf= degf - lf;
1974 deggSubLg=
degg - lg;
1976 if (lg >= 0 && deggSubLg > 0)
1978 if (repLengthBuf2 > degfSubLf + 1)
1979 degfSubLf= repLengthBuf2 - 1;
1980 tmp=
tmin (repLengthBuf1, deggSubLg + 1);
1981 for (ind= 0; ind < tmp; ind++)
1983 fmpz_poly_get_coeff_fmpz (
tmp1,
g, ind + lg);
1984 fmpz_poly_get_coeff_fmpz (
tmp2,
buf1, ind);
1986 fmpz_poly_set_coeff_fmpz (
g, ind + lg,
tmp1);
1991 fmpz_poly_clear (
buf1);
1992 fmpz_poly_clear (
buf2);
1993 fmpz_poly_clear (buf3);
1998 for (ind= 0; ind < repLengthBuf2; ind++)
2000 fmpz_poly_get_coeff_fmpz (
tmp1,
f, ind + lf);
2001 fmpz_poly_get_coeff_fmpz (
tmp2,
buf2, ind);
2003 fmpz_poly_set_coeff_fmpz (
f, ind + lf,
tmp1);
2006 fmpz_poly_clear (
buf1);
2007 fmpz_poly_clear (
buf2);
2008 fmpz_poly_clear (buf3);
2011 fmpz_poly_clear (
f);
2012 fmpz_poly_clear (
g);
2019#if ( __FLINT_RELEASE >= 20400)
2022 const fq_nmod_ctx_t
fq_con)
2030 int degf= fq_nmod_poly_degree(F,
fq_con);
2032 int degfSubK, repLength;
2039 repLength= degfSubK + 1;
2041 fq_nmod_poly_init2 (
buf, repLength,
fq_con);
2042 _fq_nmod_poly_set_length (
buf, repLength,
fq_con);
2043 _fq_nmod_vec_set (
buf->coeffs, F->coeffs+
k, repLength,
fq_con);
2066 int degf= nmod_poly_degree(F);
2068 int degfSubK, repLength,
j;
2075 repLength= degfSubK + 1;
2078 for (
j= 0;
j < repLength;
j++)
2079 nmod_poly_set_coeff_ui (
buf,
j, nmod_poly_get_coeff_ui (F,
j +
k));
2080 _nmod_poly_normalise (
buf);
2106 nmod_poly_mullow (F1, F1, G1, (
long)
k);
2113 int b= nmod_poly_degree (F2) + nmod_poly_degree (G2) -
k - degtailF - degtailG
2114 + d1*(2+taildegF + taildegG);
2115 nmod_poly_mulhigh (F2, F2, G2,
b);
2116 nmod_poly_shift_right (F2, F2,
b);
2117 int d2=
tmax (nmod_poly_degree (F2)/d1, nmod_poly_degree (F1)/d1);
2140 int d1= degAx + 1 + degBx;
2141 int d2=
tmax (degAy, degBy);
2143 if (d1 > 128 && d2 > 160 && (degAy == degBy) && (2*degAy >
degree (
M)))
2146 nmod_poly_t FLINTA, FLINTB;
2151 nmod_poly_mullow (FLINTA, FLINTA, FLINTB, (
long)
k);
2160#if ( __FLINT_RELEASE >= 20400)
2164 const fq_nmod_ctx_t
fq_con)
2170 fq_nmod_poly_t F1, F2;
2173 fq_nmod_poly_t G1, G2;
2177 fq_nmod_poly_mullow (F1, F1, G1, (
long)
k,
fq_con);
2184 int b=
k + degtailF + degtailG - d1*(2+taildegF + taildegG);
2186 fq_nmod_poly_reverse (F2, F2, fq_nmod_poly_length (F2,
fq_con),
fq_con);
2187 fq_nmod_poly_reverse (G2, G2, fq_nmod_poly_length (G2,
fq_con),
fq_con);
2188 fq_nmod_poly_mullow (F2, F2, G2,
b+1,
fq_con);
2189 fq_nmod_poly_reverse (F2, F2,
b+1,
fq_con);
2191 int d2=
tmax (fq_nmod_poly_degree (F2,
fq_con)/d1,
2192 fq_nmod_poly_degree (F1,
fq_con)/d1);
2206 const fq_nmod_ctx_t
fq_con)
2215 int d1= degAx + 1 + degBx;
2216 int d2=
tmax (degAy, degBy);
2218 if (d1 > 128 && d2 > 160 && (degAy == degBy) && (2*degAy >
degree (
M)))
2221 fq_nmod_poly_t FLINTA, FLINTB;
2226 fq_nmod_poly_mullow (FLINTA, FLINTA, FLINTB, (
long)
k,
fq_con);
2251 fmpz_poly_mullow (F1, F1, G1, (
long)
k);
2258 int b= fmpz_poly_degree (F2) + fmpz_poly_degree (G2) -
k - degtailF - degtailG
2259 + d1*(2+taildegF + taildegG);
2260 fmpz_poly_mulhigh_n (F2, F2, G2,
b);
2261 fmpz_poly_shift_right (F2, F2,
b);
2262 int d2=
tmax (fmpz_poly_degree (F2)/d1, fmpz_poly_degree (F1)/d1);
2266 fmpz_poly_clear (F1);
2267 fmpz_poly_clear (F2);
2268 fmpz_poly_clear (G1);
2269 fmpz_poly_clear (G2);
2282 int d1= degAx + 1 + degBx;
2289 fmpz_poly_t FLINTA, FLINTB;
2294 fmpz_poly_mullow (FLINTA, FLINTA, FLINTB, (
long)
k);
2296 fmpz_poly_clear (FLINTA);
2297 fmpz_poly_clear (FLINTB);
2342 int degFx=
degree (F, 1);
2343 int degFa=
degree (F, a);
2347 int d2= degFa+degGa+1;
2348 int d1= degFx + 1 + degGx;
2356 fmpz_poly_t FLINTF, FLINTG;
2360 fmpz_poly_mullow (FLINTF, FLINTF, FLINTG, d1*
degree (
M));
2365 fmpz_poly_clear (FLINTF);
2366 fmpz_poly_clear (FLINTG);
2377 result.rep.SetLength (d*(degAy + 1));
2380 resultp=
result.rep.elts();
2383 int j,
k, bufRepLength;
2387 if (
i.coeff().inCoeffDomain())
2393 bufp=
buf.rep.elts();
2394 bufRepLength= (int)
buf.rep.length();
2395 for (
j= 0;
j < bufRepLength;
j++)
2396 resultp [
j +
k]= bufp [
j];
2404#if (!(HAVE_FLINT && __FLINT_RELEASE >= 20400))
2409 result.rep.SetLength (d*(degAy + 1));
2413 resultp=
result.rep.elts();
2418 int j,
k, buf1RepLength;
2422 if (
i.coeff().inCoeffDomain())
2431 buf1p=
buf1.rep.elts();
2432 buf1RepLength= (int)
buf1.rep.length();
2433 for (
j= 0;
j < buf1RepLength;
j++)
2434 resultp [
j +
k]= buf1p [
j];
2446 subA1.rep.SetLength ((
long) d*(degAy + 2));
2447 subA2.rep.SetLength ((
long) d*(degAy + 2));
2452 subA1p= subA1.rep.elts();
2453 subA2p= subA2.rep.elts();
2458 int j,
k, kk, bufRepLength;
2462 if (
i.coeff().inCoeffDomain())
2465 buf= to_zz_pEX (to_zz_pE (
buf2));
2471 kk= (degAy -
i.exp())*d;
2472 bufp=
buf.rep.elts();
2473 bufRepLength= (int)
buf.rep.length();
2474 for (
j= 0;
j < bufRepLength;
j++)
2476 subA1p [
j +
k] += bufp [
j];
2477 subA2p [
j + kk] += bufp [
j];
2490 subA1.rep.SetLength ((
long) d*(degAy + 2));
2491 subA2.rep.SetLength ((
long) d*(degAy + 2));
2495 subA1p= subA1.rep.elts();
2496 subA2p= subA2.rep.elts();
2499 int j,
k, kk, bufRepLength;
2506 kk= (degAy -
i.exp())*d;
2507 bufp=
buf.rep.elts();
2508 bufRepLength= (int)
buf.rep.length();
2509 for (
j= 0;
j < bufRepLength;
j++)
2511 subA1p [
j +
k] += bufp [
j];
2512 subA2p [
j + kk] += bufp [
j];
2520#if (!(HAVE_FLINT && __FLINT_RELEASE >= 20400))
2540 if (
f.rep.length() < (
long) d*(
k+1))
2541 f.rep.SetLength ((
long)d*(
k+1));
2543 zz_pE *
gp=
g.rep.elts();
2544 zz_pE *
fp=
f.rep.elts();
2549 int degfSubLf= degf;
2550 int deggSubLg=
degg-lg;
2551 int repLengthBuf2, repLengthBuf1, ind, tmp;
2552 zz_pE zzpEZero= zz_pE();
2554 while (degf >= lf || lg >= 0)
2558 else if (degfSubLf < 0)
2561 repLengthBuf1= degfSubLf + 1;
2562 buf1.rep.SetLength((
long) repLengthBuf1);
2564 buf1p=
buf1.rep.elts();
2565 for (ind= 0; ind < repLengthBuf1; ind++)
2566 buf1p [ind]=
fp [ind + lf];
2569 repLengthBuf1=
buf1.rep.length();
2571 if (deggSubLg >= d - 1)
2572 repLengthBuf2= d - 1;
2573 else if (deggSubLg < 0)
2576 repLengthBuf2= deggSubLg + 1;
2578 buf2.rep.SetLength ((
long) repLengthBuf2);
2579 buf2p=
buf2.rep.elts();
2580 for (ind= 0; ind < repLengthBuf2; ind++)
2581 buf2p [ind]=
gp [ind + lg];
2584 repLengthBuf2=
buf2.rep.length();
2586 buf3.rep.SetLength((
long) repLengthBuf2 + d);
2587 buf3p= buf3.rep.elts();
2588 buf2p=
buf2.rep.elts();
2589 buf1p=
buf1.rep.elts();
2590 for (ind= 0; ind < repLengthBuf1; ind++)
2591 buf3p [ind]= buf1p [ind];
2592 for (ind= repLengthBuf1; ind < d; ind++)
2593 buf3p [ind]= zzpEZero;
2594 for (ind= 0; ind < repLengthBuf2; ind++)
2595 buf3p [ind + d]= buf2p [ind];
2603 degfSubLf= degf - lf;
2606 deggSubLg=
degg - lg;
2608 buf1p=
buf1.rep.elts();
2610 if (lg >= 0 && deggSubLg > 0)
2612 if (repLengthBuf2 > degfSubLf + 1)
2613 degfSubLf= repLengthBuf2 - 1;
2614 tmp=
tmin (repLengthBuf1, deggSubLg + 1);
2615 for (ind= 0; ind < tmp; ind++)
2616 gp [ind + lg] -= buf1p [ind];
2622 buf2p=
buf2.rep.elts();
2625 for (ind= 0; ind < repLengthBuf2; ind++)
2626 fp [ind + lf] -= buf2p [ind];
2654 if (
f.rep.length() < (
long) d*(
k+1))
2655 f.rep.SetLength ((
long)d*(
k+1));
2657 zz_p *
gp=
g.rep.elts();
2658 zz_p *
fp=
f.rep.elts();
2663 int degfSubLf= degf;
2664 int deggSubLg=
degg-lg;
2665 int repLengthBuf2, repLengthBuf1, ind, tmp;
2666 zz_p zzpZero= zz_p();
2667 while (degf >= lf || lg >= 0)
2671 else if (degfSubLf < 0)
2674 repLengthBuf1= degfSubLf + 1;
2675 buf1.rep.SetLength((
long) repLengthBuf1);
2677 buf1p=
buf1.rep.elts();
2678 for (ind= 0; ind < repLengthBuf1; ind++)
2679 buf1p [ind]=
fp [ind + lf];
2682 repLengthBuf1=
buf1.rep.length();
2684 if (deggSubLg >= d - 1)
2685 repLengthBuf2= d - 1;
2686 else if (deggSubLg < 0)
2689 repLengthBuf2= deggSubLg + 1;
2691 buf2.rep.SetLength ((
long) repLengthBuf2);
2692 buf2p=
buf2.rep.elts();
2693 for (ind= 0; ind < repLengthBuf2; ind++)
2694 buf2p [ind]=
gp [ind + lg];
2698 repLengthBuf2=
buf2.rep.length();
2701 buf3.rep.SetLength((
long) repLengthBuf2 + d);
2702 buf3p= buf3.rep.elts();
2703 buf2p=
buf2.rep.elts();
2704 buf1p=
buf1.rep.elts();
2705 for (ind= 0; ind < repLengthBuf1; ind++)
2706 buf3p [ind]= buf1p [ind];
2707 for (ind= repLengthBuf1; ind < d; ind++)
2708 buf3p [ind]= zzpZero;
2709 for (ind= 0; ind < repLengthBuf2; ind++)
2710 buf3p [ind + d]= buf2p [ind];
2718 degfSubLf= degf - lf;
2721 deggSubLg=
degg - lg;
2723 buf1p=
buf1.rep.elts();
2725 if (lg >= 0 && deggSubLg > 0)
2727 if (repLengthBuf2 > degfSubLf + 1)
2728 degfSubLf= repLengthBuf2 - 1;
2729 tmp=
tmin (repLengthBuf1, deggSubLg + 1);
2730 for (ind= 0; ind < tmp; ind++)
2731 gp [ind + lg] -= buf1p [ind];
2736 buf2p=
buf2.rep.elts();
2739 for (ind= 0; ind < repLengthBuf2; ind++)
2740 fp [ind + lf] -= buf2p [ind];
2748#if (!(HAVE_FLINT && __FLINT_RELEASE >= 20400))
2755 zz_pE *
fp=
f.rep.elts();
2763 int degfSubK, repLength,
j;
2770 repLength= degfSubK + 1;
2772 buf.rep.SetLength ((
long) repLength);
2773 bufp=
buf.rep.elts();
2774 for (
j= 0;
j < repLength;
j++)
2775 bufp [
j]=
fp [
j +
k];
2794 zz_p *
fp=
f.rep.elts();
2802 int degfSubK, repLength,
j;
2809 repLength= degfSubK + 1;
2811 buf.rep.SetLength ((
long) repLength);
2812 bufp=
buf.rep.elts();
2813 for (
j= 0;
j < repLength;
j++)
2814 bufp [
j]=
fp [
j +
k];
2840 MulTrunc (F1, F1, G1, (
long)
k);
2846 int b=
k + degtailF + degtailG - d1*(2+taildegF+taildegG);
2850 MulTrunc (F2, F2, G2,
b + 1);
2853 int d2=
tmax (deg (F2)/d1, deg (F1)/d1);
2869 int d1= degAx + 1 + degBx;
2870 int d2=
tmax (degAy, degBy);
2872 if (d1 > 128 && d2 > 160 && (degAy == degBy) && (2*degAy >
degree (
M)))
2873 return mulMod2NTLFpReci (
A,
B,
M);
2879 MulTrunc (NTLA, NTLA, NTLB, (
long)
k);
2887#if (!(HAVE_FLINT && __FLINT_RELEASE >= 20400))
2903 MulTrunc (F1, F1, G1, (
long)
k);
2909 int b=
k + degtailF + degtailG - d1*(2+taildegF+taildegG);
2913 MulTrunc (F2, F2, G2,
b + 1);
2916 int d2=
tmax (deg (F2)/d1, deg (F1)/d1);
2937#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
2938 nmod_poly_t FLINTmipo;
2952 int d1= degAx + degBx + 1;
2953 int d2=
tmax (degAy, degBy);
2963 if ((d1 > 128/degMipo) && (d2 > 160/degMipo) && (degAy == degBy) &&
2965 return mulMod2NTLFqReci (
A,
B,
M,
alpha);
2972 MulTrunc (NTLA, NTLA, NTLB, (
long)
k);
2982 A= mulMod2NTLFp (
A,
B,
M);
2994 ASSERT (
M.isUnivariate(),
"M must be univariate");
3000 if (
G.inCoeffDomain())
3007 if ((degF < 1 && degG < 1) && (F.
isUnivariate() &&
G.isUnivariate()) &&
3008 (F.
level() ==
G.level()))
3013 else if (degF <= 1 && degG <= 1)
3019 int sizeF=
size (F);
3020 int sizeG=
size (
G);
3022 int fallBackToNaive= 50;
3023 if (sizeF < fallBackToNaive || sizeG < fallBackToNaive)
3026 return mod (
G*F,
M);
3028 return mod (F*
G,
M);
3037 (((degF-degG) < 50 && degF > degG) || ((degG-degF) < 50 && degF <= degG)))
3041 if (degF >=
m || degG >=
m)
3052 return F0G0 + MLo*(F0G1 + F1G0);
3065 return H11*yToM*yToM + (H01 - H11 - H00)*yToM + H00;
3067 DEBOUTLN (cerr,
"fatal end in mulMod2");
3096 if (
G.inCoeffDomain())
3099 int sizeF=
size (F);
3100 int sizeG=
size (
G);
3102 if (sizeF / MOD.
length() < 100 || sizeG / MOD.
length() < 100)
3105 return mod (
G*F, MOD);
3107 return mod (F*
G, MOD);
3114 if ((degF <= 1 && F.
level() <=
M.level()) &&
3115 (degG <= 1 &&
G.level() <=
M.level()))
3119 if (degF == 1 && degG == 1)
3130 return H11*
y*
y + (H01 - H00 - H11)*
y + H00;
3142 else if (degF == 1 && degG == 0)
3144 else if (degF == 0 && degG == 1)
3150 if (degF >=
m || degG >=
m)
3164 return F0G0 + MLo*(F0G1 + F1G0);
3168 m= (
tmax(degF, degG)+1)/2;
3177 return H11*yToM*yToM + (H01 - H11 - H00)*yToM + H00;
3179 DEBOUTLN (cerr,
"fatal end in mulMod");
3199 for (
int j= 1;
j <=
l;
j++,
i++)
3213 else if (L.
length() == 1)
3215 else if (L.
length() == 2)
3223 for (
int j= 1;
j <=
l;
j++,
i++)
3248 while (d -
i.exp() < 0)
3251 for (;
i.hasTerms() && (d -
i.exp() >= 0);
i++)
3266 ASSERT (!
g.isZero(),
"expected a unit");
3282 for (
int i= 1;
i <=
l;
i++)
3351#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
3352 nmod_poly_t FLINTmipo;
3361 fq_nmod_poly_t FLINTA, FLINTB;
3365 fq_nmod_poly_divrem (FLINTA, FLINTB, FLINTA, FLINTB,
fq_con);
3374 bool zz_pEbak= zz_pE::initialized();
3382 div (NTLA, NTLA, NTLB);
3434#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
3435 nmod_poly_t FLINTmipo;
3443 fq_nmod_poly_t FLINTA, FLINTB;
3447 fq_nmod_poly_divrem (FLINTA, FLINTB, FLINTA, FLINTB,
fq_con);
3462 DivRem (NTLQ, NTLR, NTLA, NTLB);
3478 else if (
x.
level() !=
A.level())
3489 while (
i.hasTerms() &&
i.exp() -
j*
m >= 0)
3532 int m= (int)
ceil ((
double) (degB + 1)/2.0) + 1;
3533 ASSERT (4*
m >= degA,
"expected degree (F, 1) < 2*degree (G, 1)");
3535 if (splitA.
length() == 3)
3537 if (splitA.
length() == 2)
3542 if (splitA.
length() == 1)
3564 if (splitR.
length() == 1)
3603 int m= (int)
ceil ((
double) (degB + 1)/ 2.0);
3604 ASSERT (3*
m > degA,
"expected degree (F, 1) < 3*degree (G, 1)");
3608 if (splitA.
length() == 2)
3612 if (splitA.
length() == 1)
3642 Q +=
LC (
R,
x)*xToM;
3701 H=
i.getItem()*xToDegB;
3711 H=
R*xToDegB +
i.getItem();
3745 H=
i.getItem()*xToDegB;
3753 H=
R*xToDegB +
i.getItem();
3772 if (
A.inCoeffDomain())
3779#if (!defined(HAVE_FLINT) || __FLINT_RELEASE < 20400)
3789#if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
3790 nmod_poly_t FLINTmipo;
3798 fq_nmod_poly_t FLINTA, FLINTB;
3801 int result= fq_nmod_poly_divides (FLINTA, FLINTB, FLINTA,
fq_con);
3812 return divide (NTLB, NTLA);
3816 nmod_poly_t FLINTA, FLINTB;
3819 nmod_poly_divrem (FLINTB, FLINTA, FLINTB, FLINTA);
3820 bool result= nmod_poly_is_zero (FLINTA);
3827 return divide (NTLB, NTLA);
3837 fmpq_poly_t FLINTA,FLINTB;
3840 fmpq_poly_rem (FLINTA, FLINTB, FLINTA);
3841 bool result= fmpq_poly_is_zero (FLINTA);
3842 fmpq_poly_clear (FLINTA);
3843 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
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.
const signed long floor(const ampf< Precision > &x)
const signed long ceil(const ampf< Precision > &x)
int status int void * buf
bool getReduce(const Variable &alpha)