87#if defined(HAVE_NTL)|| defined(HAVE_FLINT)
98 for (
int i = n;
i >= 0;
i--)
111 for (
int i= 1;
i <= n;
i++)
140 for (
int i= 1;
i <= n;
i++)
175 while (min_max_deg == 0)
183 for (
int j=
i + 1;
j <=
m;
j++)
231 for (
int i= 1;
i <= n;
i++)
298 for (;
i.hasTerms();
i++)
321 for (
int i= 1;
i <= d;
i++)
325 gcdcFcG=
gcd (uniContentF, uniContentG);
326 contentF *= uniContentF;
327 contentG *= uniContentG;
370 interPoly= oldInterPoly + ((u - oldInterPoly(
alpha,
x))/newtonPoly(
alpha,
x))
390 double bound=
pow ((
double)
p, (
double) d);
401 while (
find (list, random))
407 while (
find (list, random))
410 if (F (random,
x) == 0)
415 }
while (
find (list, random));
435 nmod_poly_t Irredpoly;
437 nmod_poly_randtest_monic_irreducible(Irredpoly,
FLINTrandom,
i*
m+1);
447 BuildIrred (NTLIrredpoly,
i*
m);
453#if defined(HAVE_NTL) || defined(HAVE_FLINT)
460#if defined(HAVE_NTL) || defined(HAVE_FLINT)
476#if defined(HAVE_NTL) || defined(HAVE_FLINT)
553 gcdcAcB=
gcd (cA, cB);
563 gcdlcAlcB=
gcd (lcA, lcB);
569 coF=
N (ppA*(cA/gcdcAcB));
570 coG=
N (ppB*(cB/gcdcAcB));
579 coF=
N (ppA*(cA/gcdcAcB));
580 coG=
N (ppB*(cB/gcdcAcB));
585 CanonicalForm newtonPoly, coF_random_element, coG_random_element, coF_m,
596 bool inextension=
false;
601 int bound1=
degree (ppA, 1);
602 int bound2=
degree (ppB, 1);
613 bool prim_fail=
false;
617 prim_elem_alpha= prim_elem;
619 if (V_buf3 != V_buf4)
621 m=
mapDown (
m, prim_elem, im_prim_elem, V_buf4, source, dest);
622 G_m=
mapDown (G_m, prim_elem, im_prim_elem, V_buf4, source, dest);
623 coF_m=
mapDown (coF_m, prim_elem, im_prim_elem, V_buf4, source, dest);
624 coG_m=
mapDown (coG_m, prim_elem, im_prim_elem, V_buf4, source, dest);
625 newtonPoly=
mapDown (newtonPoly, prim_elem, im_prim_elem, V_buf4,
627 ppA=
mapDown (ppA, prim_elem, im_prim_elem, V_buf4, source, dest);
628 ppB=
mapDown (ppB, prim_elem, im_prim_elem, V_buf4, source, dest);
629 gcdlcAlcB=
mapDown (gcdlcAlcB, prim_elem, im_prim_elem, V_buf4,
631 lcA=
mapDown (lcA, prim_elem, im_prim_elem, V_buf4, source, dest);
632 lcB=
mapDown (lcB, prim_elem, im_prim_elem, V_buf4, source, dest);
634 i.getItem()=
mapDown (
i.getItem(), prim_elem, im_prim_elem, V_buf4,
638 ASSERT (!prim_fail,
"failure in integer factorizer");
642 im_prim_elem=
mapPrimElem (prim_elem, V_buf4, V_buf);
645 im_prim_elem_alpha= im_prim_elem;
647 im_prim_elem_alpha=
mapUp (im_prim_elem_alpha, V_buf4, V_buf, prim_elem,
648 im_prim_elem, source, dest);
653 i.getItem()=
mapUp (
i.getItem(), V_buf4, V_buf, prim_elem,
654 im_prim_elem, source, dest);
655 m=
mapUp (
m, V_buf4, V_buf, prim_elem, im_prim_elem, source, dest);
656 G_m=
mapUp (G_m, V_buf4, V_buf, prim_elem, im_prim_elem, source, dest);
657 coF_m=
mapUp (coF_m, V_buf4, V_buf, prim_elem, im_prim_elem, source, dest);
658 coG_m=
mapUp (coG_m, V_buf4, V_buf, prim_elem, im_prim_elem, source, dest);
659 newtonPoly=
mapUp (newtonPoly, V_buf4, V_buf, prim_elem, im_prim_elem,
661 ppA=
mapUp (ppA, V_buf4, V_buf, prim_elem, im_prim_elem, source, dest);
662 ppB=
mapUp (ppB, V_buf4, V_buf, prim_elem, im_prim_elem, source, dest);
663 gcdlcAlcB=
mapUp (gcdlcAlcB, V_buf4, V_buf, prim_elem, im_prim_elem,
665 lcA=
mapUp (lcA, V_buf4, V_buf, prim_elem, im_prim_elem, source, dest);
666 lcB=
mapUp (lcB, V_buf4, V_buf, prim_elem, im_prim_elem, source, dest);
674 modGCDFq (ppA (random_element,
x), ppB (random_element,
x),
675 coF_random_element, coG_random_element, V_buf,
678 "time for recursive call: ");
679 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
687 modGCDFq (ppA(random_element,
x), ppB(random_element,
x),
688 coF_random_element, coG_random_element, V_buf,
691 "time for recursive call: ");
692 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
706 ppA=
mapDown (ppA, prim_elem_alpha, im_prim_elem_alpha,
alpha, u,
v);
707 ppB=
mapDown (ppB, prim_elem_alpha, im_prim_elem_alpha,
alpha, u,
v);
710 coF=
N (ppA*(cA/gcdcAcB));
711 coG=
N (ppB*(cB/gcdcAcB));
716 if (!
find (
l, random_element))
717 l.append (random_element);
722 (gcdlcAlcB(random_element,
x)/
uni_lcoeff (G_random_element))
724 coF_random_element= (lcA(random_element,
x)/
uni_lcoeff(coF_random_element))
726 coG_random_element= (lcB(random_element,
x)/
uni_lcoeff(coG_random_element))
746 H=
newtonInterp (random_element, G_random_element, newtonPoly, G_m,
x);
747 coF=
newtonInterp (random_element, coF_random_element, newtonPoly, coF_m,
x);
748 coG=
newtonInterp (random_element, coG_random_element, newtonPoly, coG_m,
x);
750 "time for newton interpolation: ");
756 if (gcdlcAlcB.
isOne())
775 DEBOUTLN (cerr,
"ppH before mapDown= " << ppH);
776 ppH=
mapDown (ppH, prim_elem_alpha, im_prim_elem_alpha,
alpha, u,
v);
777 ppCoF=
mapDown (ppCoF, prim_elem_alpha, im_prim_elem_alpha,
alpha, u,
v);
778 ppCoG=
mapDown (ppCoG, prim_elem_alpha, im_prim_elem_alpha,
alpha, u,
v);
779 DEBOUTLN (cerr,
"ppH after mapDown= " << ppH);
780 coF=
N ((cA/gcdcAcB)*ppCoF);
781 coG=
N ((cB/gcdcAcB)*ppCoG);
783 "time for successful termination test Fq: ");
785 return N(gcdcAcB*ppH);
788 else if (((
degree (ppCoF,1)+
degree (ppH,1) == bound1) &&
793 coF=
N ((cA/gcdcAcB)*ppCoF);
794 coG=
N ((cB/gcdcAcB)*ppCoG);
796 "time for successful termination test Fq: ");
797 return N(gcdcAcB*ppH);
800 "time for unsuccessful termination test Fq: ");
806 newtonPoly= newtonPoly*(
x - random_element);
807 m=
m*(
x - random_element);
808 if (!
find (
l, random_element))
809 l.append (random_element);
840 while (
find (list, random))
843 if (F (random,
x) == 0)
848 }
while (
find (list, random));
947 gcdcAcB=
gcd (cA, cB);
957 gcdlcAlcB=
gcd (lcA, lcB);
962 coF=
N (ppA*(cA/gcdcAcB));
963 coG=
N (ppB*(cB/gcdcAcB));
971 coF=
N (ppA*(cA/gcdcAcB));
972 coG=
N (ppB*(cB/gcdcAcB));
977 CanonicalForm newtonPoly, coF_random_element, coG_random_element, coF_m,
988 bool inextension=
false;
994 int bound1=
degree (ppA, 1);
995 int bound2=
degree (ppB, 1);
1004 if (
ipower (
p, kk*expon) < (1 << 16))
1008 expon= (int) floor((
log ((
double)((1<<16) - 1)))/(
log((
double)
p)*kk));
1009 ASSERT (expon >= 2,
"not enough points in modGCDGF");
1018 newtonPoly=
GFMapUp (newtonPoly, kk);
1023 gcdlcAlcB=
GFMapUp (gcdlcAlcB, kk);
1030 G_random_element=
modGCDGF (ppA(random_element,
x), ppB(random_element,
x),
1031 coF_random_element, coG_random_element,
1034 "time for recursive call: ");
1035 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
1041 G_random_element=
modGCDGF (ppA(random_element,
x), ppB(random_element,
x),
1042 coF_random_element, coG_random_element,
1045 "time for recursive call: ");
1046 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
1063 coF=
N (ppA*(cA/gcdcAcB));
1064 coG=
N (ppB*(cB/gcdcAcB));
1069 if (!
find (
l, random_element))
1070 l.append (random_element);
1075 (gcdlcAlcB(random_element,
x)/
uni_lcoeff(G_random_element)) *
1078 coF_random_element= (lcA(random_element,
x)/
uni_lcoeff(coF_random_element))
1079 *coF_random_element;
1080 coG_random_element= (lcB(random_element,
x)/
uni_lcoeff(coG_random_element))
1081 *coG_random_element;
1100 H=
newtonInterp (random_element, G_random_element, newtonPoly, G_m,
x);
1101 coF=
newtonInterp (random_element, coF_random_element, newtonPoly, coF_m,
x);
1102 coG=
newtonInterp (random_element, coG_random_element, newtonPoly, coG_m,
x);
1104 "time for newton interpolation: ");
1110 if (gcdlcAlcB.
isOne())
1128 DEBOUTLN (cerr,
"ppH before mapDown= " << ppH);
1132 DEBOUTLN (cerr,
"ppH after mapDown= " << ppH);
1133 coF=
N ((cA/gcdcAcB)*ppCoF);
1134 coG=
N ((cB/gcdcAcB)*ppCoG);
1137 "time for successful termination GF: ");
1138 return N(gcdcAcB*ppH);
1148 coF=
N ((cA/gcdcAcB)*ppCoF);
1149 coG=
N ((cB/gcdcAcB)*ppCoG);
1151 "time for successful termination GF: ");
1152 return N(gcdcAcB*ppH);
1156 "time for unsuccessful termination GF: ");
1162 newtonPoly= newtonPoly*(
x - random_element);
1163 m=
m*(
x - random_element);
1164 if (!
find (
l, random_element))
1165 l.append (random_element);
1191 while (
find (list, random))
1194 if (F (random,
x) == 0)
1199 }
while (
find (list, random));
1203#if defined(HAVE_NTL) || defined(HAVE_FLINT)
1210#if defined(HAVE_NTL) || defined(HAVE_FLINT)
1221#if defined(HAVE_NTL) || defined(HAVE_FLINT)
1270 if (best_level == 0)
1297 gcdcAcB=
gcd (cA, cB);
1306 gcdlcAlcB=
gcd (lcA, lcB);
1313 coF=
N (ppA*(cA/gcdcAcB));
1314 coG=
N (ppB*(cB/gcdcAcB));
1325 coF=
N (ppA*(cA/gcdcAcB));
1326 coG=
N (ppB*(cB/gcdcAcB));
1331 CanonicalForm newtonPoly, coF_random_element, coG_random_element,
1332 coF_m, coG_m, ppCoF, ppCoG;
1342 bool inextension=
false;
1345 int bound1=
degree (ppA, 1);
1346 int bound2=
degree (ppB, 1);
1354 if (!fail && !inextension)
1359 modGCDFp (ppA (random_element,
x), ppB (random_element,
x),
1360 coF_random_element, coG_random_element,
topLevel,
1363 "time for recursive call: ");
1364 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
1366 else if (!fail && inextension)
1371 modGCDFq (ppA (random_element,
x), ppB (random_element,
x),
1372 coF_random_element, coG_random_element, V_buf,
1375 "time for recursive call: ");
1376 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
1378 else if (fail && !inextension)
1385 bool initialized=
false;
1404 modGCDFq (ppA (random_element,
x), ppB (random_element,
x),
1405 coF_random_element, coG_random_element,
alpha,
1408 "time for recursive call: ");
1409 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
1411 else if (fail && inextension)
1418 bool prim_fail=
false;
1423 if (V_buf3 !=
alpha)
1426 G_m=
mapDown (G_m, prim_elem, im_prim_elem,
alpha, source, dest);
1427 coF_m=
mapDown (coF_m, prim_elem, im_prim_elem,
alpha, source, dest);
1428 coG_m=
mapDown (coG_m, prim_elem, im_prim_elem,
alpha, source, dest);
1429 newtonPoly=
mapDown (newtonPoly, prim_elem, im_prim_elem,
alpha,
1431 ppA=
mapDown (ppA, prim_elem, im_prim_elem,
alpha, source, dest);
1432 ppB=
mapDown (ppB, prim_elem, im_prim_elem,
alpha, source, dest);
1433 gcdlcAlcB=
mapDown (gcdlcAlcB, prim_elem, im_prim_elem,
alpha, source,
1435 lcA=
mapDown (lcA, prim_elem, im_prim_elem,
alpha, source, dest);
1436 lcB=
mapDown (lcB, prim_elem, im_prim_elem,
alpha, source, dest);
1438 i.getItem()=
mapDown (
i.getItem(), prim_elem, im_prim_elem,
alpha,
1442 ASSERT (!prim_fail,
"failure in integer factorizer");
1452 i.getItem()=
mapUp (
i.getItem(),
alpha, V_buf, prim_elem,
1453 im_prim_elem, source, dest);
1454 m=
mapUp (
m,
alpha, V_buf, prim_elem, im_prim_elem, source, dest);
1455 G_m=
mapUp (G_m,
alpha, V_buf, prim_elem, im_prim_elem, source, dest);
1456 coF_m=
mapUp (coF_m,
alpha, V_buf, prim_elem, im_prim_elem, source, dest);
1457 coG_m=
mapUp (coG_m,
alpha, V_buf, prim_elem, im_prim_elem, source, dest);
1458 newtonPoly=
mapUp (newtonPoly,
alpha, V_buf, prim_elem, im_prim_elem,
1460 ppA=
mapUp (ppA,
alpha, V_buf, prim_elem, im_prim_elem, source, dest);
1461 ppB=
mapUp (ppB,
alpha, V_buf, prim_elem, im_prim_elem, source, dest);
1462 gcdlcAlcB=
mapUp (gcdlcAlcB,
alpha, V_buf, prim_elem, im_prim_elem,
1464 lcA=
mapUp (lcA,
alpha, V_buf, prim_elem, im_prim_elem, source, dest);
1465 lcB=
mapUp (lcB,
alpha, V_buf, prim_elem, im_prim_elem, source, dest);
1472 modGCDFq (ppA (random_element,
x), ppB (random_element,
x),
1473 coF_random_element, coG_random_element, V_buf,
1476 "time for recursive call: ");
1477 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
1491 coF=
N (ppA*(cA/gcdcAcB));
1492 coG=
N (ppB*(cB/gcdcAcB));
1498 if (!
find (
l, random_element))
1499 l.append (random_element);
1503 G_random_element= (gcdlcAlcB(random_element,
x)/
uni_lcoeff(G_random_element))
1506 coF_random_element= (lcA(random_element,
x)/
uni_lcoeff(coF_random_element))
1507 *coF_random_element;
1508 coG_random_element= (lcB(random_element,
x)/
uni_lcoeff(coG_random_element))
1509 *coG_random_element;
1528 H=
newtonInterp (random_element, G_random_element, newtonPoly, G_m,
x);
1529 coF=
newtonInterp (random_element, coF_random_element, newtonPoly, coF_m,
x);
1530 coG=
newtonInterp (random_element, coG_random_element, newtonPoly, coG_m,
x);
1532 "time for newton_interpolation: ");
1538 if (gcdlcAlcB.
isOne())
1557 coF=
N ((cA/gcdcAcB)*ppCoF);
1558 coG=
N ((cB/gcdcAcB)*ppCoG);
1560 "time for successful termination Fp: ");
1561 return N(gcdcAcB*ppH);
1564 "time for unsuccessful termination Fp: ");
1570 newtonPoly= newtonPoly*(
x - random_element);
1571 m=
m*(
x - random_element);
1572 if (!
find (
l, random_element))
1573 l.append (random_element);
1582 ASSERT (
A.size() == r,
"vector does not have right size");
1591 bool notDistinct=
false;
1592 for (
int i= 0;
i < r - 1;
i++)
1594 for (
int j=
i + 1;
j < r;
j++)
1608 for (
int i= 0;
i < r;
i++)
1609 master *=
x -
M [
i];
1612 for (
int i= 0;
i < r;
i++)
1614 tmp= master/(
x -
M [
i]);
1615 tmp /= tmp (
M [
i], 1);
1621 for (
int i= 1;
i <= r;
i++,
j++)
1624 for (
int l= 0;
l <
A.size();
l++)
1625 tmp +=
A[
l]*
j.getItem()[
l];
1635 ASSERT (
A.size() == r,
"vector does not have right size");
1643 bool notDistinct=
false;
1644 for (
int i= 0;
i < r - 1;
i++)
1646 for (
int j=
i + 1;
j < r;
j++)
1660 for (
int i= 0;
i < r;
i++)
1661 master *=
x -
M [
i];
1665 for (
int i= 0;
i < r;
i++)
1667 tmp= master/(
x -
M [
i]);
1668 tmp /= tmp (
M [
i], 1);
1675 for (
int i= 1;
i <= r;
i++,
j++)
1679 for (
int l= 1;
l <=
A.size();
l++)
1680 tmp +=
A[
l - 1]*
j.getItem()[
l];
1692 for (
int i= rk;
i >= 1;
i--)
1696 for (
int j=
M.columns() - 1;
j >= 1;
j--)
1715 for (
int i=
M.rows();
i >= 1;
i--)
1720 for (
int j=
M.columns();
j >= 1;
j--,
k++)
1727 if (
k > partialSol.
size() - 1)
1730 tmp3 +=
tmp2*partialSol[partialSol.
size() -
k - 1];
1741 ASSERT (L.
size() <=
M.rows(),
"dimension exceeded");
1745 for (
int i= 1;
i <=
M.rows();
i++)
1746 for (
int j= 1;
j <=
M.columns();
j++)
1750 for (
int i= 0;
i < L.
size();
i++,
j++)
1751 (*
N) (
j,
M.columns() + 1)= L[
i];
1755 long rk= nmod_mat_rref (FLINTN);
1759 nmod_mat_clear (FLINTN);
1769 long rk= gauss (*NTLN);
1776 for (
int i= 0;
i <
M.rows();
i++)
1777 L[
i]= (*
N) (
i + 1,
M.columns() + 1);
1778 M= (*N) (1,
M.rows(), 1,
M.columns());
1786 ASSERT (L.
size() <=
M.rows(),
"dimension exceeded");
1790 for (
int i= 1;
i <=
M.rows();
i++)
1791 for (
int j= 1;
j <=
M.columns();
j++)
1795 for (
int i= 0;
i < L.
size();
i++,
j++)
1796 (*
N) (
j,
M.columns() + 1)= L[
i];
1805 fq_nmod_mat_t FLINTN;
1808 long rk= fq_nmod_mat_rref (FLINTN,ctx);
1810 fq_nmod_mat_clear (FLINTN,ctx);
1812 #elif defined(HAVE_NTL)
1820 zz_pE::init (NTLMipo);
1822 long rk= gauss (*NTLN);
1830 M= (*N) (1,
M.rows(), 1,
M.columns());
1832 for (
int i= 0;
i <
M.rows();
i++)
1833 L[
i]= (*
N) (
i + 1,
M.columns() + 1);
1842 ASSERT (L.
size() <=
M.rows(),
"dimension exceeded");
1846 for (
int i= 1;
i <=
M.rows();
i++)
1847 for (
int j= 1;
j <=
M.columns();
j++)
1851 for (
int i= 0;
i < L.
size();
i++,
j++)
1852 (*
N) (
j,
M.columns() + 1)= L[
i];
1857 long rk= nmod_mat_rref (FLINTN);
1866 long rk= gauss (*NTLN);
1869 if (rk !=
M.columns())
1872 nmod_mat_clear (FLINTN);
1880 nmod_mat_clear (FLINTN);
1894 ASSERT (L.
size() <=
M.rows(),
"dimension exceeded");
1898 for (
int i= 1;
i <=
M.rows();
i++)
1899 for (
int j= 1;
j <=
M.columns();
j++)
1902 for (
int i= 0;
i < L.
size();
i++,
j++)
1903 (*
N) (
j,
M.columns() + 1)= L[
i];
1912 fq_nmod_mat_t FLINTN;
1915 long rk= fq_nmod_mat_rref (FLINTN,ctx);
1916 #elif defined(HAVE_NTL)
1924 zz_pE::init (NTLMipo);
1926 long rk= gauss (*NTLN);
1932 if (rk !=
M.columns())
1934 #if defined(HAVE_NTL) && !defined(HAVE_FLINT)
1942 fq_nmod_mat_clear (FLINTN,ctx);
1944 #elif defined(HAVE_NTL)
1973 int numMon=
size (F);
1983 for (
int k= 0;
k < recResult.
size();
k++)
1985 j += recResult.
size();
1990#if defined(HAVE_NTL) || defined(HAVE_FLINT)
2003 "expected an eval point with only one component");
2011 int numMon=
size (F);
2023 for (
int k= 0;
k < recResult.
size();
k++)
2025 j += recResult.
size();
2036 for (
int i= 0;
i <
A.size();
i++)
2041 tmp= tmp (
j.getItem(),
k);
2076 bool zeroOneOccured=
false;
2077 bool allEqual=
false;
2088 for (
int i= 0;
i <
k;
i++)
2106 if (
result.getLast().isOne() ||
result.getLast().isZero())
2107 zeroOneOccured=
true;
2109 if (
find (list, random))
2111 zeroOneOccured=
false;
2119 zeroOneOccured=
false;
2139 zeroOneOccured=
false;
2151 Geval= Geval (
i.getItem(),
j);
2152 LCeval= LCeval (
i.getItem(),
j);
2157 if (!
find (list, random))
2159 zeroOneOccured=
false;
2170 }
while (
find (list, random));
2182 i.getItem() *=
j.getItem();
2194 Beval= Beval (
i.getItem(),
j);
2212 if (F ==
G)
return F/
Lc(F);
2220 if (best_level == 0)
2238 gcdcAcB=
gcd (cA, cB);
2258 gcdlcAlcB=
gcd (lcA, lcB);
2259 int skelSize=
size (skel, skel.
mvar());
2265 biggestSize=
tmax (biggestSize,
size (
i.coeff()));
2270 bool evalFail=
false;
2281 for (
int i= 0;
i < biggestSize;
i++)
2294 if (V_buf.
level() != 1)
2303 bool prim_fail=
false;
2307 prim_elem_alpha= prim_elem;
2309 ASSERT (!prim_fail,
"failure in integer factorizer");
2313 im_prim_elem=
mapPrimElem (prim_elem, V_buf4, V_buf);
2319 im_prim_elem_alpha= im_prim_elem;
2321 im_prim_elem_alpha=
mapUp (im_prim_elem_alpha, V_buf4, V_buf,
2322 prim_elem, im_prim_elem, source, dest);
2325 j.getItem()=
mapUp (
j.getItem(), V_buf4, V_buf, prim_elem,
2326 im_prim_elem, source, dest);
2327 for (
int k= 0;
k <
i;
k++)
2330 j.getItem()=
mapUp (
j.getItem(), V_buf4, V_buf, prim_elem,
2331 im_prim_elem, source, dest);
2332 gcds[
k]=
mapUp (gcds[
k], V_buf4, V_buf, prim_elem, im_prim_elem,
2338 A=
mapUp (
A, V_buf4, V_buf, prim_elem, im_prim_elem, source,dest);
2339 B=
mapUp (
B, V_buf4, V_buf, prim_elem, im_prim_elem, source,dest);
2351 bool initialized=
false;
2374 delete[] pEvalPoints;
2383 if (
k.exp() !=
l.exp())
2385 delete[] pEvalPoints;
2402 if (Monoms.
size() == 0)
2405 coeffMonoms=
new CFArray [skelSize];
2412 for (
int i= 0;
i < biggestSize;
i++)
2416 for (
int k= 0;
k < skelSize;
k++,
l++)
2420 pL[
k] [
i]=
l.coeff();
2432 for (
int k= 0;
k < skelSize;
k++)
2434 if (biggestSize != coeffMonoms[
k].
size())
2437 for (
int i= 0;
i < coeffMonoms[
k].
size();
i++)
2438 bufArray [
i]= pL[
k] [
i];
2444 if (solution.
size() == 0)
2446 delete[] pEvalPoints;
2449 delete[] coeffMonoms;
2455 for (
int l= 0;
l < solution.
size();
l++)
2456 result += solution[
l]*Monoms [ind +
l];
2457 ind += solution.
size();
2460 delete[] pEvalPoints;
2463 delete[] coeffMonoms;
2496 if (F ==
G)
return F/
Lc(F);
2504 if (best_level == 0)
2523 gcdcAcB=
gcd (cA, cB);
2543 gcdlcAlcB=
gcd (lcA, lcB);
2544 int skelSize=
size (skel, skel.
mvar());
2552 bufSize=
size (
i.coeff());
2553 biggestSize=
tmax (biggestSize, bufSize);
2554 numberUni += bufSize;
2557 numberUni= (int) ceil ( (
double) numberUni / (skelSize - 1));
2558 biggestSize=
tmax (biggestSize , numberUni);
2560 numberUni= biggestSize +
size (
LC(skel)) - 1;
2561 int biggestSize2=
tmax (numberUni, biggestSize);
2567 bool evalFail=
false;
2578 for (
int i= 0;
i < biggestSize;
i++)
2590 if (V_buf.
level() != 1)
2599 bool prim_fail=
false;
2603 prim_elem_alpha= prim_elem;
2605 ASSERT (!prim_fail,
"failure in integer factorizer");
2609 im_prim_elem=
mapPrimElem (prim_elem, V_buf4, V_buf);
2615 im_prim_elem_alpha= im_prim_elem;
2617 im_prim_elem_alpha=
mapUp (im_prim_elem_alpha, V_buf4, V_buf,
2618 prim_elem, im_prim_elem, source, dest);
2621 i.getItem()=
mapUp (
i.getItem(), V_buf4, V_buf, prim_elem,
2622 im_prim_elem, source, dest);
2625 A=
mapUp (
A, V_buf4, V_buf, prim_elem, im_prim_elem, source,dest);
2626 B=
mapUp (
B, V_buf4, V_buf, prim_elem, im_prim_elem, source,dest);
2638 bool initialized=
false;
2667 delete[] pEvalPoints;
2676 if (
k.exp() !=
l.exp())
2678 delete[] pEvalPoints;
2695 if (Monoms.
size() == 0)
2698 coeffMonoms=
new CFArray [skelSize];
2704 int minimalColumnsIndex;
2706 minimalColumnsIndex= 1;
2708 minimalColumnsIndex= 0;
2709 int minimalColumns=-1;
2714 for (
int i= 0;
i < skelSize;
i++)
2718 minimalColumns= coeffMonoms[
i].
size();
2721 if (minimalColumns > coeffMonoms[
i].
size())
2723 minimalColumns= coeffMonoms[
i].
size();
2724 minimalColumnsIndex=
i;
2729 pMat[0]=
CFMatrix (biggestSize, coeffMonoms[0].
size());
2730 pMat[1]=
CFMatrix (biggestSize, coeffMonoms[minimalColumnsIndex].
size());
2732 for (
int i= 0;
i < biggestSize;
i++)
2736 for (
int k= 0;
k < skelSize;
k++,
l++)
2740 pL[
k] [
i]=
l.coeff();
2742 if (
i == 0 &&
k != 0 &&
k != minimalColumnsIndex)
2744 else if (
i == 0 && (
k == 0 ||
k == minimalColumnsIndex))
2746 if (
i > 0 && (
k == 0 ||
k == minimalColumnsIndex))
2751 if (pMat[
k].rows() >=
i + 1)
2753 for (
int ind= 1; ind < coeffEval.
size() + 1; ind++)
2754 pMat[
k] (
i + 1, ind)= coeffEval[ind - 1];
2757 if (
k == minimalColumnsIndex)
2759 if (pMat[1].rows() >=
i + 1)
2761 for (
int ind= 1; ind < coeffEval.
size() + 1; ind++)
2762 pMat[1] (
i + 1, ind)= coeffEval[ind - 1];
2771 int matRows, matColumns;
2772 matRows= pMat[1].
rows();
2773 matColumns= pMat[0].
columns() - 1;
2774 matColumns += pMat[1].
columns();
2776 Mat=
CFMatrix (matRows, matColumns);
2777 for (
int i= 1;
i <= matRows;
i++)
2779 Mat (
i,
j)= pMat[1] (
i,
j);
2781 for (
int j= pMat[1].columns() + 1;
j <= matColumns;
2784 for (
int i= 1;
i <= matRows;
i++)
2785 Mat (
i,
j)= (-pMat [0] (
i, ind + 1))*pL[minimalColumnsIndex] [
i - 1];
2789 for (
int i= 0;
i < pMat[0].
rows();
i++)
2790 firstColumn [
i]= pMat[0] (
i + 1, 1);
2792 CFArray bufArray= pL[minimalColumnsIndex];
2794 for (
int i= 0;
i < biggestSize;
i++)
2795 pL[minimalColumnsIndex] [
i] *= firstColumn[
i];
2800 if (V_buf.
level() != 1)
2802 pL[minimalColumnsIndex], V_buf);
2805 pL[minimalColumnsIndex]);
2807 if (solution.
size() == 0)
2812 pL[minimalColumnsIndex]= bufArray;
2815 if (biggestSize != biggestSize2)
2817 bufpEvalPoints= pEvalPoints;
2818 pEvalPoints=
new CFList [biggestSize2];
2821 for (
int i= 0;
i < biggestSize;
i++)
2823 pEvalPoints[
i]= bufpEvalPoints [
i];
2824 gcds[
i]= bufGcds[
i];
2826 for (
int i= 0;
i < biggestSize2 - biggestSize;
i++)
2834 delete[] pEvalPoints;
2837 delete[] coeffMonoms;
2839 if (bufpEvalPoints !=
NULL)
2840 delete [] bufpEvalPoints;
2849 if (
k.exp() !=
l.exp())
2851 delete[] pEvalPoints;
2854 delete[] coeffMonoms;
2856 if (bufpEvalPoints !=
NULL)
2857 delete [] bufpEvalPoints;
2865 gcds[
i + biggestSize]=
g;
2868 for (
int i= 0;
i < biggestSize;
i++)
2872 for (
int k= 1;
k < skelSize;
k++,
l++)
2875 pMat[
k]=
CFMatrix (biggestSize2,coeffMonoms[
k].
size()+biggestSize2-1);
2876 if (
k == minimalColumnsIndex)
2879 if (pMat[
k].rows() >=
i + 1)
2881 for (
int ind= 1; ind < coeffEval.
size() + 1; ind++)
2882 pMat[
k] (
i + 1, ind)= coeffEval[ind - 1];
2887 pMat[0]=
CFMatrix (biggestSize2, coeffMonoms[0].
size() + biggestSize2 - 1);
2888 for (
int j= 1;
j <= Mat.
rows();
j++)
2890 pMat [0] (
j,
k)= Mat (
j,
k);
2892 for (
int j= 1;
j <= Mat.
rows();
j++)
2894 pMat [minimalColumnsIndex] (
j,
k)= Mat (
j,
k);
2896 for (
int i= 0;
i < skelSize;
i++)
2900 for (
int j= 0;
j < bufArray.
size();
j++)
2901 pL[
i] [
j]= bufArray [
j];
2904 for (
int i= 0;
i < biggestSize2 - biggestSize;
i++)
2908 for (
int k= 0;
k < skelSize;
k++,
l++)
2910 pL[
k] [
i + biggestSize]=
l.coeff();
2912 if (pMat[
k].rows() >=
i + biggestSize + 1)
2914 for (
int ind= 1; ind < coeffEval.
size() + 1; ind++)
2915 pMat[
k] (
i + biggestSize + 1, ind)= coeffEval[ind - 1];
2920 for (
int i= 0;
i < skelSize;
i++)
2922 if (pL[
i].
size() > 1)
2924 for (
int j= 2;
j <= pMat[
i].
rows();
j++)
2925 pMat[
i] (
j, coeffMonoms[
i].
size() +
j - 1)=
2930 matColumns= biggestSize2 - 1;
2932 for (
int i= 0;
i < skelSize;
i++)
2934 if (V_buf.
level() == 1)
2939 if (pMat[
i] (coeffMonoms[
i].
size(), coeffMonoms[
i].
size()) == 0)
2941 delete[] pEvalPoints;
2944 delete[] coeffMonoms;
2946 if (bufpEvalPoints !=
NULL)
2947 delete [] bufpEvalPoints;
2953 matRows += pMat[
i].
rows() - coeffMonoms[
i].
size();
2957 Mat=
CFMatrix (matRows, matColumns);
2961 for (
int i= 0;
i < skelSize;
i++)
2963 if (coeffMonoms[
i].
size() + 1 >= pMat[
i].rows() || coeffMonoms[
i].
size() + 1 >= pMat[
i].columns())
2965 delete[] pEvalPoints;
2968 delete[] coeffMonoms;
2970 if (bufpEvalPoints !=
NULL)
2971 delete [] bufpEvalPoints;
2977 bufMat= pMat[
i] (coeffMonoms[
i].
size() + 1, pMat[
i].
rows(),
2980 for (
int j= 1;
j <= bufMat.
rows();
j++)
2982 Mat (
j + ind,
k)= bufMat(
j,
k);
2983 bufArray2= coeffMonoms[
i].
size();
2984 for (
int j= 1;
j <= pMat[
i].
rows();
j++)
2986 if (
j > coeffMonoms[
i].
size())
2987 bufArray [
j-coeffMonoms[
i].
size() + ind - 1]= pL[
i] [
j - 1];
2989 bufArray2 [
j - 1]= pL[
i] [
j - 1];
2992 ind += bufMat.
rows();
2996 if (V_buf.
level() != 1)
3001 if (solution.
size() == 0)
3003 delete[] pEvalPoints;
3006 delete[] coeffMonoms;
3008 if (bufpEvalPoints !=
NULL)
3009 delete [] bufpEvalPoints;
3019 for (
int i= 0;
i < skelSize;
i++)
3022 for (
int i= 0;
i < bufSolution.
size();
i++, ind++)
3023 result += Monoms [ind]*bufSolution[
i];
3032 delete[] pEvalPoints;
3035 delete[] coeffMonoms;
3038 if (bufpEvalPoints !=
NULL)
3039 delete [] bufpEvalPoints;
3050 int ind2= 0, ind3= 2;
3052 for (
int l= 0;
l < minimalColumnsIndex;
l++)
3053 ind += coeffMonoms[
l].
size();
3055 l++, ind2++, ind3++)
3057 result += solution[
l]*Monoms [1 + ind2];
3058 for (
int i= 0;
i < pMat[0].
rows();
i++)
3059 firstColumn[
i] += solution[
l]*pMat[0] (
i + 1, ind3);
3061 for (
int l= 0;
l < solution.
size() + 1 - pMat[0].columns();
l++)
3062 result += solution[
l]*Monoms [ind +
l];
3063 ind= coeffMonoms[0].
size();
3064 for (
int k= 1;
k < skelSize;
k++)
3066 if (
k == minimalColumnsIndex)
3068 ind += coeffMonoms[
k].
size();
3071 if (
k != minimalColumnsIndex)
3073 for (
int i= 0;
i < biggestSize;
i++)
3074 pL[
k] [
i] *= firstColumn [
i];
3077 if (biggestSize != coeffMonoms[
k].
size() &&
k != minimalColumnsIndex)
3080 for (
int i= 0;
i < bufArray.
size();
i++)
3081 bufArray [
i]= pL[
k] [
i];
3087 if (solution.
size() == 0)
3089 delete[] pEvalPoints;
3092 delete[] coeffMonoms;
3099 if (
k != minimalColumnsIndex)
3101 for (
int l= 0;
l < solution.
size();
l++)
3102 result += solution[
l]*Monoms [ind +
l];
3103 ind += solution.
size();
3107 delete[] pEvalPoints;
3111 delete[] coeffMonoms;
3141 if (F ==
G)
return F/
Lc(F);
3146 if (best_level == 0)
return B.
genOne();
3163 gcdcAcB=
gcd (cA, cB);
3183 gcdlcAlcB=
gcd (lcA, lcB);
3198 CanonicalForm m, random_element, G_m, G_random_element,
H, cH, ppH, skeleton;
3205 bool inextension=
false;
3213 if (random_element == 0 && !fail)
3215 if (!
find (
l, random_element))
3216 l.append (random_element);
3226 bool prim_fail=
false;
3229 if (V_buf4 ==
alpha)
3230 prim_elem_alpha= prim_elem;
3232 if (V_buf3 != V_buf4)
3234 m=
mapDown (
m, prim_elem, im_prim_elem, V_buf4, source, dest);
3235 G_m=
mapDown (
m, prim_elem, im_prim_elem, V_buf4, source, dest);
3236 newtonPoly=
mapDown (newtonPoly, prim_elem, im_prim_elem, V_buf4,
3238 ppA=
mapDown (ppA, prim_elem, im_prim_elem, V_buf4, source, dest);
3239 ppB=
mapDown (ppB, prim_elem, im_prim_elem, V_buf4, source, dest);
3240 gcdlcAlcB=
mapDown (gcdlcAlcB, prim_elem, im_prim_elem, V_buf4, source,
3243 i.getItem()=
mapDown (
i.getItem(), prim_elem, im_prim_elem, V_buf4,
3247 ASSERT (!prim_fail,
"failure in integer factorizer");
3251 im_prim_elem=
mapPrimElem (prim_elem, V_buf4, V_buf);
3253 if (V_buf4 ==
alpha)
3254 im_prim_elem_alpha= im_prim_elem;
3256 im_prim_elem_alpha=
mapUp (im_prim_elem_alpha, V_buf4, V_buf, prim_elem,
3257 im_prim_elem, source, dest);
3263 i.getItem()=
mapUp (
i.getItem(), V_buf4, V_buf, prim_elem,
3264 im_prim_elem, source, dest);
3265 m=
mapUp (
m, V_buf4, V_buf, prim_elem, im_prim_elem, source, dest);
3266 G_m=
mapUp (G_m, V_buf4, V_buf, prim_elem, im_prim_elem, source, dest);
3267 newtonPoly=
mapUp (newtonPoly, V_buf4, V_buf, prim_elem, im_prim_elem,
3269 ppA=
mapUp (ppA, V_buf4, V_buf, prim_elem, im_prim_elem, source, dest);
3270 ppB=
mapUp (ppB, V_buf4, V_buf, prim_elem, im_prim_elem, source, dest);
3271 gcdlcAlcB=
mapUp (gcdlcAlcB, V_buf4, V_buf, prim_elem, im_prim_elem,
3280 sparseGCDFq (ppA (random_element,
x), ppB (random_element,
x), V_buf,
3283 "time for recursive call: ");
3284 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
3292 sparseGCDFq (ppA(random_element,
x), ppB(random_element,
x), V_buf,
3295 "time for recursive call: ");
3296 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
3313 if (!
find (
l, random_element))
3314 l.append (random_element);
3319 (gcdlcAlcB(random_element,
x)/
uni_lcoeff (G_random_element))
3322 skeleton= G_random_element;
3337 H=
newtonInterp (random_element, G_random_element, newtonPoly, G_m,
x);
3349 DEBOUTLN (cerr,
"ppH before mapDown= " << ppH);
3350 ppH=
mapDown (ppH, prim_elem_alpha, im_prim_elem_alpha,
alpha, u,
v);
3352 DEBOUTLN (cerr,
"ppH after mapDown= " << ppH);
3354 return N(gcdcAcB*ppH);
3358 return N(gcdcAcB*ppH);
3361 newtonPoly= newtonPoly*(
x - random_element);
3362 m=
m*(
x - random_element);
3363 if (!
find (
l, random_element))
3364 l.append (random_element);
3373 if (random_element == 0 && !fail)
3375 if (!
find (
l, random_element))
3376 l.append (random_element);
3386 bool prim_fail=
false;
3389 if (V_buf4 ==
alpha)
3390 prim_elem_alpha= prim_elem;
3392 if (V_buf3 != V_buf4)
3394 m=
mapDown (
m, prim_elem, im_prim_elem, V_buf4, source, dest);
3395 G_m=
mapDown (
m, prim_elem, im_prim_elem, V_buf4, source, dest);
3396 newtonPoly=
mapDown (newtonPoly, prim_elem, im_prim_elem, V_buf4,
3398 ppA=
mapDown (ppA, prim_elem, im_prim_elem, V_buf4, source, dest);
3399 ppB=
mapDown (ppB, prim_elem, im_prim_elem, V_buf4, source, dest);
3400 gcdlcAlcB=
mapDown (gcdlcAlcB, prim_elem, im_prim_elem, V_buf4,
3403 i.getItem()=
mapDown (
i.getItem(), prim_elem, im_prim_elem, V_buf4,
3407 ASSERT (!prim_fail,
"failure in integer factorizer");
3411 im_prim_elem=
mapPrimElem (prim_elem, V_buf4, V_buf);
3413 if (V_buf4 ==
alpha)
3414 im_prim_elem_alpha= im_prim_elem;
3416 im_prim_elem_alpha=
mapUp (im_prim_elem_alpha, V_buf4, V_buf,
3417 prim_elem, im_prim_elem, source, dest);
3423 i.getItem()=
mapUp (
i.getItem(), V_buf4, V_buf, prim_elem,
3424 im_prim_elem, source, dest);
3425 m=
mapUp (
m, V_buf4, V_buf, prim_elem, im_prim_elem, source, dest);
3426 G_m=
mapUp (G_m, V_buf4, V_buf, prim_elem, im_prim_elem, source, dest);
3427 newtonPoly=
mapUp (newtonPoly, V_buf4, V_buf, prim_elem, im_prim_elem,
3429 ppA=
mapUp (ppA, V_buf4, V_buf, prim_elem, im_prim_elem, source, dest);
3430 ppB=
mapUp (ppB, V_buf4, V_buf, prim_elem, im_prim_elem, source, dest);
3432 gcdlcAlcB=
mapUp (gcdlcAlcB, V_buf4, V_buf, prim_elem, im_prim_elem,
3444 bool sparseFail=
false;
3445 if (
LC (skeleton).inCoeffDomain())
3448 skeleton,V_buf, sparseFail, coeffMonoms,Monoms);
3452 skeleton, V_buf, sparseFail, coeffMonoms,
3458 "time for recursive call: ");
3459 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
3465 bool sparseFail=
false;
3466 if (
LC (skeleton).inCoeffDomain())
3469 skeleton,V_buf, sparseFail,coeffMonoms, Monoms);
3473 skeleton, V_buf, sparseFail, coeffMonoms,
3479 "time for recursive call: ");
3480 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
3497 if (!
find (
l, random_element))
3498 l.append (random_element);
3503 (gcdlcAlcB(random_element,
x)/
uni_lcoeff (G_random_element))
3521 H=
newtonInterp (random_element, G_random_element, newtonPoly, G_m,
x);
3523 "time for newton interpolation: ");
3537 DEBOUTLN (cerr,
"ppH before mapDown= " << ppH);
3538 ppH=
mapDown (ppH, prim_elem_alpha, im_prim_elem_alpha,
alpha, u,
v);
3540 DEBOUTLN (cerr,
"ppH after mapDown= " << ppH);
3542 return N(gcdcAcB*ppH);
3547 return N(gcdcAcB*ppH);
3552 newtonPoly= newtonPoly*(
x - random_element);
3553 m=
m*(
x - random_element);
3554 if (!
find (
l, random_element))
3555 l.append (random_element);
3573 if (F ==
G)
return F/
Lc(F);
3578 if (best_level == 0)
return B.
genOne();
3595 gcdcAcB=
gcd (cA, cB);
3615 gcdlcAlcB=
gcd (lcA, lcB);
3631 CanonicalForm m, random_element, G_m, G_random_element,
H, cH, ppH, skeleton;
3638 bool inextension=
false;
3648 if (random_element == 0 && !fail)
3650 if (!
find (
l, random_element))
3651 l.append (random_element);
3655 if (!fail && !inextension)
3663 "time for recursive call: ");
3664 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
3666 else if (!fail && inextension)
3674 "time for recursive call: ");
3675 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
3677 else if (fail && !inextension)
3684 bool initialized=
false;
3706 "time for recursive call: ");
3707 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
3709 else if (fail && inextension)
3716 bool prim_fail=
false;
3721 if (V_buf3 !=
alpha)
3724 G_m=
mapDown (
m, prim_elem, im_prim_elem,
alpha, source, dest);
3725 newtonPoly=
mapDown (newtonPoly, prim_elem, im_prim_elem,
alpha, source,
3727 ppA=
mapDown (ppA, prim_elem, im_prim_elem,
alpha, source, dest);
3728 ppB=
mapDown (ppB, prim_elem, im_prim_elem,
alpha, source, dest);
3729 gcdlcAlcB=
mapDown (gcdlcAlcB, prim_elem, im_prim_elem,
alpha, source,
3732 i.getItem()=
mapDown (
i.getItem(), prim_elem, im_prim_elem,
alpha,
3736 ASSERT (!prim_fail,
"failure in integer factorizer");
3746 i.getItem()=
mapUp (
i.getItem(),
alpha, V_buf, prim_elem,
3747 im_prim_elem, source, dest);
3748 m=
mapUp (
m,
alpha, V_buf, prim_elem, im_prim_elem, source, dest);
3749 G_m=
mapUp (G_m,
alpha, V_buf, prim_elem, im_prim_elem, source, dest);
3750 newtonPoly=
mapUp (newtonPoly,
alpha, V_buf, prim_elem, im_prim_elem,
3752 ppA=
mapUp (ppA,
alpha, V_buf, prim_elem, im_prim_elem, source, dest);
3753 ppB=
mapUp (ppB,
alpha, V_buf, prim_elem, im_prim_elem, source, dest);
3754 gcdlcAlcB=
mapUp (gcdlcAlcB,
alpha, V_buf, prim_elem, im_prim_elem,
3762 sparseGCDFq (ppA (random_element,
x), ppB (random_element,
x), V_buf,
3765 "time for recursive call: ");
3766 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
3784 if (!
find (
l, random_element))
3785 l.append (random_element);
3790 (gcdlcAlcB(random_element,
x)/
uni_lcoeff (G_random_element))
3793 skeleton= G_random_element;
3809 H=
newtonInterp (random_element, G_random_element, newtonPoly, G_m,
x);
3822 return N(gcdcAcB*ppH);
3826 newtonPoly= newtonPoly*(
x - random_element);
3827 m=
m*(
x - random_element);
3828 if (!
find (
l, random_element))
3829 l.append (random_element);
3842 if (random_element == 0 && !fail)
3844 if (!
find (
l, random_element))
3845 l.append (random_element);
3849 bool sparseFail=
false;
3850 if (!fail && !inextension)
3854 if (
LC (skeleton).inCoeffDomain())
3857 skeleton,
x, sparseFail, coeffMonoms,
3862 skeleton,
x, sparseFail,
3863 coeffMonoms, Monoms);
3865 "time for recursive call: ");
3866 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
3868 else if (!fail && inextension)
3872 if (
LC (skeleton).inCoeffDomain())
3875 skeleton,
alpha, sparseFail, coeffMonoms,
3880 skeleton,
alpha, sparseFail, coeffMonoms,
3883 "time for recursive call: ");
3884 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
3886 else if (fail && !inextension)
3893 bool initialized=
false;
3911 if (
LC (skeleton).inCoeffDomain())
3914 skeleton,
alpha, sparseFail, coeffMonoms,
3919 skeleton,
alpha, sparseFail, coeffMonoms,
3922 "time for recursive call: ");
3923 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
3925 else if (fail && inextension)
3932 bool prim_fail=
false;
3937 if (V_buf3 !=
alpha)
3940 G_m=
mapDown (
m, prim_elem, im_prim_elem,
alpha, source, dest);
3941 newtonPoly=
mapDown (newtonPoly, prim_elem, im_prim_elem,
alpha,
3943 ppA=
mapDown (ppA, prim_elem, im_prim_elem,
alpha, source, dest);
3944 ppB=
mapDown (ppB, prim_elem, im_prim_elem,
alpha, source, dest);
3945 gcdlcAlcB=
mapDown (gcdlcAlcB, prim_elem, im_prim_elem,
alpha,
3948 i.getItem()=
mapDown (
i.getItem(), prim_elem, im_prim_elem,
alpha,
3952 ASSERT (!prim_fail,
"failure in integer factorizer");
3962 i.getItem()=
mapUp (
i.getItem(),
alpha, V_buf, prim_elem,
3963 im_prim_elem, source, dest);
3964 m=
mapUp (
m,
alpha, V_buf, prim_elem, im_prim_elem, source, dest);
3965 G_m=
mapUp (G_m,
alpha, V_buf, prim_elem, im_prim_elem, source, dest);
3966 newtonPoly=
mapUp (newtonPoly,
alpha, V_buf, prim_elem, im_prim_elem,
3968 ppA=
mapUp (ppA,
alpha, V_buf, prim_elem, im_prim_elem, source, dest);
3969 ppB=
mapUp (ppB,
alpha, V_buf, prim_elem, im_prim_elem, source, dest);
3970 gcdlcAlcB=
mapUp (gcdlcAlcB,
alpha, V_buf, prim_elem, im_prim_elem,
3977 if (
LC (skeleton).inCoeffDomain())
3980 skeleton, V_buf, sparseFail, coeffMonoms,
3985 skeleton, V_buf, sparseFail,
3986 coeffMonoms, Monoms);
3988 "time for recursive call: ");
3989 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
4010 if (!
find (
l, random_element))
4011 l.append (random_element);
4016 (gcdlcAlcB(random_element,
x)/
uni_lcoeff (G_random_element))
4034 H=
newtonInterp (random_element, G_random_element, newtonPoly, G_m,
x);
4036 "time for newton interpolation: ");
4049 return N(gcdcAcB*ppH);
4054 newtonPoly= newtonPoly*(
x - random_element);
4055 m=
m*(
x - random_element);
4056 if (!
find (
l, random_element))
4057 l.append (random_element);
4146#if defined(HAVE_NTL) || defined(HAVE_FLINT)
4161 "time for gcd mod p in modular gcd: ");
4240 "time for successful termination in modular gcd: ");
4245 "time for unsuccessful termination in modular gcd: ");
CFMatrix * convertNmod_mat_t2FacCFMatrix(const nmod_mat_t m)
conversion of a FLINT matrix over Z/p to a factory matrix
void convertFacCFMatrix2nmod_mat_t(nmod_mat_t M, const CFMatrix &m)
conversion of a factory matrix over Z/p to a nmod_mat_t
void convertFacCFMatrix2Fq_nmod_mat_t(fq_nmod_mat_t M, const fq_nmod_ctx_t fq_con, const CFMatrix &m)
conversion of a factory matrix over F_q to a fq_nmod_mat_t
CanonicalForm convertnmod_poly_t2FacCF(const nmod_poly_t poly, const Variable &x)
conversion of a FLINT poly over Z/p to CanonicalForm
CFMatrix * convertFq_nmod_mat_t2FacCFMatrix(const fq_nmod_mat_t m, const fq_nmod_ctx_t &fq_con, const Variable &alpha)
conversion of a FLINT matrix over F_q to a factory matrix
This file defines functions for conversion to FLINT (www.flintlib.org) and back.
Rational pow(const Rational &a, int e)
Rational abs(const Rational &a)
CFMatrix * convertNTLmat_zz_p2FacCFMatrix(const mat_zz_p &m)
CFMatrix * convertNTLmat_zz_pE2FacCFMatrix(const mat_zz_pE &m, const Variable &alpha)
CanonicalForm convertNTLzzpX2CF(const zz_pX &poly, const Variable &x)
mat_zz_pE * convertFacCFMatrix2NTLmat_zz_pE(const CFMatrix &m)
zz_pX convertFacCF2NTLzzpX(const CanonicalForm &f)
mat_zz_p * convertFacCFMatrix2NTLmat_zz_p(const CFMatrix &m)
Conversion to and from NTL.
const CanonicalForm CFMap CFMap & N
const CanonicalForm CFMap CFMap int & both_non_zero
const CanonicalForm CFMap CFMap bool topLevel
coprimality check and change of representation mod n
CanonicalForm sparseGCDFq(const CanonicalForm &F, const CanonicalForm &G, const Variable &alpha, CFList &l, bool &topLevel)
CFArray readOffSolution(const CFMatrix &M, const long rk)
M in row echolon form, rk rank of M.
CanonicalForm modGCDFq(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &coF, CanonicalForm &coG, Variable &alpha, CFList &l, bool &topLevel)
GCD of F and G over , l and topLevel are only used internally, output is monic based on Alg....
static CanonicalForm GFRandomElement(const CanonicalForm &F, CFList &list, bool &fail)
compute a random element a of GF, s.t. F(a) , F is a univariate polynomial, returns fail if there ar...
CFArray evaluateMonom(const CanonicalForm &F, const CFList &evalPoints)
const CanonicalForm const CanonicalForm const CanonicalForm & coG
CFArray getMonoms(const CanonicalForm &F)
extract monomials of F, parts in algebraic variable are considered coefficients
void mult(CFList &L1, const CFList &L2)
multiply two lists componentwise
const CanonicalForm const CanonicalForm const CanonicalForm const CanonicalForm & cand
long gaussianElimFq(CFMatrix &M, CFArray &L, const Variable &alpha)
int myCompress(const CanonicalForm &F, const CanonicalForm &G, CFMap &M, CFMap &N, bool topLevel)
compressing two polynomials F and G, M is used for compressing, N to reverse the compression
static Variable chooseExtension(const Variable &alpha)
CFArray evaluate(const CFArray &A, const CFList &evalPoints)
CanonicalForm monicSparseInterpol(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &skeleton, const Variable &alpha, bool &fail, CFArray *&coeffMonoms, CFArray &Monoms)
long gaussianElimFp(CFMatrix &M, CFArray &L)
static CanonicalForm uni_content(const CanonicalForm &F)
compute the content of F, where F is considered as an element of
CFArray solveGeneralVandermonde(const CFArray &M, const CFArray &A)
CanonicalForm extractContents(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &contentF, CanonicalForm &contentG, CanonicalForm &ppF, CanonicalForm &ppG, const int d)
static CanonicalForm uni_lcoeff(const CanonicalForm &F)
compute the leading coefficient of F, where F is considered as an element of , order on is dp.
CFArray solveVandermonde(const CFArray &M, const CFArray &A)
const CanonicalForm const CanonicalForm & coF
CanonicalForm cd(bCommonDen(FF))
CanonicalForm nonMonicSparseInterpol(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &skeleton, const Variable &alpha, bool &fail, CFArray *&coeffMonoms, CFArray &Monoms)
CanonicalForm modGCDFp(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &coF, CanonicalForm &coG, bool &topLevel, CFList &l)
CFArray solveSystemFp(const CFMatrix &M, const CFArray &L)
CanonicalForm sparseGCDFp(const CanonicalForm &F, const CanonicalForm &G, bool &topLevel, CFList &l)
static CanonicalForm randomElement(const CanonicalForm &F, const Variable &alpha, CFList &list, bool &fail)
compute a random element a of , s.t. F(a) , F is a univariate polynomial, returns fail if there are...
static CanonicalForm FpRandomElement(const CanonicalForm &F, CFList &list, bool &fail)
CanonicalForm modGCDGF(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &coF, CanonicalForm &coG, CFList &l, bool &topLevel)
GCD of F and G over GF, based on Alg. 7.2. as described in "Algorithms for Computer Algebra" by Gedde...
static CanonicalForm newtonInterp(const CanonicalForm &alpha, const CanonicalForm &u, const CanonicalForm &newtonPoly, const CanonicalForm &oldInterPoly, const Variable &x)
Newton interpolation - Incremental algorithm. Given a list of values alpha_i and a list of polynomial...
CFArray solveSystemFq(const CFMatrix &M, const CFArray &L, const Variable &alpha)
CFList evaluationPoints(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Feval, CanonicalForm &Geval, const CanonicalForm &LCF, const bool &GF, const Variable &alpha, bool &fail, CFList &list)
modular and sparse modular GCD algorithms over finite fields and Z.
bool terminationTest(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &coF, const CanonicalForm &coG, const CanonicalForm &cand)
CanonicalForm modGCDZ(const CanonicalForm &FF, const CanonicalForm &GG)
modular GCD over Z
static void evalPoint(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &FEval, CanonicalForm &GEval, CFGenerator &evalPoint)
This file provides functions to compute the Newton polygon of a bivariate polynomial.
CanonicalForm bCommonDen(const CanonicalForm &f)
CanonicalForm bCommonDen ( const CanonicalForm & f )
CanonicalForm maxNorm(const CanonicalForm &f)
CanonicalForm maxNorm ( const CanonicalForm & f )
bool fdivides(const CanonicalForm &f, const CanonicalForm &g)
bool fdivides ( const CanonicalForm & f, const CanonicalForm & g )
declarations of higher level algorithms.
void FACTORY_PUBLIC chineseRemainder(const CanonicalForm &x1, const CanonicalForm &q1, const CanonicalForm &x2, const CanonicalForm &q2, CanonicalForm &xnew, CanonicalForm &qnew)
void chineseRemainder ( const CanonicalForm & x1, const CanonicalForm & q1, const CanonicalForm & x2,...
#define ASSERT(expression, message)
static const int SW_USE_CHINREM_GCD
set to 1 to use modular gcd over Z
static CanonicalForm balance_p(const CanonicalForm &f, const CanonicalForm &q, const CanonicalForm &qh)
CanonicalForm randomIrredpoly(int i, const Variable &x)
computes a random monic irreducible univariate polynomial in x over Fp of degree i via NTL/FLINT
generate random irreducible univariate polynomials
Iterators for CanonicalForm's.
static CanonicalForm bound(const CFMatrix &M)
CanonicalForm mapPrimElem(const CanonicalForm &primElem, const Variable &alpha, const Variable &beta)
compute the image of a primitive element of in . We assume .
CanonicalForm GFMapDown(const CanonicalForm &F, int k)
maps a polynomial over to a polynomial over , d needs to be a multiple of k
CanonicalForm primitiveElement(const Variable &alpha, Variable &beta, bool &fail)
determine a primitive element of , is a primitive element of a field which is isomorphic to
static CanonicalForm mapDown(const CanonicalForm &F, const Variable &alpha, const CanonicalForm &G, CFList &source, CFList &dest)
the CanonicalForm G is the output of map_up, returns F considered as an element over ,...
static CanonicalForm mapUp(const Variable &alpha, const Variable &beta)
and is a primitive element, returns the image of
CanonicalForm GFMapUp(const CanonicalForm &F, int k)
maps a polynomial over to a polynomial over , d needs to be a multiple of k
This file implements functions to map between extensions of finite fields.
int cf_getBigPrime(int i)
GLOBAL_VAR flint_rand_t FLINTrandom
generate random integers, random elements of finite fields
generate random evaluation points
VAR void(* factoryError)(const char *s)
int ipower(int b, int m)
int ipower ( int b, int m )
generate random elements in F_p(alpha)
CanonicalForm generate() const
class to iterate through CanonicalForm's
generate random elements in F_p
CanonicalForm generate() const
generate random elements in GF
CanonicalForm generate() const
factory's class for variables
functions to print debug output
#define DEBOUTLN(stream, objects)
const Variable & v
< [in] a sqrfree bivariate poly
CFList *& Aeval
<[in] poly
CFList evalPoints(const CanonicalForm &F, CFList &eval, const Variable &alpha, CFList &list, const bool &GF, bool &fail)
evaluation point search for multivariate factorization, looks for a (F.level() - 1)-tuple such that t...
fq_nmod_ctx_clear(fq_con)
nmod_poly_init(FLINTmipo, getCharacteristic())
fq_nmod_ctx_init_modulus(fq_con, FLINTmipo, "Z")
convertFacCF2nmod_poly_t(FLINTmipo, M)
nmod_poly_clear(FLINTmipo)
This file defines functions for Hensel lifting.
some useful template functions.
template CanonicalForm tmax(const CanonicalForm &, const CanonicalForm &)
template CanonicalForm tmin(const CanonicalForm &, const CanonicalForm &)
template bool find(const List< CanonicalForm > &, const CanonicalForm &)
gmp_float log(const gmp_float &a)
int status int void * buf
#define TIMING_DEFINE_PRINT(t)
#define TIMING_END_AND_PRINT(t, msg)
void prune1(const Variable &alpha)
void prune(Variable &alpha)
CanonicalForm getMipo(const Variable &alpha, const Variable &x)
void setMipo(const Variable &alpha, const CanonicalForm &mipo)
Variable rootOf(const CanonicalForm &mipo, char name)
returns a symbolic root of polynomial with name name Use it to define algebraic variables