410{
411 if (
f.inCoeffDomain() )
413#ifndef NOASSERT
416 ( const CanonicalForm & f, const Variable & alpha ) instead");
417#endif
418
419 if (!
f.isUnivariate() )
420 {
422 {
431 for (
j=Intermediatelist;
j.hasItem();
j++ )
432 {
434 CFFactor( n(
j.getItem().factor()),
j.getItem().exp()) );
435 }
438 for (
j=Homoglist;
j.hasItem();
j++ )
439 {
442 d_xn -= (
degree(unhomogelem,
xn)*
j.getItem().exp());
443 }
444 if ( d_xn != 0 )
447 return Unhomoglist;
448 }
449 }
452 {
453 if (
f.isUnivariate())
454 {
455#ifdef HAVE_FLINT
456#ifdef HAVE_NTL
458#endif
459 {
460
461 nmod_poly_t f1;
463 nmod_poly_factor_t
result;
464 nmod_poly_factor_init (
result);
465 mp_limb_t leadingCoeff= nmod_poly_factor (
result, f1);
467 nmod_poly_factor_clear (
result);
470 return F;
471 }
472#endif
473#ifdef HAVE_NTL
474 {
476 {
477
479 {
481 zz_p::init(2);
482 }
483
485
486
487 vec_pair_GF2X_long factors;
488 CanZass(factors,f1);
489
490
493 return F;
494 }
495 }
496#endif
497#ifdef HAVE_NTL
498 {
499
501 {
504 }
505
506
508 zz_p leadcoeff = LeadCoeff(f1);
509
510
511 f1=f1 / LeadCoeff(f1);
512
513 vec_pair_zz_pX_long factors;
514 CanZass(factors,f1);
515
517
519 return F;
520 }
521#endif
522#if !defined(HAVE_NTL) && !defined(HAVE_FLINT)
523
524 {
527 else
529 return F;
530 }
531#endif
532 }
533 else
534 {
536 {
537 #if defined(HAVE_NTL)
538 if (issqrfree)
539 {
545 }
546 else
547 {
550 }
551 #else
552 factoryError (
"multivariate factorization over GF depends on NTL(missing)");
554 #endif
555 }
556 else
557 {
558 #if defined(HAVE_FLINT) && (__FLINT_RELEASE >= 20700) && defined(HAVE_NTL)
560 {
561 #endif
562 #if defined(HAVE_NTL)
563 if (issqrfree)
564 {
570 goto end_charp;
571 }
572 else
573 {
576 goto end_charp;
577 }
578 #endif
579 #if defined(HAVE_FLINT) && (__FLINT_RELEASE >= 20700) && defined(HAVE_NTL)
580 }
581 #endif
582 #if defined(HAVE_FLINT) && (__FLINT_RELEASE >= 20700)
583 nmod_mpoly_ctx_t ctx;
585 nmod_mpoly_t Flint_f;
586 nmod_mpoly_init(Flint_f,ctx);
587 convFactoryPFlintMP(
f,Flint_f,ctx,
f.level());
588 nmod_mpoly_factor_t factors;
589 nmod_mpoly_factor_init(factors,ctx);
590 int okay;
591 if (issqrfree) okay=nmod_mpoly_factor_squarefree(factors,Flint_f,ctx);
592 else okay=nmod_mpoly_factor(factors,Flint_f,ctx);
593 nmod_mpoly_t fac;
594 nmod_mpoly_init(fac,ctx);
596 int cf_exp;
597 cf_fac=nmod_mpoly_factor_get_constant_ui(factors,ctx);
599 for(
int i=nmod_mpoly_factor_length(factors,ctx)-1;
i>=0;
i--)
600 {
601 nmod_mpoly_factor_get_base(fac,factors,
i,ctx);
602 cf_fac=convFlintMPFactoryP(fac,ctx,
f.level());
603 cf_exp=nmod_mpoly_factor_get_exp_si(factors,
i,ctx);
605 }
606 nmod_mpoly_factor_clear(factors,ctx);
607 nmod_mpoly_clear(Flint_f,ctx);
608 nmod_mpoly_ctx_clear(ctx);
609 if (okay==0)
610 {
616 }
617 #endif
618 #if !defined(HAVE_FLINT) || (__FLINT_RELEASE < 20700)
619 #ifndef HAVE_NTL
620 factoryError (
"multivariate factorization depends on NTL/FLINT(missing)");
622 #endif
623 #endif
624 }
625 }
626 }
627 else
628 {
634 if (
f.isUnivariate() )
635 {
637 fz/=ic;
639 {
642 }
643 else
644 #if defined(HAVE_FLINT) && (__FLINT_RELEASE>=20503) && (__FLINT_RELEASE!= 20600)
645 {
646
647
648
649 fmpz_poly_t f1;
651 fmpz_poly_factor_t
result;
652 fmpz_poly_factor_init (
result);
653 fmpz_poly_factor(
result, f1);
655 fmpz_poly_factor_clear (
result);
656 fmpz_poly_clear (f1);
658 {
659
660
664 }
665 }
666 goto end_char0;
667 #elif defined(HAVE_NTL)
668 {
669
670 ZZ c;
671 vec_pair_ZZX_long factors;
672
674
675
678 {
679
680
684 }
685 }
686 goto end_char0;
687 #else
688 {
689
691 goto end_char0;
692 }
693 #endif
694 }
695 else
696 {
697 #if defined(HAVE_FLINT) && (__FLINT_RELEASE >= 20700)
699 {
701 fmpz_mpoly_ctx_t ctx;
702 fmpz_mpoly_ctx_init(ctx,
f.level(),ORD_LEX);
703 fmpz_mpoly_t Flint_f;
704 fmpz_mpoly_init(Flint_f,ctx);
705 convFactoryPFlintMP(fz,Flint_f,ctx,fz.
level());
706 fmpz_mpoly_factor_t factors;
707 fmpz_mpoly_factor_init(factors,ctx);
708 int rr;
709 if (issqrfree) rr=fmpz_mpoly_factor_squarefree(factors,Flint_f,ctx);
710 else rr=fmpz_mpoly_factor(factors,Flint_f,ctx);
711 if (rr==0) printf("fail\n");
712 fmpz_mpoly_t fac;
713 fmpz_mpoly_init(fac,ctx);
715 int cf_exp;
716 fmpz_t c;
717 fmpz_init(c);
718 fmpz_mpoly_factor_get_constant_fmpz(c,factors,ctx);
720 fmpz_clear(c);
722 for(
int i=fmpz_mpoly_factor_length(factors,ctx)-1;
i>=0;
i--)
723 {
724 fmpz_mpoly_factor_get_base(fac,factors,
i,ctx);
725 cf_fac=convFlintMPFactoryP(fac,ctx,
f.level());
726 cf_exp=fmpz_mpoly_factor_get_exp_si(factors,
i,ctx);
728 }
729 fmpz_mpoly_factor_clear(factors,ctx);
730 fmpz_mpoly_clear(Flint_f,ctx);
731 fmpz_mpoly_ctx_clear(ctx);
732 goto end_char0;
733 }
734 #endif
735 #if defined(HAVE_NTL)
737 if (issqrfree)
738 {
742 }
743 else
744 {
746 }
747 #endif
748 #if !defined(HAVE_FLINT) || (__FLINT_RELEASE < 20700)
749 #ifndef HAVE_NTL
751 #endif
752 #endif
753 }
754
755end_char0:
756 if ( on_rational )
758 else
761 {
765 }
766 }
767
768#if defined(HAVE_NTL)
769end_charp:
770#endif
772 return F;
773}
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)
CanonicalForm bCommonDen ( const CanonicalForm & f )
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)