main absolute factorization routine, expects bivariate poly which is irreducible over Q
212{
218
219 mpz_t *
M=
new mpz_t [4];
224
225 mpz_t * S=new mpz_t [2];
226 mpz_init (S[0]);
227 mpz_init (S[1]);
228
230
232 {
234 {
240
241 mpz_clear (S[0]);
242 mpz_clear (S[1]);
243 delete [] S;
244 if (!isRat)
247 }
249 if (
result.getFirst().factor().inCoeffDomain())
259
260 mpz_clear (S[0]);
261 mpz_clear (S[1]);
262 delete [] S;
263 if (!isRat)
266 }
267
269 {
275
276 mpz_clear (S[0]);
277 mpz_clear (S[1]);
278 delete [] S;
279 if (!isRat)
282 }
288 bool rec= false;
295differentevalpoint:
296 while (1)
297 {
301
302
306
307 if (factors.
getFirst().factor().inCoeffDomain())
309
311 {
313 {
314 if (isRat)
322
323 mpz_clear (S[0]);
324 mpz_clear (S[1]);
325 delete [] S;
327 }
328 else
329 {
332 {
333 if (isRat)
340
341 mpz_clear (S[0]);
342 mpz_clear (S[1]);
343 delete [] S;
345 }
346 rec= true;
347 continue;
348 }
349 }
353 {
356 break;
358 }
359
364 {
367 {
370 }
371 }
372 if (tdegF % minTdeg == 0)
373 break;
375 rec=true;
376 }
379
384
386 !
gcd (Gpx, smallestFactorEvalx).inCoeffDomain());
388 !
gcd (Gpy, smallestFactorEvaly).inCoeffDomain());
389 if (!xValid || !yValid)
390 {
391 rec= true;
393 goto differentevalpoint;
394 }
395
397
399
402 for (
int i= 1;
i < 3;
i++)
403 {
405
406 int s= tdegF/minTdeg + 1;
410
416 }
417
418
420#ifdef HAVE_FLINT
421 fmpz_poly_t FLINTFi;
424 nmod_poly_t FLINTFpi, FLINTGpi;
426 {
428 smallestFactorEvalx/
lc (smallestFactorEvalx));
430 }
431 else
432 {
434 smallestFactorEvaly/
lc (smallestFactorEvaly));
436 }
437 nmod_poly_factor_t nmodFactors;
438 nmod_poly_factor_init (nmodFactors);
439 nmod_poly_factor_insert (nmodFactors, FLINTFpi, 1L);
440 nmod_poly_factor_insert (nmodFactors, FLINTGpi, 1L);
441
442
443# ifndef slong
444# define slong long
445# endif
446
448 fmpz_poly_t *
v=
new fmpz_poly_t[2];
449 fmpz_poly_t *
w=
new fmpz_poly_t[2];
450 fmpz_poly_init(
v[0]);
451 fmpz_poly_init(
v[1]);
452 fmpz_poly_init(
w[0]);
453 fmpz_poly_init(
w[1]);
454
455 fmpz_poly_factor_t liftedFactors;
456 fmpz_poly_factor_init (liftedFactors);
457 _fmpz_poly_hensel_start_lift (liftedFactors, link,
v,
w, FLINTFi,
459
460 nmod_poly_factor_clear (nmodFactors);
463
467
471#elif defined(HAVE_NTL)
475
477 {
480 }
481 zz_pX NTLFpi, NTLGpi;
483 {
486 }
487 else
488 {
491 }
492 vec_zz_pX modFactors;
493 modFactors.SetLength(2);
494 modFactors[0]= NTLFpi;
495 modFactors[1]= NTLGpi;
496 vec_ZZX liftedFactors;
497 MultiLift (liftedFactors, modFactors, NTLFi, (
long)
k);
501
504#else
506#endif
507
509 liftedSmallestFactor= pk (liftedSmallestFactor);
511 liftedSmallestFactor= liftedSmallestFactor (
eval[0],1);
512 else
513 liftedSmallestFactor= liftedSmallestFactor (
eval[1],1);
514
518 for (
int j= 1;
j <
s;
j++)
519 {
521 (*M) (
j+1,
j)= -liftedSmallestFactor;
522 }
523
524 #ifdef HAVE_FLINT
525 fmpz_mat_t FLINTM;
528 fmpq_init(delta); fmpq_set_si(delta,1,1);
529 fmpq_init(eta); fmpq_set_si(eta,3,4);
530 fmpz_mat_transpose(FLINTM,FLINTM);
531 fmpz_mat_lll_storjohann(FLINTM,delta,eta);
532 fmpz_mat_transpose(FLINTM,FLINTM);
535 fmpz_mat_clear(FLINTM);
536 #elif defined(HAVE_NTL)
538
539 ZZ det;
540
541 transpose (*NTLM, *NTLM);
542 (void) LLL (det, *NTLM, 1L, 1L);
543 transpose (*NTLM, *NTLM);
546 delete NTLM;
547 #else
549 #endif
550
552 for (
int j= 1;
j <=
s;
j++)
554
557 if (mipoFactors.
getFirst().factor().inCoeffDomain())
559
560#ifdef HAVE_FLINT
561 fmpz_poly_clear (
v[0]);
562 fmpz_poly_clear (
v[1]);
563 fmpz_poly_clear (
w[0]);
564 fmpz_poly_clear (
w[1]);
567 delete [] link;
568 fmpz_poly_factor_clear (liftedFactors);
569#endif
570
571 if (mipoFactors.
length() > 1 ||
572 (mipoFactors.
length() == 1 && mipoFactors.
getFirst().exp() > 1) ||
574 {
575 rec=true;
576 goto differentevalpoint;
577 }
578 else
580 }
581
583 {
584 rec=true;
585 goto differentevalpoint;
586 }
587
591 else
593
594 int wrongMipo= 0;
595
598 {
600 if (mipoFactors.
getFirst().factor().inCoeffDomain())
603 {
605 wrongMipo++;
606 }
607 if (wrongMipo == mipoFactors.
length())
608 {
609 rec=true;
610 goto differentevalpoint;
611 }
612 wrongMipo= 0;
615 if (mipoFactors.
getFirst().factor().inCoeffDomain())
618 {
620 wrongMipo++;
621 }
622 if (wrongMipo == mipoFactors.
length())
623 {
624 rec=true;
625 goto differentevalpoint;
626 }
627 }
628 else
629 {
631 if (mipoFactors.
getFirst().factor().inCoeffDomain())
634 {
636 wrongMipo++;
637 }
638 if (wrongMipo == mipoFactors.
length())
639 {
640 rec=true;
641 goto differentevalpoint;
642 }
643 wrongMipo= 0;
646 if (mipoFactors.
getFirst().factor().inCoeffDomain())
649 {
651 wrongMipo++;
652 }
653 if (wrongMipo == mipoFactors.
length())
654 {
655 rec=true;
656 goto differentevalpoint;
657 }
658 }
659
660
662 if (
degree (F,1) > minTdeg)
664 else
666
670 {
674 }
675
676 wrongMipo= 0;
678 if (QaF1Factors.
getFirst().factor().inCoeffDomain())
681 {
683 wrongMipo++;
684 }
685
686 if (wrongMipo == QaF1Factors.
length())
687 {
688 rec= true;
689 F= bufF;
690 goto differentevalpoint;
691 }
692
696 else
698
701
702 int liftBound=
degree (F,
y) + 1;
703
705
707
709
713
715 #ifdef HAVE_FLINT
716
717 fmpz_t FLINTf,FLINTD;
718 fmpz_init(FLINTf);
719 fmpz_init(FLINTD);
720 fmpz_poly_t FLINTmipo;
721 fmpz_poly_t FLINTLcf;
722
725
726 fmpz_poly_resultant(FLINTf,FLINTmipo,FLINTLcf);
727 fmpz_poly_discriminant(FLINTD,FLINTmipo);
728 fmpz_mul(FLINTf,FLINTD,FLINTf);
730
731 fmpz_clear(FLINTf);
732
733 fmpz_poly_clear(FLINTLcf);
734 fmpz_poly_clear(FLINTmipo);
735 #elif defined(HAVE_NTL)
739 ZZ NTLD= discriminant (NTLmipo);
741 #else
743 #endif
744
745
748 {
751 }
752 F *= multiplier;
754
756 int ii= 0;
757 #ifdef HAVE_FLINT
759 fmpz_clear(FLINTD);
760 #elif defined(HAVE_NTL)
762 #endif
766
770 if (bb.
getk() >
b.getk() )
b=bb;
772 if (bb.
getk() >
b.getk() )
b=bb;
773
776
777 bool earlySuccess= false;
780 (F, earlySuccess, earlyFactors, degs, liftBound,
782
783 DEBOUTLN (cerr,
"lifted factors= " << uniFactors);
784
786
790
792
795
797
798 if (earlySuccess)
799 biFactors=
Union (earlyFactors, biFactors);
800 else if (!earlySuccess && degs.
getLength() == 1)
801 biFactors= earlyFactors;
802
803 bool swap2= false;
807
810
812 {
816
818 {
823
825 break;
826 }
827 }
828
830 {
831 rec= true;
832 F= bufF;
833 goto differentevalpoint;
834 }
835
836 if (isRat)
838 else
840
846
847 mpz_clear (S[0]);
848 mpz_clear (S[1]);
849 delete [] S;
850
852}
void convertFacCFMatrix2Fmpz_mat_t(fmpz_mat_t M, const CFMatrix &m)
conversion of a factory matrix over Z to a fmpz_mat_t
CFMatrix * convertFmpz_mat_t2FacCFMatrix(const fmpz_mat_t m)
conversion of a FLINT matrix over Z to a factory matrix
CanonicalForm convertFmpz2CF(const fmpz_t coefficient)
conversion of a FLINT integer to CanonicalForm
CanonicalForm convertFmpz_poly_t2FacCF(const fmpz_poly_t poly, const Variable &x)
conversion of a FLINT poly over Z to CanonicalForm
void convertFacCF2Fmpz_poly_t(fmpz_poly_t result, const CanonicalForm &f)
conversion of a factory univariate polynomial over Z to a fmpz_poly_t
Rational abs(const Rational &a)
CanonicalForm convertZZ2CF(const ZZ &a)
NAME: convertZZ2CF.
ZZX convertFacCF2NTLZZX(const CanonicalForm &f)
CanonicalForm convertNTLZZX2CF(const ZZX &polynom, const Variable &x)
zz_pX convertFacCF2NTLzzpX(const CanonicalForm &f)
mat_ZZ * convertFacCFMatrix2NTLmat_ZZ(const CFMatrix &m)
CFMatrix * convertNTLmat_ZZ2FacCFMatrix(const mat_ZZ &m)
bool modularIrredTestWithShift(const CanonicalForm &F)
modular absolute irreducibility test with shift as described in "Modular Las Vegas Algorithms for Pol...
bool absIrredTest(const CanonicalForm &F)
absolute irreducibility test as described in "Modular Las Vegas Algorithms for Polynomial Absolute Fa...
CanonicalForm decompress(const CanonicalForm &F, const mpz_t *inverseM, const mpz_t *A)
decompress a bivariate poly
CanonicalForm bCommonDen(const CanonicalForm &f)
CanonicalForm bCommonDen ( const CanonicalForm & f )
CanonicalForm maxNorm(const CanonicalForm &f)
CanonicalForm maxNorm ( const CanonicalForm & f )
CFFList FACTORY_PUBLIC factorize(const CanonicalForm &f, bool issqrfree=false)
factorization over or
CanonicalForm FACTORY_PUBLIC resultant(const CanonicalForm &f, const CanonicalForm &g, const Variable &x)
CanonicalForm resultant ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x )
static const int SW_RATIONAL
set to 1 for computations over Q
static const int SW_SYMMETRIC_FF
set to 1 for symmetric representation over F_q
static CanonicalForm bound(const CFMatrix &M)
CanonicalForm compress(const CanonicalForm &f, CFMap &m)
CanonicalForm compress ( const CanonicalForm & f, CFMap & m )
int cf_getBigPrime(int i)
VAR void(* factoryError)(const char *s)
DegreePattern provides a functionality to create, intersect and refine degree patterns.
int getLength() const
getter
ExtensionInfo contains information about extension.
factory's class for variables
class to do operations mod p^k for int's p and k
CanonicalForm inverse(const CanonicalForm &f, bool symmetric=true) const
#define DEBOUTLN(stream, objects)
int choosePoint(const CanonicalForm &F, int tdegF, CFArray &eval, bool rec, int absValue)
CFAFList uniAbsFactorize(const CanonicalForm &F, bool full=false)
univariate absolute factorization over Q
const CanonicalForm int const CFList & evaluation
const CanonicalForm int s
const CanonicalForm int const CFList const Variable & y
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)
void findGoodPrime(const CanonicalForm &f, int &start)
find a big prime p from our tables such that no term of f vanishes mod p
const Variable & v
< [in] a sqrfree bivariate poly
void appendSwapDecompress(CFList &factors1, const CFList &factors2, const CFList &factors3, const bool swap1, const bool swap2, const CFMap &N)
first swap Variables in factors1 if necessary, then append factors2 and factors3 on factors1 and fina...
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...
convertFacCF2nmod_poly_t(FLINTmipo, M)
nmod_poly_clear(FLINTmipo)
template List< Variable > Union(const List< Variable > &, const List< Variable > &)
bool delta(X x, Y y, D d)
static poly normalize(poly next_p, ideal add_generators, syStrategy syzstr, int *g_l, int *p_l, int crit_comp)
int F1(int a1, int &r1)
F1.
#define TIMING_END_AND_PRINT(t, msg)
CanonicalForm getMipo(const Variable &alpha, const Variable &x)
Variable rootOf(const CanonicalForm &mipo, char name)
returns a symbolic root of polynomial with name name Use it to define algebraic variables