1226{
1230 {
1234 }
1236 {
1240 }
1242 {
1245 }
1247 {
1251 }
1253 {
1256 }
1258 {
1261 }
1263 {
1266 }
1269
1270 if (best_level == 0)
1271 {
1275 }
1276
1279
1281
1282
1284 {
1289 }
1290
1294
1297 gcdcAcB=
gcd (cA, cB);
1300
1305
1306 gcdlcAlcB=
gcd (lcA, lcB);
1307
1309 int d0;
1310
1311 if (d == 0)
1312 {
1313 coF=
N (ppA*(cA/gcdcAcB));
1314 coG=
N (ppB*(cB/gcdcAcB));
1316 }
1317
1319
1320 if (d0 < d)
1321 d= d0;
1322
1323 if (d == 0)
1324 {
1325 coF=
N (ppA*(cA/gcdcAcB));
1326 coG=
N (ppB*(cB/gcdcAcB));
1328 }
1329
1331 CanonicalForm newtonPoly, coF_random_element, coG_random_element,
1332 coF_m, coG_m, ppCoF, ppCoG;
1333
1334 newtonPoly= 1;
1339 G_m= 0;
1341 bool fail= false;
1342 bool inextension= false;
1345 int bound1=
degree (ppA, 1);
1346 int bound2=
degree (ppB, 1);
1347 do
1348 {
1349 if (inextension)
1351 else
1353
1354 if (!fail && !inextension)
1355 {
1358 G_random_element=
1359 modGCDFp (ppA (random_element,
x), ppB (random_element,
x),
1360 coF_random_element, coG_random_element,
topLevel,
1361 list);
1363 "time for recursive call: ");
1364 DEBOUTLN (cerr,
"G_random_element= " << G_random_element);
1365 }
1366 else if (!fail && inextension)
1367 {
1370 G_random_element=
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);
1377 }
1378 else if (fail && !inextension)
1379 {
1384 int deg= 2;
1385 bool initialized= false;
1386 do
1387 {
1389 if (initialized)
1391 else
1393 inextension= true;
1394 initialized= true;
1395 fail= false;
1397 deg++;
1398 } while (fail);
1403 G_random_element=
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);
1410 }
1411 else if (fail && inextension)
1412 {
1415
1418 bool prim_fail= false;
1422
1423 if (V_buf3 !=
alpha)
1424 {
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,
1430 source, dest);
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,
1434 dest);
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,
1439 source, dest);
1440 }
1441
1442 ASSERT (!prim_fail,
"failure in integer factorizer");
1443 if (prim_fail)
1444 ;
1445 else
1447
1450
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,
1459 source, dest);
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,
1463 source, dest);
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);
1466 fail= false;
1471 G_random_element=
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);
1479 }
1480
1484 else
1485 d0= 0;
1486
1487 if (d0 == 0)
1488 {
1489 if (inextension)
1491 coF=
N (ppA*(cA/gcdcAcB));
1492 coG=
N (ppB*(cB/gcdcAcB));
1494 }
1495
1496 if (d0 > d)
1497 {
1498 if (!
find (
l, random_element))
1499 l.append (random_element);
1500 continue;
1501 }
1502
1503 G_random_element= (gcdlcAlcB(random_element,
x)/
uni_lcoeff(G_random_element))
1504 *G_random_element;
1505
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;
1510
1514 else
1515 d0= 0;
1516
1517 if (d0 < d)
1518 {
1520 newtonPoly= 1;
1521 G_m= 0;
1522 d= d0;
1523 coF_m= 0;
1524 coG_m= 0;
1525 }
1526
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: ");
1533
1534
1536 {
1538 if (gcdlcAlcB.
isOne())
1539 cH= 1;
1540 else
1554 {
1555 if (inextension)
1557 coF=
N ((cA/gcdcAcB)*ppCoF);
1558 coG=
N ((cB/gcdcAcB)*ppCoG);
1560 "time for successful termination Fp: ");
1561 return N(gcdcAcB*ppH);
1562 }
1564 "time for unsuccessful termination Fp: ");
1565 }
1566
1570 newtonPoly= newtonPoly*(
x - random_element);
1571 m=
m*(
x - random_element);
1572 if (!
find (
l, random_element))
1573 l.append (random_element);
1574 } while (1);
1575}
const CanonicalForm CFMap CFMap & N
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....
const CanonicalForm const CanonicalForm const CanonicalForm & coG
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)
static CanonicalForm uni_content(const CanonicalForm &F)
compute the content of F, where F is considered as an element of
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.
const CanonicalForm const CanonicalForm & coF
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)
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...
bool terminationTest(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &coF, const CanonicalForm &coG, const CanonicalForm &cand)
bool fdivides(const CanonicalForm &f, const CanonicalForm &g)
bool fdivides ( const CanonicalForm & f, const CanonicalForm & g )
#define ASSERT(expression, message)
CanonicalForm randomIrredpoly(int i, const Variable &x)
computes a random monic irreducible univariate polynomial in x over Fp of degree i via NTL/FLINT
CanonicalForm mapPrimElem(const CanonicalForm &primElem, const Variable &alpha, const Variable &beta)
compute the image of a primitive element of in . We assume .
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
#define DEBOUTLN(stream, objects)
template bool find(const List< CanonicalForm > &, const CanonicalForm &)
#define TIMING_END_AND_PRINT(t, msg)
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