36 #include <NTL/lzz_pEX.h> 49 #if (!(HAVE_FLINT && __FLINT_RELEASE >= 20400)) 59 zz_pE::init (NTLMipo);
62 v.SetLength (factors.
length());
66 if (
i.getItem().inCoeffDomain())
73 for (
int j= 0; j < factors.
length(); j++)
77 for (
int i= 0;
i < factors.
length();
i++, k++)
89 #if (HAVE_FLINT && __FLINT_RELEASE >= 20400) 93 nmod_poly_t FLINTmipo;
103 fq_nmod_poly_t *
vec=
new fq_nmod_poly_t [factors.
length()];
109 if (
i.getItem().inCoeffDomain())
112 fq_nmod_init2 (buf, fq_con);
114 fq_nmod_poly_set_coeff (vec[j], 0, buf, fq_con);
115 fq_nmod_clear (buf, fq_con);
127 fq_nmod_poly_one (prod, fq_con);
128 for (
int i= 0;
i < factors.
length();
i++, k++)
132 fq_nmod_poly_mul (prod, prod, vec[
i], fq_con);
136 for (j= 0; j < factors.
length(); j++)
153 CFList bufFactors= factors;
155 bufFactors.insert (factors.
getFirst () (0,2));
158 if (bufFactors.getFirst().inCoeffDomain())
170 #if (HAVE_FLINT && __FLINT_RELEASE >= 20400) 171 bufFactors= productsFLINT (bufFactors, M);
173 bufFactors= productsNTL (bufFactors, M);
180 buf1= bufFactors.getFirst();
190 zz_pE::init (NTLMipo);
191 zz_pEX NTLbuf1, NTLbuf2, NTLbuf3, NTLS, NTLT;
194 tryNTLXGCD (NTLbuf3, NTLS, NTLT, NTLbuf1, NTLbuf2, fail);
200 tryExtgcd (buf1, buf2, M, buf3, S, T, fail);
212 tryNTLXGCD (NTLbuf3, NTLS, NTLT, NTLbuf3, NTLbuf1, fail);
219 tryExtgcd (buf3, buf1, M, buf3, S, T, fail);
228 j.getItem()=
reduce (j.getItem(),
M);
248 if (
mod (
i.getItem(),
p) == 0)
300 i.getItem() /=
Lc (
i.getItem());
313 bound= (dummy >
bound) ? dummy : bound;
316 bound *= bound*
bound;
339 while ( i >= 0 &&
mod( leadingCoeffs, p ) == 0)
345 ASSERT (i >= 0,
"ran out of primes");
349 modMipo /=
lc (modMipo);
369 p, newResult, newQ );
384 if (j.getItem() != k.
getItem())
397 if (newQ > bound && equal)
416 i.getItem() *= denFirst;
422 test += ii.getItem()*(f/jj.
getItem());
479 recResult=
mapinto (recResult);
487 bufFactors[
k]=
i.getItem() (0);
489 bufFactors [
k]=
i.getItem();
492 for (k= 0; k < factors.
length(); k++)
495 for (
int l= 0;
l < factors.
length();
l++)
501 tmp=
mulNTL (tmp, bufFactors[
l]);
508 for (k= 0; k < factors.
length(); k++)
509 bufFactors [k]= bufFactors[k].
mapinto();
522 recResult=
mapinto (recResult);
528 for (
int i= 1;
i < d;
i++)
530 coeffE=
div (e, modulus);
541 for (; j.
hasItem(); j++, k++, l++, ii++)
544 g=
modNTL (coeffE, bufFactors[ii]);
546 g=
modNTL (g, bufFactors[ii]);
548 k.getItem() += g.mapinto()*modulus;
549 e -=
mulNTL (g.mapinto(), b2 (l.getItem()), b2)*modulus;
573 bool mipoHasDen=
false;
587 modMipo /=
lc (modMipo);
606 recResult=
mapinto (recResult);
615 bufFactors[
k]=
i.getItem() (0);
617 bufFactors [
k]=
i.getItem();
621 for (k= 0; k < factors.
length(); k++)
624 for (
int l= 0;
l < factors.
length();
l++)
629 tmp=
mulNTL (tmp, bufFactors[
l]);
652 modMipo /=
lc (modMipo);
657 for (k= 0; k < factors.
length(); k++)
659 bufFactors [
k]= bufFactors[
k].mapinto();
660 bufFactors [
k]=
replacevar (bufFactors[k], alpha, beta);
680 e=
b (e -
mulNTL (
i.getItem(), j.getItem(),
b));
701 recResult=
mapinto (recResult);
712 for (
int i= 1;
i < d;
i++)
714 coeffE=
div (e, modulus);
737 for (; j.hasItem(); j++, k++, l++, ii++)
740 g=
modNTL (coeffE, bufFactors[ii]);
741 g=
mulNTL (g, j.getItem());
742 g=
modNTL (g, bufFactors[ii]);
749 b2 (l.getItem()), b2)*modulus;
757 b2 (l.getItem()), b2)*modulus;
785 bool mipoHasDen=
false;
799 modMipo /=
lc (modMipo);
836 CFList bufFactors= factors;
855 buf2=
divNTL (F, i.getItem(),
b);
858 ZZ_pE::init (NTLmipo);
859 ZZ_pEX NTLS, NTLT, NTLbuf3;
862 XGCD (NTLbuf3, NTLS, NTLT, NTLbuf1, NTLbuf2);
867 for (; i.hasItem(); i++)
870 buf1=
divNTL (Freplaced, i.getItem(),
b);
872 buf1=
divNTL (F, i.getItem(),
b);
878 j.getItem()=
mulNTL (j.getItem(), S,
b);
917 buf3=
extgcd (buf1, buf2, S, T);
925 buf3=
extgcd (buf3, buf1, S, T);
929 j.getItem()=
mulNTL (j.getItem(), S);
958 E= F[
j] - Pi [factors.
length() - 2] [
j];
972 if (
degree (bufFactors[k], x) > 0)
975 remainder=
modNTL (E, bufFactors[k] [0], b);
980 remainder=
modNTL (E, bufFactors[k], b);
982 buf[
k]=
mulNTL (
i.getItem(), remainder,
b);
983 if (
degree (bufFactors[k], x) > 0)
984 buf[k]=
modNTL (buf[k], bufFactors[k] [0], b);
986 buf[
k]=
modNTL (buf[k], bufFactors[k], b);
988 for (k= 1; k < factors.
length(); k++)
990 bufFactors[
k] += xToJ*buf[
k];
992 bufFactors[k]=
b(bufFactors[k]);
996 int degBuf0=
degree (bufFactors[0], x);
997 int degBuf1=
degree (bufFactors[1], x);
998 if (degBuf0 > 0 && degBuf1 > 0)
999 M (j + 1, 1)=
mulNTL (bufFactors[0] [j], bufFactors[1] [j], b);
1002 if (degBuf0 > 0 && degBuf1 > 0)
1003 uIZeroJ=
mulNTL ((bufFactors[0] [0] + bufFactors[0] [j]),
1004 (bufFactors[1] [0] + buf[1]), b) -
M(1, 1) -
M(j + 1, 1);
1005 else if (degBuf0 > 0)
1006 uIZeroJ=
mulNTL (bufFactors[0] [j], bufFactors[1], b);
1007 else if (degBuf1 > 0)
1008 uIZeroJ=
mulNTL (bufFactors[0], buf[1], b);
1012 uIZeroJ= b (uIZeroJ);
1013 Pi [0] += xToJ*uIZeroJ;
1018 for (k= 0; k < factors.
length() - 1; k++)
1021 one= bufFactors [0];
1022 two= bufFactors [1];
1023 if (degBuf0 > 0 && degBuf1 > 0)
1025 for (k= 1; k <= (int) ceil (j/2.0); k++)
1032 tmp[0] +=
mulNTL ((bufFactors[0][k]+one.
coeff()), (bufFactors[1][k]+
1033 two.
coeff()), b) -
M (k + 1, 1) -
M (j - k + 2, 1);
1037 else if (one.
hasTerms() && one.
exp() == j - k + 1)
1039 tmp[0] +=
mulNTL ((bufFactors[0][k]+one.
coeff()), bufFactors[1][k], b)
1043 else if (two.
hasTerms() && two.
exp() == j - k + 1)
1045 tmp[0] +=
mulNTL (bufFactors[0][k], (bufFactors[1][k]+two.
coeff()), b)
1052 tmp[0] +=
M (k + 1, 1);
1058 Pi [0] += tmp[0]*xToJ*F.
mvar();
1062 for (
int l= 1;
l < factors.
length() - 1;
l++)
1064 degPi=
degree (Pi [
l - 1], x);
1065 degBuf=
degree (bufFactors[
l + 1], x);
1066 if (degPi > 0 && degBuf > 0)
1067 M (j + 1,
l + 1)=
mulNTL (Pi [
l - 1] [j], bufFactors[
l + 1] [j], b);
1070 if (degPi > 0 && degBuf > 0)
1071 Pi [
l] += xToJ*(
mulNTL (Pi [
l - 1] [0] + Pi [
l - 1] [j],
1072 bufFactors[
l + 1] [0] + buf[
l + 1], b) -
M (j + 1,
l +1) -
1075 Pi [
l] += xToJ*(
mulNTL (Pi [
l - 1] [j], bufFactors[
l + 1], b));
1076 else if (degBuf > 0)
1077 Pi [
l] += xToJ*(
mulNTL (Pi [
l - 1], buf[
l + 1], b));
1081 if (degPi > 0 && degBuf > 0)
1083 uIZeroJ=
mulNTL (uIZeroJ, bufFactors [
l + 1] [0], b);
1084 uIZeroJ +=
mulNTL (Pi [
l - 1] [0], buf [
l + 1], b);
1087 uIZeroJ=
mulNTL (uIZeroJ, bufFactors [
l + 1], b);
1088 else if (degBuf > 0)
1090 uIZeroJ=
mulNTL (uIZeroJ, bufFactors [
l + 1] [0], b);
1091 uIZeroJ +=
mulNTL (Pi [
l - 1], buf[
l + 1], b);
1093 Pi[
l] += xToJ*uIZeroJ;
1095 one= bufFactors [
l + 1];
1099 if (degBuf > 0 && degPi > 0)
1110 if (degBuf > 0 && degPi > 0)
1112 for (k= 1; k <= (int) ceil (j/2.0); k++)
1119 tmp[
l] +=
mulNTL ((bufFactors[
l+1][k] + one.
coeff()), (Pi[
l-1][k] +
1120 two.
coeff()),b) -
M (k + 1,
l + 1) -
M (j - k + 2,
l + 1);
1124 else if (one.
hasTerms() && one.
exp() == j - k + 1)
1126 tmp[
l] +=
mulNTL ((bufFactors[
l+1][k]+one.
coeff()), Pi[
l-1][k], b) -
1130 else if (two.
hasTerms() && two.
exp() == j - k + 1)
1132 tmp[
l] +=
mulNTL (bufFactors[
l+1][k], (Pi[
l-1][k] + two.
coeff()), b)
1138 tmp[
l] +=
M (k + 1,
l + 1);
1143 Pi[
l] += tmp[
l]*xToJ*F.
mvar();
1164 bool hasAlgVar2=
false;
1167 if (hasAlgVar && hasAlgVar2 && v!=w)
1175 DEBOUTLN (cerr,
"diophant= " << diophant);
1182 for (; j.hasItem(); j++, i++)
1184 Pi [
i]=
mulNTL (Pi [i - 1], j.getItem(),
b);
1185 M (1, i + 1)= Pi [
i];
1192 bufFactors[
i]=
mod (k.getItem(), F.
mvar());
1194 bufFactors[
i]= k.getItem();
1196 for (i= 1; i <
l; i++)
1197 henselStep12 (bufF, factors, bufFactors, diophant, M, Pi, i, b);
1200 for (i= 0; i < factors.
length (); i++, k++)
1210 henselLift12 (F, factors, l, Pi, diophant, M, dummy, sort);
1224 bufFactors[
i]=
mod (k.getItem(), xToStart);
1226 bufFactors[
i]= k.getItem();
1228 for (i= start; i < end; i++)
1229 henselStep12 (F, factors, bufFactors, diophant, M, Pi, i, b);
1232 for (i= 0; i < factors.
length(); k++, i++)
1252 i.getItem()=
mod (
i.getItem(),
y);
1263 bufFactors [
k]=
i.getItem();
1266 for (k= 0; k < factors.
length(); k++)
1269 if (
fdivides (bufFactors[k], F, quot))
1273 for (
int l= 0;
l < factors.
length();
l++)
1279 b=
mulMod2 (b, bufFactors[
l], yToD);
1296 for (
int i= 1;
i < d;
i++)
1308 for (; j.
hasItem(); j++, k++, l++, ii++)
1311 if (
degree (bufFactors[ii], y) <= 0)
1312 g=
mod (g, bufFactors[ii]);
1314 g=
mod (g, bufFactors[ii][0]);
1315 k.getItem() += g*
power (y,
i);
1317 DEBOUTLN (cerr,
"mod (e, power (y, i + 1))= " <<
1318 mod (e, power (y,
i + 1)));
1357 for (k= 0; k < factors.
length(); k++)
1360 if (
fdivides (bufFactors[k], F, quot))
1364 for (
int l= 0;
l < factors.
length();
l++)
1370 b=
mulMod (b, bufFactors[
l], buf);
1386 for (
int i= 1; i < d; i++)
1399 for (; j.
hasItem(); j++, k++, l++, ii++)
1402 if (
degree (bufFactors[ii], y) <= 0)
1406 divrem (g, bufFactors[ii][0], dummy, g, M);
1407 k.getItem() += g*
power (y, i);
1408 e -=
mulMod (g*power (y, i), l.getItem(),
M);
1421 DEBOUTLN (cerr,
"test in multiRecDiophantine= " << test);
1441 for (
int i= 0;
i < factors.
length();
i++)
1444 test=
mulMod (test,
mod (bufFactors [
i], xToJ), MOD);
1446 test=
mulMod (test, bufFactors[i], MOD);
1450 test2=
mod (test2, MOD);
1451 DEBOUTLN (cerr,
"test in henselStep= " << test2);
1458 for (
int i= 0;
i < factors.
length();
i++)
1461 test *=
mod (bufFactors [
i],
power (x, j));
1463 test *= bufFactors[
i];
1466 test=
mod (test, MOD);
1468 DEBOUTLN (cerr,
"test in henselStep= " << test2);
1472 E= F[
j] - Pi [factors.
length() - 2] [
j];
1484 if (
degree (bufFactors[k], x) > 0)
1487 divrem (E, bufFactors[k] [0], dummy, rest1, MOD);
1492 divrem (E, bufFactors[k], dummy, rest1, MOD);
1494 buf[
k]=
mulMod (
i.getItem(), rest1, MOD);
1496 if (
degree (bufFactors[k], x) > 0)
1497 divrem (buf[k], bufFactors[k] [0], dummy, buf[k], MOD);
1499 divrem (buf[k], bufFactors[k], dummy, buf[k], MOD);
1501 for (k= 1; k < factors.
length(); k++)
1502 bufFactors[k] += xToJ*buf[k];
1505 int degBuf0=
degree (bufFactors[0], x);
1506 int degBuf1=
degree (bufFactors[1], x);
1507 if (degBuf0 > 0 && degBuf1 > 0)
1508 M (j + 1, 1)=
mulMod (bufFactors[0] [j], bufFactors[1] [j], MOD);
1511 if (degBuf0 > 0 && degBuf1 > 0)
1512 uIZeroJ=
mulMod ((bufFactors[0] [0] + bufFactors[0] [j]),
1513 (bufFactors[1] [0] + buf[1]), MOD) -
M(1, 1) -
M(j + 1, 1);
1514 else if (degBuf0 > 0)
1515 uIZeroJ=
mulMod (bufFactors[0] [j], bufFactors[1], MOD);
1516 else if (degBuf1 > 0)
1517 uIZeroJ=
mulMod (bufFactors[0], buf[1], MOD);
1520 Pi [0] += xToJ*uIZeroJ;
1523 for (k= 0; k < factors.
length() - 1; k++)
1526 one= bufFactors [0];
1527 two= bufFactors [1];
1528 if (degBuf0 > 0 && degBuf1 > 0)
1530 for (k= 1; k <= (int) ceil (j/2.0); k++)
1537 tmp[0] +=
mulMod ((bufFactors[0] [k] + one.
coeff()),
1538 (bufFactors[1] [k] + two.
coeff()), MOD) -
M (k + 1, 1) -
1543 else if (one.
hasTerms() && one.
exp() == j - k + 1)
1545 tmp[0] +=
mulMod ((bufFactors[0] [k] + one.
coeff()),
1546 bufFactors[1] [k], MOD) -
M (k + 1, 1);
1549 else if (two.
hasTerms() && two.
exp() == j - k + 1)
1551 tmp[0] +=
mulMod (bufFactors[0] [k], (bufFactors[1] [k] +
1552 two.
coeff()), MOD) -
M (k + 1, 1);
1558 tmp[0] +=
M (k + 1, 1);
1562 Pi [0] += tmp[0]*xToJ*F.
mvar();
1566 for (
int l= 1;
l < factors.
length() - 1;
l++)
1568 degPi=
degree (Pi [
l - 1], x);
1569 degBuf=
degree (bufFactors[
l + 1], x);
1570 if (degPi > 0 && degBuf > 0)
1571 M (j + 1,
l + 1)=
mulMod (Pi [
l - 1] [j], bufFactors[
l + 1] [j], MOD);
1574 if (degPi > 0 && degBuf > 0)
1575 Pi [
l] += xToJ*(
mulMod ((Pi [
l - 1] [0] + Pi [
l - 1] [j]),
1576 (bufFactors[
l + 1] [0] + buf[
l + 1]), MOD) -
M (j + 1,
l +1)-
1579 Pi [
l] += xToJ*(
mulMod (Pi [
l - 1] [j], bufFactors[
l + 1], MOD));
1580 else if (degBuf > 0)
1581 Pi [
l] += xToJ*(
mulMod (Pi [
l - 1], buf[
l + 1], MOD));
1585 if (degPi > 0 && degBuf > 0)
1587 uIZeroJ=
mulMod (uIZeroJ, bufFactors [
l + 1] [0], MOD);
1588 uIZeroJ +=
mulMod (Pi [
l - 1] [0], buf [
l + 1], MOD);
1591 uIZeroJ=
mulMod (uIZeroJ, bufFactors [
l + 1], MOD);
1592 else if (degBuf > 0)
1594 uIZeroJ=
mulMod (uIZeroJ, bufFactors [
l + 1] [0], MOD);
1595 uIZeroJ +=
mulMod (Pi [
l - 1], buf[
l + 1], MOD);
1597 Pi[
l] += xToJ*uIZeroJ;
1599 one= bufFactors [
l + 1];
1603 if (degBuf > 0 && degPi > 0)
1614 if (degBuf > 0 && degPi > 0)
1616 for (k= 1; k <= (int) ceil (j/2.0); k++)
1624 (Pi[
l - 1] [k] + two.
coeff()), MOD) -
M (k + 1,
l + 1) -
1625 M (j - k + 2,
l + 1);
1629 else if (one.
hasTerms() && one.
exp() == j - k + 1)
1632 Pi[
l - 1] [k], MOD) -
M (k + 1,
l + 1);
1635 else if (two.
hasTerms() && two.
exp() == j - k + 1)
1637 tmp[
l] +=
mulMod (bufFactors[
l + 1] [k],
1638 (Pi[
l - 1] [k] + two.
coeff()), MOD) -
M (k + 1,
l + 1);
1643 tmp[
l] +=
M (k + 1,
l + 1);
1646 Pi[
l] += tmp[
l]*xToJ*F.
mvar();
1658 int liftBoundBivar= l[
k];
1669 bufFactors[k]=
i.getItem();
1679 for (; i.hasItem(); i++, k++)
1681 Pi [
k]=
mulMod (Pi [k - 1], i.getItem(), MOD);
1682 M (1, k + 1)= Pi [
k];
1685 for (
int d= 1; d < l[1]; d++)
1688 for (k= 1; k < factors.
length(); k++)
1689 result.
append (bufFactors[k]);
1704 bufFactors[
i]=
mod (k.getItem(), xToStart);
1706 bufFactors[
i]= k.getItem();
1708 for (i= start; i < end; i++)
1709 henselStep (F, factors, bufFactors, diophant, M, Pi, i, MOD);
1712 for (i= 0; i < factors.
length(); k++, i++)
1730 bufFactors[
k]=
i.getItem();
1740 Pi [0]=
mod (Pi[0], xToLOld);
1747 Pi [
k]=
mod (Pi [k], xToLOld);
1748 M (1, k + 1)= Pi [
k];
1751 for (
int d= 1; d < lNew; d++)
1754 for (k= 1; k < factors.
length(); k++)
1755 result.
append (bufFactors[k]);
1774 for (
int i= 0;
i < 2;
i++)
1782 for (
int i= 2; i < lLength && j.
hasItem(); i++, j++)
1787 result=
henselLift (bufEval, result, MOD, diophant, Pi, M, l[i - 1], l[i]);
1807 E= F[
j] - Pi [factors.
length() - 2] [
j];
1818 if (
degree (bufFactors[k], x) > 0)
1819 remainder=
modNTL (E, bufFactors[k] [0]);
1821 remainder=
modNTL (E, bufFactors[k]);
1822 buf[
k]=
mulNTL (
i.getItem(), remainder);
1823 if (
degree (bufFactors[k], x) > 0)
1824 buf[k]=
modNTL (buf[k], bufFactors[k] [0]);
1826 buf[
k]=
modNTL (buf[k], bufFactors[k]);
1829 for (k= 0; k < factors.
length(); k++)
1830 bufFactors[k] += xToJ*buf[k];
1833 int degBuf0=
degree (bufFactors[0], x);
1834 int degBuf1=
degree (bufFactors[1], x);
1835 if (degBuf0 > 0 && degBuf1 > 0)
1837 M (j + 1, 1)=
mulNTL (bufFactors[0] [j], bufFactors[1] [j]);
1838 if (j + 2 <= M.
rows())
1839 M (j + 2, 1)=
mulNTL (bufFactors[0] [j + 1], bufFactors[1] [j + 1]);
1845 if (degBuf0 > 0 && degBuf1 > 0)
1846 uIZeroJ=
mulNTL(bufFactors[0][0], buf[1]) +
1847 mulNTL (bufFactors[1][0], buf[0]);
1848 else if (degBuf0 > 0)
1849 uIZeroJ=
mulNTL (buf[0], bufFactors[1]) +
1850 mulNTL (buf[1], bufFactors[0][0]);
1851 else if (degBuf1 > 0)
1852 uIZeroJ=
mulNTL (bufFactors[0], buf[1]) +
1853 mulNTL (buf[0], bufFactors[1][0]);
1855 uIZeroJ=
mulNTL (bufFactors[0], buf[1]) +
1856 mulNTL (buf[0], bufFactors[1]);
1858 Pi [0] += xToJ*uIZeroJ;
1861 for (k= 0; k < factors.
length() - 1; k++)
1864 one= bufFactors [0];
1865 two= bufFactors [1];
1866 if (degBuf0 > 0 && degBuf1 > 0)
1870 for (k= 1; k <= (int) ceil (j/2.0); k++)
1874 if ((one.
hasTerms() && one.
exp() == j - k + 1) && +
1877 tmp[0] +=
mulNTL ((bufFactors[0][k]+one.
coeff()),(bufFactors[1][k] +
1878 two.
coeff())) -
M (k + 1, 1) -
M (j - k + 2, 1);
1882 else if (one.
hasTerms() && one.
exp() == j - k + 1)
1884 tmp[0] +=
mulNTL ((bufFactors[0][k]+one.
coeff()), bufFactors[1] [k]) -
1888 else if (two.
hasTerms() && two.
exp() == j - k + 1)
1890 tmp[0] +=
mulNTL (bufFactors[0][k],(bufFactors[1][k] + two.
coeff())) -
1896 tmp[0] +=
M (k + 1, 1);
1900 if (degBuf0 >= j + 1 && degBuf1 >= j + 1)
1902 if (j + 2 <= M.
rows())
1903 tmp [0] +=
mulNTL ((bufFactors [0] [j + 1]+ bufFactors [0] [0]),
1904 (bufFactors [1] [j + 1] + bufFactors [1] [0]))
1905 -
M(1,1) -
M (j + 2,1);
1907 else if (degBuf0 >= j + 1)
1910 tmp[0] +=
mulNTL (bufFactors [0] [j+1], bufFactors [1] [0]);
1912 tmp[0] +=
mulNTL (bufFactors [0] [j+1], bufFactors [1]);
1914 else if (degBuf1 >= j + 1)
1917 tmp[0] +=
mulNTL (bufFactors [0] [0], bufFactors [1] [j + 1]);
1919 tmp[0] +=
mulNTL (bufFactors [0], bufFactors [1] [j + 1]);
1922 Pi [0] += tmp[0]*xToJ*F.
mvar();
1925 for (
int l= 1;
l < factors.
length() - 1;
l++)
1927 degPi=
degree (Pi [
l - 1], x);
1928 degBuf=
degree (bufFactors[
l + 1], x);
1929 if (degPi > 0 && degBuf > 0)
1931 M (j + 1,
l + 1)=
mulNTL (Pi [
l - 1] [j], bufFactors[
l + 1] [j]);
1932 if (j + 2 <= M.
rows())
1933 M (j + 2,
l + 1)=
mulNTL (Pi [
l - 1][j + 1], bufFactors[
l + 1] [j + 1]);
1936 M (j + 1,
l + 1)= 0;
1938 if (degPi > 0 && degBuf > 0)
1939 uIZeroJ=
mulNTL (Pi[
l - 1] [0], buf[
l + 1]) +
1940 mulNTL (uIZeroJ, bufFactors[
l+1] [0]);
1942 uIZeroJ=
mulNTL (uIZeroJ, bufFactors[
l + 1]) +
1944 else if (degBuf > 0)
1945 uIZeroJ=
mulNTL (uIZeroJ, bufFactors[
l + 1][0]) +
1948 uIZeroJ=
mulNTL (uIZeroJ, bufFactors[
l + 1]) +
1951 Pi [
l] += xToJ*uIZeroJ;
1953 one= bufFactors [
l + 1];
1955 if (degBuf > 0 && degPi > 0)
1959 for (k= 1; k <= (int) ceil (j/2.0); k++)
1967 (Pi[
l - 1] [k] + two.
coeff())) -
M (k + 1,
l + 1) -
1968 M (j - k + 2,
l + 1);
1972 else if (one.
hasTerms() && one.
exp() == j - k + 1)
1975 Pi[
l - 1] [k]) -
M (k + 1,
l + 1);
1978 else if (two.
hasTerms() && two.
exp() == j - k + 1)
1980 tmp[
l] +=
mulNTL (bufFactors[
l + 1] [k],
1981 (Pi[
l - 1] [k] + two.
coeff())) -
M (k + 1,
l + 1);
1986 tmp[
l] +=
M (k + 1,
l + 1);
1990 if (degPi >= j + 1 && degBuf >= j + 1)
1992 if (j + 2 <= M.
rows())
1993 tmp [
l] +=
mulNTL ((Pi [
l - 1] [j + 1]+ Pi [
l - 1] [0]),
1994 (bufFactors [
l + 1] [j + 1] + bufFactors [
l + 1] [0])
1995 ) -
M(1,
l+1) -
M (j + 2,
l+1);
1997 else if (degPi >= j + 1)
2000 tmp[
l] +=
mulNTL (Pi [
l - 1] [j+1], bufFactors [
l + 1] [0]);
2002 tmp[
l] +=
mulNTL (Pi [
l - 1] [j+1], bufFactors [
l + 1]);
2004 else if (degBuf >= j + 1)
2007 tmp[
l] +=
mulNTL (Pi [
l - 1] [0], bufFactors [
l + 1] [j + 1]);
2009 tmp[
l] +=
mulNTL (Pi [
l - 1], bufFactors [
l + 1] [j + 1]);
2012 Pi[
l] += tmp[
l]*xToJ*F.
mvar();
2025 CFList bufFactors2= factors;
2028 DEBOUTLN (cerr,
"diophant= " << diophant);
2033 bufFactors[i]=
replaceLc (k.getItem(), LCs [
i]);
2036 if (
degree (bufFactors[0], x) > 0 &&
degree (bufFactors [1], x) > 0)
2038 M (1, 1)=
mulNTL (bufFactors [0] [0], bufFactors[1] [0]);
2039 Pi [0]=
M (1, 1) + (
mulNTL (bufFactors [0] [1], bufFactors[1] [0]) +
2040 mulNTL (bufFactors [0] [0], bufFactors [1] [1]))*x;
2042 else if (
degree (bufFactors[0], x) > 0)
2044 M (1, 1)=
mulNTL (bufFactors [0] [0], bufFactors[1]);
2046 mulNTL (bufFactors [0] [1], bufFactors[1])*
x;
2048 else if (
degree (bufFactors[1], x) > 0)
2050 M (1, 1)=
mulNTL (bufFactors [0], bufFactors[1] [0]);
2052 mulNTL (bufFactors [0], bufFactors[1] [1])*
x;
2056 M (1, 1)=
mulNTL (bufFactors [0], bufFactors[1]);
2060 for (i= 1; i < Pi.
size(); i++)
2062 if (
degree (Pi[i-1], x) > 0 &&
degree (bufFactors [i+1], x) > 0)
2064 M (1,i+1)=
mulNTL (Pi[i-1] [0], bufFactors[i+1] [0]);
2065 Pi [
i]=
M (1,i+1) + (
mulNTL (Pi[i-1] [1], bufFactors[i+1] [0]) +
2066 mulNTL (Pi[i-1] [0], bufFactors [i+1] [1]))*x;
2068 else if (
degree (Pi[i-1], x) > 0)
2070 M (1,i+1)=
mulNTL (Pi[i-1] [0], bufFactors [i+1]);
2071 Pi [
i]=
M(1,i+1) +
mulNTL (Pi[i-1] [1], bufFactors[i+1])*
x;
2073 else if (
degree (bufFactors[i+1], x) > 0)
2075 M (1,i+1)=
mulNTL (Pi[i-1], bufFactors [i+1] [0]);
2076 Pi [
i]=
M (1,i+1) +
mulNTL (Pi[i-1], bufFactors[i+1] [1])*
x;
2080 M (1,i+1)=
mulNTL (Pi [i-1], bufFactors [i+1]);
2085 for (i= 1; i <
l; i++)
2089 for (i= 0; i < bufFactors.
size(); i++)
2090 factors.
append (bufFactors[i]);
2110 "constant or univariate poly expected");
2111 ASSERT (
i.getItem().isUnivariate() ||
i.getItem().inCoeffDomain(),
2112 "constant or univariate poly expected");
2114 "constant or univariate poly expected");
2121 CFList bufFactors= factors;
2123 i.getItem()=
mod (
i.getItem(),
y);
2124 CFList bufProducts= products;
2126 i.getItem()=
mod (
i.getItem(),
y);
2141 CFList result= recDiophantine;
2144 for (
int i= 1;
i < d;
i++)
2150 if (!coeffE.isZero())
2153 recDiophantine=
diophantine (recResult, bufFactors, bufProducts, buf,
2158 for (j= recDiophantine; j.
hasItem(); j++, k++, l++)
2179 const CFList& MOD,
bool& noOneToOne)
2188 for (
int i= 0;
i < factors.
length();
i++)
2191 test *=
mod (bufFactors [
i],
power (x, j));
2193 test *= bufFactors[
i];
2196 test=
mod (test, MOD);
2198 DEBOUTLN (cerr,
"test in nonMonicHenselStep= " << test2);
2202 E= F[
j] - Pi [factors.
length() - 2] [
j];
2219 buf[
k]=
i.getItem();
2220 bufFactors[
k] += xToJ*
i.getItem();
2226 int degBuf0=
degree (bufFactors[0], x);
2227 int degBuf1=
degree (bufFactors[1], x);
2228 if (degBuf0 > 0 && degBuf1 > 0)
2230 M (j + 1, 1)=
mulMod (bufFactors[0] [j], bufFactors[1] [j], MOD);
2231 if (j + 2 <= M.
rows())
2232 M (j + 2, 1)=
mulMod (bufFactors[0] [j + 1], bufFactors[1] [j + 1], MOD);
2238 if (degBuf0 > 0 && degBuf1 > 0)
2239 uIZeroJ=
mulMod (bufFactors[0] [0], buf[1], MOD) +
2240 mulMod (bufFactors[1] [0], buf[0], MOD);
2241 else if (degBuf0 > 0)
2242 uIZeroJ=
mulMod (buf[0], bufFactors[1], MOD) +
2243 mulMod (buf[1], bufFactors[0][0], MOD);
2244 else if (degBuf1 > 0)
2245 uIZeroJ=
mulMod (bufFactors[0], buf[1], MOD) +
2246 mulMod (buf[0], bufFactors[1][0], MOD);
2248 uIZeroJ=
mulMod (bufFactors[0], buf[1], MOD) +
2249 mulMod (buf[0], bufFactors[1], MOD);
2250 Pi [0] += xToJ*uIZeroJ;
2253 for (k= 0; k < factors.
length() - 1; k++)
2256 one= bufFactors [0];
2257 two= bufFactors [1];
2258 if (degBuf0 > 0 && degBuf1 > 0)
2262 for (k= 1; k <= (int) ceil (j/2.0); k++)
2269 tmp[0] +=
mulMod ((bufFactors[0] [k] + one.
coeff()),
2270 (bufFactors[1] [k] + two.
coeff()), MOD) -
M (k + 1, 1) -
2275 else if (one.
hasTerms() && one.
exp() == j - k + 1)
2277 tmp[0] +=
mulMod ((bufFactors[0] [k] + one.
coeff()),
2278 bufFactors[1] [k], MOD) -
M (k + 1, 1);
2281 else if (two.
hasTerms() && two.
exp() == j - k + 1)
2283 tmp[0] +=
mulMod (bufFactors[0] [k], (bufFactors[1] [k] +
2284 two.
coeff()), MOD) -
M (k + 1, 1);
2290 tmp[0] +=
M (k + 1, 1);
2295 if (degBuf0 >= j + 1 && degBuf1 >= j + 1)
2297 if (j + 2 <= M.
rows())
2298 tmp [0] +=
mulMod ((bufFactors [0] [j + 1]+ bufFactors [0] [0]),
2299 (bufFactors [1] [j + 1] + bufFactors [1] [0]), MOD)
2300 -
M(1,1) -
M (j + 2,1);
2302 else if (degBuf0 >= j + 1)
2305 tmp[0] +=
mulMod (bufFactors [0] [j+1], bufFactors [1] [0], MOD);
2307 tmp[0] +=
mulMod (bufFactors [0] [j+1], bufFactors [1], MOD);
2309 else if (degBuf1 >= j + 1)
2312 tmp[0] +=
mulMod (bufFactors [0] [0], bufFactors [1] [j + 1], MOD);
2314 tmp[0] +=
mulMod (bufFactors [0], bufFactors [1] [j + 1], MOD);
2316 Pi [0] += tmp[0]*xToJ*F.
mvar();
2320 for (
int l= 1;
l < factors.
length() - 1;
l++)
2322 degPi=
degree (Pi [
l - 1], x);
2323 degBuf=
degree (bufFactors[
l + 1], x);
2324 if (degPi > 0 && degBuf > 0)
2326 M (j + 1,
l + 1)=
mulMod (Pi [
l - 1] [j], bufFactors[
l + 1] [j], MOD);
2327 if (j + 2 <= M.
rows())
2328 M (j + 2,
l + 1)=
mulMod (Pi [
l - 1] [j + 1], bufFactors[
l + 1] [j + 1],
2332 M (j + 1,
l + 1)= 0;
2334 if (degPi > 0 && degBuf > 0)
2335 uIZeroJ=
mulMod (Pi[
l - 1] [0], buf[
l + 1], MOD) +
2336 mulMod (uIZeroJ, bufFactors[
l + 1] [0], MOD);
2338 uIZeroJ=
mulMod (uIZeroJ, bufFactors[
l + 1], MOD) +
2339 mulMod (Pi[
l - 1][0], buf[
l + 1], MOD);
2340 else if (degBuf > 0)
2341 uIZeroJ=
mulMod (Pi[
l - 1], buf[
l + 1], MOD) +
2342 mulMod (uIZeroJ, bufFactors[
l + 1][0], MOD);
2344 uIZeroJ=
mulMod (Pi[
l - 1], buf[
l + 1], MOD) +
2345 mulMod (uIZeroJ, bufFactors[
l + 1], MOD);
2347 Pi [
l] += xToJ*uIZeroJ;
2349 one= bufFactors [
l + 1];
2351 if (degBuf > 0 && degPi > 0)
2355 for (k= 1; k <= (int) ceil (j/2.0); k++)
2363 (Pi[
l - 1] [k] + two.
coeff()), MOD) -
M (k + 1,
l + 1) -
2364 M (j - k + 2,
l + 1);
2368 else if (one.
hasTerms() && one.
exp() == j - k + 1)
2371 Pi[
l - 1] [k], MOD) -
M (k + 1,
l + 1);
2374 else if (two.
hasTerms() && two.
exp() == j - k + 1)
2376 tmp[
l] +=
mulMod (bufFactors[
l + 1] [k],
2377 (Pi[
l - 1] [k] + two.
coeff()), MOD) -
M (k + 1,
l + 1);
2382 tmp[
l] +=
M (k + 1,
l + 1);
2386 if (degPi >= j + 1 && degBuf >= j + 1)
2388 if (j + 2 <= M.
rows())
2389 tmp [
l] +=
mulMod ((Pi [
l - 1] [j + 1]+ Pi [
l - 1] [0]),
2390 (bufFactors [
l + 1] [j + 1] + bufFactors [
l + 1] [0])
2391 , MOD) -
M(1,
l+1) -
M (j + 2,
l+1);
2393 else if (degPi >= j + 1)
2396 tmp[
l] +=
mulMod (Pi [
l - 1] [j+1], bufFactors [
l + 1] [0], MOD);
2398 tmp[
l] +=
mulMod (Pi [
l - 1] [j+1], bufFactors [
l + 1], MOD);
2400 else if (degBuf >= j + 1)
2403 tmp[
l] +=
mulMod (Pi [
l - 1] [0], bufFactors [
l + 1] [j + 1], MOD);
2405 tmp[
l] +=
mulMod (Pi [
l - 1], bufFactors [
l + 1] [j + 1], MOD);
2408 Pi[
l] += tmp[
l]*xToJ*F.
mvar();
2435 int liftBoundBivar= l[
k];
2458 Pi[0]=
mod (Pi[0],
power (v, liftBoundBivar));
2460 if (
degree (bufFactors[0], y) > 0 &&
degree (bufFactors [1], y) > 0)
2461 Pi [0] += (
mulMod (bufFactors [0] [1], bufFactors[1] [0], MOD) +
2462 mulMod (bufFactors [0] [0], bufFactors [1] [1], MOD))*y;
2463 else if (
degree (bufFactors[0], y) > 0)
2464 Pi [0] +=
mulMod (bufFactors [0] [1], bufFactors[1], MOD)*
y;
2465 else if (
degree (bufFactors[1], y) > 0)
2466 Pi [0] +=
mulMod (bufFactors [0], bufFactors[1] [1], MOD)*
y;
2469 for (
int i= 0; i < bufFactors.size(); i++)
2471 if (
degree (bufFactors[i], y) > 0)
2477 for (
int d= 1; d < l[1]; d++)
2485 for (k= 0; k < factors.
length(); k++)
2486 result.
append (bufFactors[k]);
2505 Pi [0]=
mod (Pi[0], xToLOld);
2508 if (
degree (bufFactors[0], y) > 0 &&
degree (bufFactors [1], y) > 0)
2509 Pi [0] += (
mulMod (bufFactors [0] [1], bufFactors[1] [0], MOD) +
2510 mulMod (bufFactors [0] [0], bufFactors [1] [1], MOD))*y;
2511 else if (
degree (bufFactors[0], y) > 0)
2512 Pi [0] +=
mulMod (bufFactors [0] [1], bufFactors[1], MOD)*
y;
2513 else if (
degree (bufFactors[1], y) > 0)
2514 Pi [0] +=
mulMod (bufFactors [0], bufFactors[1] [1], MOD)*
y;
2518 for (
int i= 0;
i < bufFactors.size();
i++)
2520 if (
degree (bufFactors[
i], y) > 0)
2540 for (
int d= 1; d < lNew; d++)
2549 for (k= 0; k < factors.
length(); k++)
2550 result.
append (bufFactors[k]);
2559 CFList bufDiophant= diophant;
2573 for (
int i= 0;
i < 2;
i++)
2585 bufLCs2.
append (jjj.getItem());
2588 for (
int i= 2; i < lLength && j.
hasItem(); i++, j++, jj++, jjj++)
2590 bufEval.
append (j.getItem());
2591 bufLCs1.
append (jj.getItem());
2592 bufLCs2.
append (jjj.getItem());
2595 l[i - 1], l[i], bufLCs1, bufLCs2, bad);
2609 int bivarLiftBound,
bool&
bad)
2611 CFList bufFactors2= factors;
2615 i.getItem()=
mod (
i.getItem(),
y);
2618 bufF=
mod (bufF, y);
2633 bufFactors[i]=
replaceLC (k.getItem(), j.getItem());
2638 if (
degree (bufFactors[0], v) > 0 &&
degree (bufFactors [1], v) > 0)
2640 M (1, 1)=
mulMod2 (bufFactors [0] [0], bufFactors[1] [0], yToL);
2641 Pi [0]=
M (1,1) + (
mulMod2 (bufFactors [0] [1], bufFactors[1] [0], yToL) +
2642 mulMod2 (bufFactors [0] [0], bufFactors [1] [1], yToL))*v;
2644 else if (
degree (bufFactors[0], v) > 0)
2646 M (1,1)=
mulMod2 (bufFactors [0] [0], bufFactors [1], yToL);
2647 Pi [0]=
M(1,1) +
mulMod2 (bufFactors [0] [1], bufFactors[1], yToL)*
v;
2649 else if (
degree (bufFactors[1], v) > 0)
2651 M (1,1)=
mulMod2 (bufFactors [0], bufFactors [1] [0], yToL);
2652 Pi [0]=
M (1,1) +
mulMod2 (bufFactors [0], bufFactors[1] [1], yToL)*
v;
2656 M (1,1)=
mulMod2 (bufFactors [0], bufFactors [1], yToL);
2660 for (i= 1; i < Pi.size(); i++)
2662 if (
degree (Pi[i-1], v) > 0 &&
degree (bufFactors [i+1], v) > 0)
2664 M (1,i+1)=
mulMod2 (Pi[i-1] [0], bufFactors[i+1] [0], yToL);
2665 Pi [
i]=
M (1,i+1) + (
mulMod2 (Pi[i-1] [1], bufFactors[i+1] [0], yToL) +
2666 mulMod2 (Pi[i-1] [0], bufFactors [i+1] [1], yToL))*v;
2668 else if (
degree (Pi[i-1], v) > 0)
2670 M (1,i+1)=
mulMod2 (Pi[i-1] [0], bufFactors [i+1], yToL);
2671 Pi [
i]=
M(1,i+1) +
mulMod2 (Pi[i-1] [1], bufFactors[i+1], yToL)*
v;
2673 else if (
degree (bufFactors[i+1], v) > 0)
2675 M (1,i+1)=
mulMod2 (Pi[i-1], bufFactors [i+1] [0], yToL);
2676 Pi [
i]=
M (1,i+1) +
mulMod2 (Pi[i-1], bufFactors[i+1] [1], yToL)*
v;
2680 M (1,i+1)=
mulMod2 (Pi [i-1], bufFactors [i+1], yToL);
2689 products.
append (bufF/k.getItem());
2694 for (
int d= 1; d < liftBound; d++)
2703 for (i= 0; i < factors.
length(); i++)
2704 result.
append (bufFactors[i]);
2711 int& lNew,
const CFList& MOD,
bool& noOneToOne
2719 bufFactors [k]=
replaceLC (
i.getItem(), j.getItem());
2725 Pi [0]=
mod (Pi[0], xToLOld);
2728 if (
degree (bufFactors[0], y) > 0 &&
degree (bufFactors [1], y) > 0)
2729 Pi [0] += (
mulMod (bufFactors [0] [1], bufFactors[1] [0], MOD) +
2730 mulMod (bufFactors [0] [0], bufFactors [1] [1], MOD))*y;
2731 else if (
degree (bufFactors[0], y) > 0)
2732 Pi [0] +=
mulMod (bufFactors [0] [1], bufFactors[1], MOD)*
y;
2733 else if (
degree (bufFactors[1], y) > 0)
2734 Pi [0] +=
mulMod (bufFactors [0], bufFactors[1] [1], MOD)*
y;
2736 for (
int i= 1;
i < Pi.
size();
i++)
2738 Pi [
i]=
mod (Pi [
i], xToLOld);
2739 M (1, i + 1)= Pi [
i];
2741 if (
degree (Pi[i-1], y) > 0 &&
degree (bufFactors [i+1], y) > 0)
2742 Pi [
i] += (
mulMod (Pi[i-1] [1], bufFactors[i+1] [0], MOD) +
2743 mulMod (Pi[i-1] [0], bufFactors [i+1] [1], MOD))*y;
2744 else if (
degree (Pi[i-1], y) > 0)
2745 Pi [i] +=
mulMod (Pi[i-1] [1], bufFactors[i+1], MOD)*
y;
2746 else if (
degree (bufFactors[i+1], y) > 0)
2747 Pi [i] +=
mulMod (Pi[i-1], bufFactors[i+1] [1], MOD)*
y;
2754 for (
int i= 0;
i < bufFactors.
size();
i++)
2756 if (
degree (bufFactors[
i], y) > 0)
2758 if (!
fdivides (bufFactors[i] [0], bufF, quot))
2767 if (!
fdivides (bufFactors[i], bufF, quot))
2777 for (
int d= 1; d < lNew; d++)
2780 products, d, MOD, noOneToOne);
2786 for (k= 0; k < factors.
length(); k++)
2787 result.
append (bufFactors[k]);
2794 int* liftBound,
int length,
bool& noOneToOne
2797 CFList bufDiophant= diophant;
2806 liftBound[1], liftBound[0], noOneToOne);
2817 for (
int i= 0;
i < 2;
i++)
2825 for (
int i= 2; i <= length && j.
hasItem(); i++, j++, k++)
2827 bufEval.
append (j.getItem());
2831 liftBound[i-1], liftBound[i], MOD, noOneToOne);
int status int void size_t count
nmod_poly_init(FLINTmipo, getCharacteristic())
const CanonicalForm int s
ZZ convertFacCF2NTLZZ(const CanonicalForm &f)
NAME: convertFacCF2NTLZZX.
const CanonicalForm int const CFList const Variable & y
Conversion to and from NTL.
This file defines functions for Hensel lifting.
static CanonicalForm bound(const CFMatrix &M)
This file defines functions for conversion to FLINT (www.flintlib.org) and back.
static CFList replacevar(const CFList &L, const Variable &a, const Variable &b)
functions to print debug output
CanonicalForm extgcd(const CanonicalForm &f, const CanonicalForm &g, CanonicalForm &a, CanonicalForm &b)
CanonicalForm extgcd ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & a...
#define TIMING_END_AND_PRINT(t, msg)
factory's class for variables
static void chineseRemainder(const CFList &x1, const CanonicalForm &q1, const CFList &x2, const CanonicalForm &q2, CFList &xnew, CanonicalForm &qnew)
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
void nonMonicHenselStep(const CanonicalForm &F, const CFList &factors, CFArray &bufFactors, const CFList &diophant, CFMatrix &M, CFArray &Pi, const CFList &products, int j, const CFList &MOD, bool &noOneToOne)
void henselStep12(const CanonicalForm &F, const CFList &factors, CFArray &bufFactors, const CFList &diophant, CFMatrix &M, CFArray &Pi, int j, const modpk &b)
CanonicalForm replaceLc(const CanonicalForm &f, const CanonicalForm &c)
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
ZZ_pEX convertFacCF2NTLZZ_pEX(const CanonicalForm &f, const ZZ_pX &mipo)
CanonicalForm in Z_p(a)[X] to NTL ZZ_pEX.
nmod_poly_clear(FLINTmipo)
CFList diophantineHensel(const CanonicalForm &F, const CFList &factors, const modpk &b)
CFList biDiophantine(const CanonicalForm &F, const CFList &factors, int d)
ZZX convertFacCF2NTLZZX(const CanonicalForm &f)
void nonMonicHenselStep12(const CanonicalForm &F, const CFList &factors, CFArray &bufFactors, const CFList &diophant, CFMatrix &M, CFArray &Pi, int j, const CFArray &)
static void henselStep(const CanonicalForm &F, const CFList &factors, CFArray &bufFactors, const CFList &diophant, CFMatrix &M, CFArray &Pi, int j, const CFList &MOD)
static int mod(const CFList &L, const CanonicalForm &p)
CFList nonMonicHenselLift(const CFList &F, const CFList &factors, const CFList &LCs, CFList &diophant, CFArray &Pi, CFMatrix &M, int lOld, int &lNew, const CFList &MOD, bool &noOneToOne)
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...
void tryInvert(const CanonicalForm &F, const CanonicalForm &M, CanonicalForm &inv, bool &fail)
CanonicalForm getMipo(const Variable &alpha, const Variable &x)
fq_nmod_ctx_clear(fq_con)
void sortList(CFList &list, const Variable &x)
sort a list of polynomials by their degree in x.
TIMING_DEFINE_PRINT(diotime) TIMING_DEFINE_PRINT(product1) TIMING_DEFINE_PRINT(product2) TIMING_DEFINE_PRINT(hensel23) TIMING_DEFINE_PRINT(hensel) static CFList productsFLINT(const CFList &factors
static CFList Farey(const CFList &L, const CanonicalForm &q)
Variable rootOf(const CanonicalForm &, char name='@')
returns a symbolic root of polynomial with name name Use it to define algebraic variables ...
CanonicalForm inverse(const CanonicalForm &f, bool symmetric=true) const
CFList nonMonicHenselLift2(const CFList &F, const CFList &factors, const CFList &MOD, CFList &diophant, CFArray &Pi, CFMatrix &M, int lOld, int &lNew, const CFList &LCs1, const CFList &LCs2, bool &bad)
void tryNTLXGCD(zz_pEX &d, zz_pEX &s, zz_pEX &t, const zz_pEX &a, const zz_pEX &b, bool &fail)
compute the extended GCD d=s*a+t*b, fail is set to true if a zero divisor is encountered ...
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), Z, Q, Q(a), if we are in GF factory's default multiplication is used. If b!= 0 and getCharacteristic() == 0 the input will be considered as elements over Z/p^k or Z/p^k[t]/(f).
CFList multiRecDiophantine(const CanonicalForm &F, const CFList &factors, const CFList &recResult, const CFList &M, int d)
univariate Gcd over finite fields and Z, extended GCD over finite fields and Q
CanonicalForm convertNTLZZ_pEX2CF(const ZZ_pEX &f, const Variable &x, const Variable &alpha)
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, Q, Q(a), if we are in GF factory's default multiplication is used. If b!= 0 and getCharacteristic() == 0 the input will be considered as elements over Z/p^k or Z/p^k[t]/(f); in this case invertiblity of Lc(G) is not checked
convertFacCF2nmod_poly_t(FLINTmipo, M)
This file defines functions for fast multiplication and division with remainder.
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)...
zz_pEX convertFacCF2NTLzz_pEX(const CanonicalForm &f, const zz_pX &mipo)
void setReduce(const Variable &alpha, bool reduce)
CFList henselLift23(const CFList &eval, const CFList &factors, int *l, CFList &diophant, CFArray &Pi, CFMatrix &M)
Hensel lifting from bivariate to trivariate.
void convertFacCF2Fq_nmod_t(fq_nmod_t result, const CanonicalForm &f, const fq_nmod_ctx_t ctx)
conversion of a factory element of F_q to a FLINT fq_nmod_t, does not do any memory allocation for po...
CFList nonMonicHenselLift232(const CFList &eval, const CFList &factors, int *l, CFList &diophant, CFArray &Pi, CFMatrix &M, const CFList &LCs1, const CFList &LCs2, bool &bad)
CanonicalForm mulMod2(const CanonicalForm &A, const CanonicalForm &B, const CanonicalForm &M)
Karatsuba style modular multiplication for bivariate polynomials.
static const int SW_RATIONAL
set to 1 for computations over Q
CanonicalForm replaceLC(const CanonicalForm &F, const CanonicalForm &c)
CFList diophantine(const CanonicalForm &F, const CFList &factors)
declarations of higher level algorithms.
This file defines functions for univariate GCD and extended GCD over Z/p[t]/(f)[x] for reducible f...
CanonicalForm bCommonDen(const CanonicalForm &f)
CanonicalForm bCommonDen ( const CanonicalForm & f )
fq_nmod_poly_clear(prod, fq_con)
CanonicalForm convertNTLzz_pEX2CF(const zz_pEX &f, const Variable &x, const Variable &alpha)
static CFList mapinto(const CFList &L)
CanonicalForm maxNorm(const CanonicalForm &f)
CanonicalForm maxNorm ( const CanonicalForm & f )
CFList diophantineQa(const CanonicalForm &F, const CanonicalForm &G, const CFList &factors, modpk &b, const Variable &alpha)
solve mod over by first computing mod and if no zero divisor occurred compute it mod ...
class to iterate through CanonicalForm's
void henselLift12(const CanonicalForm &F, CFList &factors, int l, CFArray &Pi, CFList &diophant, CFMatrix &M, modpk &b, bool sort)
Hensel lift from univariate to bivariate.
bool fdivides(const CanonicalForm &f, const CanonicalForm &g)
bool fdivides ( const CanonicalForm & f, const CanonicalForm & g )
const Variable & v
< [in] a sqrfree bivariate poly
CanonicalForm mulMod(const CanonicalForm &A, const CanonicalForm &B, const CFList &MOD)
Karatsuba style modular multiplication for multivariate polynomials.
REvaluation E(1, terms.length(), IntRandom(25))
fq_nmod_poly_init(prod, fq_con)
zz_pX convertFacCF2NTLzzpX(const CanonicalForm &f)
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CanonicalForm getpk() const
int cf_getBigPrime(int i)
void henselLiftResume(const CanonicalForm &F, CFList &factors, int start, int end, CFArray &Pi, const CFList &diophant, CFMatrix &M, const CFList &MOD)
resume Hensel lifting.
void findGoodPrime(const CanonicalForm &f, int &start)
find a big prime p from our tables such that no term of f vanishes mod p
void henselLiftResume12(const CanonicalForm &F, CFList &factors, int start, int end, CFArray &Pi, const CFList &diophant, CFMatrix &M, const modpk &b)
resume Hensel lift from univariate to bivariate. Assumes factors are lifted to precision Variable (2)...
void sort(CFArray &A, int l=0)
quick sort A
CFList diophantineHenselQa(const CanonicalForm &F, const CanonicalForm &G, const CFList &factors, modpk &b, const Variable &alpha)
solve mod over by p-adic lifting
#define ASSERT(expression, message)
#define DEBOUTLN(stream, objects)
modpk coeffBound(const CanonicalForm &f, int p, const CanonicalForm &mipo)
compute p^k larger than the bound on the coefficients of a factor of f over Q (mipo) ...
operations mod p^k and some other useful functions for factorization
bivariate factorization over Q(a)
static void tryDiophantine(CFList &result, const CanonicalForm &F, const CFList &factors, const CanonicalForm &M, bool &fail)
CF_NO_INLINE int exp() const
get the current exponent
int hasAlgVar(const CanonicalForm &f, const Variable &v)
CFList modularDiophant(const CanonicalForm &f, const CFList &factors, const CanonicalForm &M)
CFList nonMonicHenselLift23(const CanonicalForm &F, const CFList &factors, const CFList &LCs, CFList &diophant, CFArray &Pi, int liftBound, int bivarLiftBound, bool &bad)
class to do operations mod p^k for int's p and k
void nonMonicHenselLift12(const CanonicalForm &F, CFList &factors, int l, CFArray &Pi, CFList &diophant, CFMatrix &M, const CFArray &LCs, bool sort)
Hensel lifting from univariate to bivariate, factors need not to be monic.
CFList henselLift(const CFList &F, const CFList &factors, const CFList &MOD, CFList &diophant, CFArray &Pi, CFMatrix &M, int lOld, int lNew)
Hensel lifting.
fq_nmod_ctx_init_modulus(fq_con, FLINTmipo, "Z")