304{
306
310
313
314
319 "time to compress poly in abs fact: ")
320
321
322 if (F.isUnivariate())
323 {
326 if (
result.getFirst().factor().inCoeffDomain())
329 }
330
331
333 {
337 }
338
341
345 int factorNums= 1;
346 CFAFList absBiFactors, absBufBiFactors;
348 int lift, bufLift, lengthAeval2=
A.level()-2;
351 int counter;
352 int differentSecondVar= 0;
354
355
359 for (
int i= 0;
i < factorNums;
i++)
360 {
361 counter= 0;
367 "time to find evaluation point in abs fact: ");
369 evalPoly= 0;
370
374 "time to eval wrt diff second vars in abs fact: ");
375
376 for (
int j= 0;
j < lengthAeval2;
j++)
377 {
378 if (!bufAeval2[
j].isEmpty())
379 counter++;
380 }
381
383
387 "time for bivariate factorization in abs fact: ");
388
389 if (absBufBiFactors.
length() == 1)
390 {
395 delete [] bufAeval2;
396 delete [] Aeval2;
397 return factors;
398 }
399
401 {
404 absBiFactors= absBufBiFactors;
406 for (
int j= 0;
j < lengthAeval2;
j++)
407 Aeval2 [
j]= bufAeval2 [
j];
408 differentSecondVar= counter;
409 }
410 else
411 {
415 counter > differentSecondVar)
416 {
419 absBiFactors= absBufBiFactors;
421 for (
int j= 0;
j < lengthAeval2;
j++)
422 Aeval2 [
j]= bufAeval2 [
j];
423 differentSecondVar= counter;
424 }
425 }
428 evalPoly +=
j.getItem()*
power (
x,
k);
430 }
431
432 delete [] bufAeval2;
433
436
440
442
445
449 "time for bivariate factorization wrt diff second vars in abs fact: ");
450
452 "total time for eval and bivar factors in abs fact: ");
454 {
459 delete [] Aeval2;
460 return factors;
461 }
462
468
470
472
474
476 {
481 delete [] Aeval2;
482 return factors;
483 }
484
486 if (differentSecondVar == lengthAeval2)
487 {
488 bool zeroOccured= false;
490 {
492 {
493 zeroOccured= true;
494 break;
495 }
496 }
497 if (!zeroOccured)
498 {
502 {
504 {
506 {
509 break;
510 }
511 }
512
515
518 delete [] Aeval2;
519 return factors;
520 }
521 else
522 rationalFactors=
CFList();
523
524 }
525 }
526
528 for (
int i= 0;
i < lengthAeval2;
i++)
529 oldAeval[
i]= Aeval2[
i];
530
532
535 biFactorsLCs.
append (
LC (
i.getItem(), 1));
536
541
545
547 CFList oldBiFactors= biFactors;
548
552
553 if (!LCmultiplierIsConst)
555 LCmultiplier);
556
557
561
563 CFList bufLeadingCoeffs2= leadingCoeffs2[lengthAeval2-1];
564 CFList bufBiFactors= biFactors;
567 if (!LCmultiplierIsConst)
568 {
570 for (
int i= 0;
i < lengthAeval2;
i++)
571 {
572 if (!oldAeval[
i].isEmpty())
574 }
575 }
577 "time to precompute LC in abs fact: ");
578
581 bool LCheuristic= false;
583 rationalFactors))
584 {
587 CFList oldFactors= rationalFactors;
589
591 {
593 {
596 }
597
599 {
601 {
604 break;
605 }
606 }
607
610
614 delete [] Aeval2;
616 "time for successful LucksWang in abs fact: ");
617 return factors;
618 }
619 else if (rationalFactors.
length() > 0)
620 {
621 int oneCount= 0;
624 {
626 {
628 for (
int j=1;
j <=
i-oneCount;
j++)
631 for (
int j= 0;
j < lengthAeval2;
j++)
632 {
633 l= leadingCoeffs2[
j];
635 for (
int k=1;
k <=
i-oneCount;
k++)
639 }
640 oneCount++;
641 }
642 }
643 bufFactors= rationalFactors;
644 rationalFactors=
CFList();
645 }
646 else if (!LCmultiplierIsConst && rationalFactors.
length() == 0)
647 {
648 LCheuristic= true;
649 rationalFactors= oldFactors;
651 bool foundTrueMultiplier= false;
652 LCHeuristic2 (LCmultiplier,rationalFactors,leadingCoeffs2[lengthAeval2-1],
653 contents, LCs, foundTrueMultiplier);
654 if (foundTrueMultiplier)
655 {
657 leadingCoeffs= leadingCoeffs2[lengthAeval2-1];
658 for (
int i= lengthAeval2-1;
i > -1;
i--)
662 }
663 else
664 {
665 bool foundMultiplier= false;
666 LCHeuristic3 (LCmultiplier, rationalFactors, oldBiFactors, contents,
667 oldAeval,
A,leadingCoeffs2, lengthAeval2, foundMultiplier);
668
669 if (foundMultiplier)
670 {
671 foundMultiplier= false;
672 LCHeuristic4 (oldBiFactors, oldAeval, contents, rationalFactors,
673 testVars, lengthAeval2, leadingCoeffs2,
A, LCmultiplier,
674 foundMultiplier);
675 }
676 else
677 {
679 leadingCoeffs2[lengthAeval2-1], foundMultiplier);
681 {
682 LCHeuristic (
A, LCmultiplier, biFactors, leadingCoeffs2, oldAeval,
684 }
685 }
686
687
688 leadingCoeffs= leadingCoeffs2[lengthAeval2-1];
689 for (
int i= lengthAeval2-1;
i > -1;
i--)
693 }
694 rationalFactors=
CFList();
695 if (!
fdivides (
LC (oldA,1),
prod (leadingCoeffs2[lengthAeval2-1])))
696 {
697 LCheuristic= false;
699 biFactors= bufBiFactors;
700 leadingCoeffs2[lengthAeval2-1]= bufLeadingCoeffs2;
701 LCmultiplier= bufLCmultiplier;
702 }
703 }
704 else
705 rationalFactors=
CFList();
707 }
709
711 if (!LCheuristic && !LCmultiplierIsConst && bufFactors.
isEmpty()
713 {
714 LCheuristic= true;
715 LCHeuristic (
A, LCmultiplier, biFactors, leadingCoeffs2, oldAeval,
717
718 leadingCoeffs= leadingCoeffs2[lengthAeval2-1];
719 for (
int i= lengthAeval2-1;
i > -1;
i--)
723
724 if (!
fdivides (
LC (oldA,1),
prod (leadingCoeffs2[lengthAeval2-1])))
725 {
726 LCheuristic= false;
728 biFactors= bufBiFactors;
729 leadingCoeffs2[lengthAeval2-1]= bufLeadingCoeffs2;
730 LCmultiplier= bufLCmultiplier;
731 }
732 }
734 "time for Lc heuristic in abs fact: ");
735
736tryAgainWithoutHeu:
737
743
746
747 for (
int i= 0;
i < lengthAeval2-1;
i++)
750 {
752 for (
int i=
A.level() - 4;
i > -1;
i--)
753 {
754 if (
i + 1 == lengthAeval2-1)
756 else
758 }
759 }
761 "time to shift evaluation point to zero in abs fact: ");
762
765 int* liftBounds=
new int [
A.level() - 1];
766 int liftBoundsLength=
A.level() - 1;
767 for (
int i= 0;
i < liftBoundsLength;
i++)
769
771 bool noOneToOne= false;
772
774 CFList commonDenominators;
779 for (
int i= 0;
i < lengthAeval2;
i++)
780 {
781 iter2= commonDenominators;
783 {
788 }
789 }
792 {
797 }
799 multiplier= tmp3/
tmp1;
800 iter2= commonDenominators;
803
806
807 for (
int i= 0;
i < lengthAeval2;
i++)
808 {
809 iter2= commonDenominators;
812 }
813
815 "time to clear denominators in abs fact: ");
816
819 Pi, liftBounds, liftBoundsLength, noOneToOne);
821 "time for non monic hensel lifting in abs fact: ");
822
823 if (!noOneToOne)
824 {
830 "time to recover factors in abs fact: ");
832 noOneToOne= true;
833 else
834 rationalFactors=
Union (rationalFactors, bufFactors);
835 }
836 if (noOneToOne)
837 {
838 if (!LCmultiplierIsConst && LCheuristic)
839 {
841 biFactors= bufBiFactors;
842 leadingCoeffs2[lengthAeval2-1]= bufLeadingCoeffs2;
843 delete [] liftBounds;
844 LCheuristic= false;
845 goto tryAgainWithoutHeu;
846
847 }
848
850 biFactors= oldBiFactors;
858
859 for (;
i.hasItem();
i++)
861
863
867 for (;
i.hasItem();
i++)
868 {
869 LCA=
LC (
i.getItem(), 1);
870 extgcd (LCA, yToLift, LCA, dummy);
871 i.getItem()=
mod (
i.getItem()*LCA, yToLift);
872 }
873
874 liftBoundsLength= F.
level() - 1;
876
878 bool earlySuccess;
884 (
A, MOD, liftBounds, earlySuccess, earlyFactors,
887 "time for hensel lifting in abs fact: ");
888
892 "time for factor recombination in abs fact: ");
893
894 if (earlySuccess)
895 rationalFactors=
Union (rationalFactors, earlyFactors);
896
898 {
901 {
902 if (
i.getItem().level() < kk)
903 continue;
904 i.getItem()=
i.getItem() (
Variable (kk) -
j.getItem(), kk);
905 }
906 }
907 }
908
910 {
913 }
914
916 {
918 {
921 break;
922 }
923 }
924
925
928
932
933 delete [] leadingCoeffs2;
934 delete [] oldAeval;
935 delete [] Aeval2;
936 delete[] liftBounds;
937
938 return factors;
939}
const CanonicalForm CFMap CFMap & N
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
CanonicalForm decompress(const CanonicalForm &F, const mpz_t *inverseM, const mpz_t *A)
decompress a bivariate poly
CanonicalForm extgcd(const CanonicalForm &f, const CanonicalForm &g, CanonicalForm &a, CanonicalForm &b)
CanonicalForm extgcd ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & a,...
bool fdivides(const CanonicalForm &f, const CanonicalForm &g)
bool fdivides ( const CanonicalForm & f, const CanonicalForm & g )
ExtensionInfo contains information about extension.
void remove(int moveright)
class to generate random evaluation points
factory's class for variables
CFAFList absBiFactorizeMain(const CanonicalForm &G, bool full)
main absolute factorization routine, expects bivariate poly which is irreducible over Q
CFAFList uniAbsFactorize(const CanonicalForm &F, bool full=false)
univariate absolute factorization over Q
const CanonicalForm int const CFList & evaluation
const CanonicalForm int const CFList const Variable & y
REvaluation E(1, terms.length(), IntRandom(25))
CFList evalPoints4AbsFact(const CanonicalForm &F, CFList &eval, Evaluation &E, int &intervalSize)
if(degree(Feval, x) >=8||degree(H, x) >=8) res
CFAFList RothsteinTrager(const CanonicalForm &F, const CFList &factors, const Variable &alpha, const CFList &evaluation)
Algorithm B.7.8 from Greuel, Pfister "A Singular Introduction to Commutative Algebra".
const Variable & v
< [in] a sqrfree bivariate poly
void factorizationWRTDifferentSecondVars(const CanonicalForm &A, CFList *&Aeval, int &minFactorsLength, bool &irred, const Variable &w)
CFList int & minFactorsLength
[in,out] minimal length of bivariate factors
CFList *& Aeval
<[in] poly
CFList int bool & irred
[in,out] Is A irreducible?
CFList henselLiftAndEarly(CanonicalForm &A, bool &earlySuccess, CFList &earlyFactors, DegreePattern °s, int &liftBound, const CFList &uniFactors, const ExtensionInfo &info, const CanonicalForm &eval, modpk &b, CanonicalForm &den)
hensel Lifting and early factor detection
CFList factorRecombination(CFList &factors, CanonicalForm &F, const CanonicalForm &N, DegreePattern °s, const CanonicalForm &eval, int s, int thres, const modpk &b, const CanonicalForm &den)
naive factor recombination as decribed in "Factoring multivariate polynomials over a finite field" by...
CFList recoverFactors(const CanonicalForm &F, const CFList &factors)
divides factors by their content wrt. Variable(1) and checks if these polys divide F
CanonicalForm shift2Zero(const CanonicalForm &F, CFList &Feval, const CFList &evaluation, int l)
shift evaluation point to zero
int * liftingBounds(const CanonicalForm &A, const int &bivarLiftBound)
compute lifting bounds
CFList precomputeLeadingCoeff(const CanonicalForm &LCF, const CFList &LCFFactors, const Variable &alpha, const CFList &evaluation, CFList *&differentSecondVarLCs, int lSecondVarLCs, Variable &y)
computes a list l of length length(LCFFactors)+1 of polynomials such that prod (l)=LCF,...
void LCHeuristicCheck(const CFList &LCs, const CFList &contents, CanonicalForm &A, const CanonicalForm &oldA, CFList &leadingCoeffs, bool &foundTrueMultiplier)
checks if prod(LCs)==LC (oldA,1) and if so divides elements of leadingCoeffs by elements in contents,...
void distributeLCmultiplier(CanonicalForm &A, CFList &leadingCoeffs, CFList &biFactors, const CFList &evaluation, const CanonicalForm &LCmultipler)
distributes a divisor LCmultiplier of LC(A,1) on the bivariate factors and the precomputed leading co...
void evaluationWRTDifferentSecondVars(CFList *&Aeval, const CFList &evaluation, const CanonicalForm &A)
evaluate a poly A with main variable at level 1 at an evaluation point in K^(n-1) wrt different secon...
void prepareLeadingCoeffs(CFList *&LCs, CanonicalForm &A, CFList &Aeval, int n, const CFList &leadingCoeffs, const CFList &biFactors, const CFList &evaluation)
normalize precomputed leading coefficients such that leading coefficients evaluated at evaluation in ...
void LCHeuristic4(const CFList &oldBiFactors, const CFList *oldAeval, const CFList &contents, const CFList &factors, const CanonicalForm &testVars, int lengthAeval, CFList *&leadingCoeffs, CanonicalForm &A, CanonicalForm &LCmultiplier, bool &foundMultiplier)
heuristic to remove factors of LCmultiplier from factors. More precisely checks if elements of conten...
void changeSecondVariable(CanonicalForm &A, CFList &biFactors, CFList &evaluation, CFList *&oldAeval, int lengthAeval2, const CFList &uniFactors, const Variable &w)
changes the second variable to be w and updates all relevant data
void sortByUniFactors(CFList *&Aeval, int AevalLength, CFList &uniFactors, CFList &biFactors, const CFList &evaluation)
sort bivariate factors in Aeval such that their corresponding univariate factors coincide with uniFac...
void getLeadingCoeffs(const CanonicalForm &A, CFList *&Aeval)
extract leading coefficients wrt Variable(1) from bivariate factors obtained from factorizations of A...
void LCHeuristic3(const CanonicalForm &LCmultiplier, const CFList &factors, const CFList &oldBiFactors, const CFList &contents, const CFList *oldAeval, CanonicalForm &A, CFList *&leadingCoeffs, int lengthAeval, bool &foundMultiplier)
heuristic to remove LCmultiplier from a factor based on the contents of factors. factors are assumed ...
void LCHeuristic(CanonicalForm &A, const CanonicalForm &LCmultiplier, CFList &biFactors, CFList *&leadingCoeffs, const CFList *oldAeval, int lengthAeval, const CFList &evaluation, const CFList &oldBiFactors)
heuristic to distribute LCmultiplier onto factors based on the variables that occur in LCmultiplier a...
void refineBiFactors(const CanonicalForm &A, CFList &biFactors, CFList *const &Aeval, const CFList &evaluation, int minFactorsLength)
refine a bivariate factorization of A with l factors to one with minFactorsLength if possible
void LCHeuristic2(const CanonicalForm &LCmultiplier, const CFList &factors, CFList &leadingCoeffs, CFList &contents, CFList &LCs, bool &foundTrueMultiplier)
heuristic to distribute LCmultiplier onto factors based on the contents of factors....
CFList buildUniFactors(const CFList &biFactors, const CanonicalForm &evalPoint, const Variable &y)
plug in evalPoint for y in a list of polys
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)
void sortList(CFList &list, const Variable &x)
sort a list of polynomials by their degree in x.
int LucksWangSparseHeuristic(const CanonicalForm &F, const CFList &factors, int level, const CFList &leadingCoeffs, CFList &result)
sparse heuristic lifting by Wang and Lucks
CFList sparseHeuristic(const CanonicalForm &A, const CFList &biFactors, CFList *&moreBiFactors, const CFList &evaluation, int minFactorsLength)
sparse heuristic which patches together bivariate factors of A wrt. different second variables by the...
template CanonicalForm tmax(const CanonicalForm &, const CanonicalForm &)
template CanonicalForm tmin(const CanonicalForm &, const CanonicalForm &)
ideal lift(const ideal J, const ring r, const ideal inI, const ring s)
int lcm(unsigned long *l, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
static int index(p_Length length, p_Ord ord)
#define TIMING_END_AND_PRINT(t, msg)
CanonicalForm getMipo(const Variable &alpha, const Variable &x)