412{
413 if (
f.inCoeffDomain() )
415#ifndef NOASSERT
418 ( const CanonicalForm & f, const Variable & alpha ) instead");
419#endif
420
421 if (!
f.isUnivariate() )
422 {
424 {
433 for (
j=Intermediatelist;
j.hasItem();
j++ )
434 {
436 CFFactor( n(
j.getItem().factor()),
j.getItem().exp()) );
437 }
440 for (
j=Homoglist;
j.hasItem();
j++ )
441 {
444 d_xn -= (
degree(unhomogelem,
xn)*
j.getItem().exp());
445 }
446 if ( d_xn != 0 )
449 return Unhomoglist;
450 }
451 }
454 {
455 if (
f.isUnivariate())
456 {
457#ifdef HAVE_FLINT
458#ifdef HAVE_NTL
460#endif
461 {
462
463 nmod_poly_t f1;
465 nmod_poly_factor_t
result;
466 nmod_poly_factor_init (
result);
467 mp_limb_t leadingCoeff= nmod_poly_factor (
result, f1);
469 nmod_poly_factor_clear (
result);
472 return F;
473 }
474#endif
475#ifdef HAVE_NTL
476 {
478 {
479
481 {
483 zz_p::init(2);
484 }
485
487
488
489 vec_pair_GF2X_long factors;
490 CanZass(factors,f1);
491
492
495 return F;
496 }
497 }
498#endif
499#ifdef HAVE_NTL
500 {
501
503 {
506 }
507
508
510 zz_p leadcoeff = LeadCoeff(f1);
511
512
513 f1=f1 / LeadCoeff(f1);
514
515 vec_pair_zz_pX_long factors;
516 CanZass(factors,f1);
517
519
521 return F;
522 }
523#endif
524#if !defined(HAVE_NTL) && !defined(HAVE_FLINT)
525
526 {
529 else
531 return F;
532 }
533#endif
534 }
535 else
536 {
538 {
539 #if defined(HAVE_NTL)
540 if (issqrfree)
541 {
547 }
548 else
549 {
552 }
553 #else
554 factoryError (
"multivariate factorization over GF depends on NTL(missing)");
556 #endif
557 }
558 else
559 {
560 #if defined(HAVE_FLINT) && (__FLINT_RELEASE >= 20700) && defined(HAVE_NTL)
562 {
563 #endif
564 #if defined(HAVE_NTL)
565 if (issqrfree)
566 {
572 goto end_charp;
573 }
574 else
575 {
578 goto end_charp;
579 }
580 #endif
581 #if defined(HAVE_FLINT) && (__FLINT_RELEASE >= 20700) && defined(HAVE_NTL)
582 }
583 #endif
584 #if defined(HAVE_FLINT) && (__FLINT_RELEASE >= 20700)
585 nmod_mpoly_ctx_t ctx;
587 nmod_mpoly_t Flint_f;
588 nmod_mpoly_init(Flint_f,ctx);
589 convFactoryPFlintMP(
f,Flint_f,ctx,
f.level());
590 nmod_mpoly_factor_t factors;
591 nmod_mpoly_factor_init(factors,ctx);
592 int okay;
593 if (issqrfree) okay=nmod_mpoly_factor_squarefree(factors,Flint_f,ctx);
594 else okay=nmod_mpoly_factor(factors,Flint_f,ctx);
595 nmod_mpoly_t fac;
596 nmod_mpoly_init(fac,ctx);
598 int cf_exp;
599 cf_fac=nmod_mpoly_factor_get_constant_ui(factors,ctx);
601 for(
int i=nmod_mpoly_factor_length(factors,ctx)-1;
i>=0;
i--)
602 {
603 nmod_mpoly_factor_get_base(fac,factors,
i,ctx);
604 cf_fac=convFlintMPFactoryP(fac,ctx,
f.level());
605 cf_exp=nmod_mpoly_factor_get_exp_si(factors,
i,ctx);
607 }
608 nmod_mpoly_factor_clear(factors,ctx);
609 nmod_mpoly_clear(Flint_f,ctx);
610 nmod_mpoly_ctx_clear(ctx);
611 if (okay==0)
612 {
618 }
619 #endif
620 #if !defined(HAVE_FLINT) || (__FLINT_RELEASE < 20700)
621 #ifndef HAVE_NTL
622 factoryError (
"multivariate factorization depends on NTL/FLINT(missing)");
624 #endif
625 #endif
626 }
627 }
628 }
629 else
630 {
636 if (
f.isUnivariate() )
637 {
639 fz/=ic;
641 {
644 }
645 else
646 #if defined(HAVE_FLINT) && (__FLINT_RELEASE>=20503) && (__FLINT_RELEASE!= 20600)
647 {
648
649
650
651 fmpz_poly_t f1;
653 fmpz_poly_factor_t
result;
654 fmpz_poly_factor_init (
result);
655 fmpz_poly_factor(
result, f1);
657 fmpz_poly_factor_clear (
result);
658 fmpz_poly_clear (f1);
660 {
661
662
666 }
667 }
668 goto end_char0;
669 #elif defined(HAVE_NTL)
670 {
671
672 ZZ c;
673 vec_pair_ZZX_long factors;
674
676
677
680 {
681
682
686 }
687 }
688 goto end_char0;
689 #else
690 {
691
693 goto end_char0;
694 }
695 #endif
696 }
697 else
698 {
699 #if defined(HAVE_FLINT) && (__FLINT_RELEASE >= 20700)
701 {
703 fmpz_mpoly_ctx_t ctx;
704 fmpz_mpoly_ctx_init(ctx,
f.level(),ORD_LEX);
705 fmpz_mpoly_t Flint_f;
706 fmpz_mpoly_init(Flint_f,ctx);
707 convFactoryPFlintMP(fz,Flint_f,ctx,fz.
level());
708 fmpz_mpoly_factor_t factors;
709 fmpz_mpoly_factor_init(factors,ctx);
710 int rr;
711 if (issqrfree) rr=fmpz_mpoly_factor_squarefree(factors,Flint_f,ctx);
712 else rr=fmpz_mpoly_factor(factors,Flint_f,ctx);
713 if (rr==0) printf("fail\n");
714 fmpz_mpoly_t fac;
715 fmpz_mpoly_init(fac,ctx);
717 int cf_exp;
718 fmpz_t c;
719 fmpz_init(c);
720 fmpz_mpoly_factor_get_constant_fmpz(c,factors,ctx);
722 fmpz_clear(c);
724 for(
int i=fmpz_mpoly_factor_length(factors,ctx)-1;
i>=0;
i--)
725 {
726 fmpz_mpoly_factor_get_base(fac,factors,
i,ctx);
727 cf_fac=convFlintMPFactoryP(fac,ctx,
f.level());
728 cf_exp=fmpz_mpoly_factor_get_exp_si(factors,
i,ctx);
730 }
731 fmpz_mpoly_factor_clear(factors,ctx);
732 fmpz_mpoly_clear(Flint_f,ctx);
733 fmpz_mpoly_ctx_clear(ctx);
734 goto end_char0;
735 }
736 #endif
737 #if defined(HAVE_NTL)
739 if (issqrfree)
740 {
744 }
745 else
746 {
748 }
749 #endif
750 #if !defined(HAVE_FLINT) || (__FLINT_RELEASE < 20700)
751 #ifndef HAVE_NTL
753 #endif
754 #endif
755 }
756
757end_char0:
758 if ( on_rational )
760 else
763 {
767 }
768 }
769
770#if defined(HAVE_NTL)
771end_charp:
772#endif
774 return F;
775}
CanonicalForm convertFmpz2CF(const fmpz_t coefficient)
conversion of a FLINT integer to CanonicalForm
CFFList convertFLINTnmod_poly_factor2FacCFFList(const nmod_poly_factor_t fac, const mp_limb_t leadingCoeff, const Variable &x)
conversion of a FLINT factorization over Z/p (for word size p) to a CFFList
void convertFacCF2Fmpz_poly_t(fmpz_poly_t result, const CanonicalForm &f)
conversion of a factory univariate polynomial over Z to a fmpz_poly_t
CFFList convertFLINTfmpz_poly_factor2FacCFFList(const fmpz_poly_factor_t fac, const Variable &x)
conversion of a FLINT factorization over Z to a CFFList
CFFList convertNTLvec_pair_GF2X_long2FacCFFList(const vec_pair_GF2X_long &e, GF2, const Variable &x)
NAME: convertNTLvec_pair_GF2X_long2FacCFFList.
ZZX convertFacCF2NTLZZX(const CanonicalForm &f)
CFFList convertNTLvec_pair_zzpX_long2FacCFFList(const vec_pair_zz_pX_long &e, const zz_p cont, const Variable &x)
zz_pX convertFacCF2NTLzzpX(const CanonicalForm &f)
GF2X convertFacCF2NTLGF2X(const CanonicalForm &f)
NAME: convertFacCF2NTLGF2X.
CFFList convertNTLvec_pair_ZZX_long2FacCFFList(const vec_pair_ZZX_long &e, const ZZ &cont, const Variable &x)
NAME: convertNTLvec_pair_ZZX_long2FacCFFList.
CanonicalForm cd(bCommonDen(FF))
CanonicalForm bCommonDen(const CanonicalForm &f)
void psqr ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & q, CanonicalForm & r,...
EXTERN_VAR int singular_homog_flag
#define ASSERT(expression, message)
static const int SW_USE_FL_GCD_P
set to 1 to use Flints gcd over F_p
static const int SW_RATIONAL
set to 1 for computations over Q
static const int SW_USE_NTL_SORT
set to 1 to sort factors in a factorization
static const int SW_USE_FL_FAC_0
set to 1 to prefer flints multivariate factorization over Z/p
static const int SW_USE_FL_FAC_P
set to 1 to prefer flints multivariate factorization over Z/p
static const int SW_BERLEKAMP
set to 1 to use Factorys Berlekamp alg.
#define GaloisFieldDomain
Variable get_max_degree_Variable(const CanonicalForm &f)
get_max_degree_Variable returns Variable with highest degree.
int cmpCF(const CFFactor &f, const CFFactor &g)
CanonicalForm homogenize(const CanonicalForm &f, const Variable &x)
homogenize homogenizes f with Variable x
CFFList factorize(const CanonicalForm &f, bool issqrfree)
factorization over or
CanonicalForm compress(const CanonicalForm &f, CFMap &m)
CanonicalForm compress ( const CanonicalForm & f, CFMap & m ).
VAR void(* factoryError)(const char *s)
void sort(int(*)(const T &, const T &))
factory's class for variables
CFFList ratFactorize(const CanonicalForm &G, const Variable &v=Variable(1), bool substCheck=true)
factorize a multivariate polynomial over
CFList ratSqrfFactorize(const CanonicalForm &G, const Variable &v=Variable(1))
factorize a squarefree multivariate polynomial over
CFList FpSqrfFactorize(const CanonicalForm &F)
factorize a squarefree multivariate polynomial over
CFFList FpFactorize(const CanonicalForm &G, bool substCheck=true)
factorize a multivariate polynomial over
CFFList GFFactorize(const CanonicalForm &G, bool substCheck=true)
factorize a multivariate polynomial over GF
CFList GFSqrfFactorize(const CanonicalForm &F)
factorize a squarefree multivariate polynomial over GF
convertFacCF2nmod_poly_t(FLINTmipo, M)
nmod_poly_clear(FLINTmipo)
CFFList FpFactorizeUnivariateB(const CanonicalForm &f, bool issqrfree=false)
CFFList FpFactorizeUnivariateCZ(const CanonicalForm &f, bool issqrfree, int numext, const Variable alpha, const Variable beta)
CFFList ZFactorizeMultivariate(const CanonicalForm &f, bool issqrfree)
CFFList ZFactorizeUnivariate(const CanonicalForm &ff, bool issqrfree=false)