Extended Zassenhaus GCD for finite fields. In case things become too dense we switch to a modular algorithm.
880 else if (FF.isZero() &&
GG.
isZero())
return FF.genOne();
882 if (FF.isUnivariate() &&
fdivides(FF,
GG))
return FF/
Lc(FF);
884 if (FF ==
GG)
return FF/
Lc(FF);
888 int sizeF=
size (FF);
910 CanonicalForm F,
G,
f,
g, d, Fb, Gb, Db, Fbt, Gbt, Dbt, B0,
B, D0, lcF, lcG,
912 CFArray DD( 1, 2 ), lcDD( 1, 2 );
930 int best_level= compress4EZGCD (F,
G,
M,
N, smallestDegLev);
932 if (best_level == 0)
return G.
genOne();
945 if( F.isUnivariate() &&
G.isUnivariate() )
947 if( F.mvar() ==
G.
mvar() )
953 if ( F.isUnivariate())
956 return N(d*
gcd(F,
g));
984 bool passToGF=
false;
985 bool extOfExt=
false;
997 else if (
p == 5 ||
p == 7)
1023 if (
p == 2 && d < 6)
1025 bool primFail=
false;
1028 ASSERT (!primFail,
"failure in integer factorizer");
1032 nmod_poly_t Irredpoly;
1034 nmod_poly_randtest_monic_irreducible(Irredpoly,
FLINTrandom, 3*d+1);
1037 #elif defined(HAVE_NTL)
1044 BuildIrred (NTLIrredpoly, d*3);
1054 nmod_poly_t Irredpoly;
1056 nmod_poly_randtest_monic_irreducible(Irredpoly,
FLINTrandom, 2*d+1);
1059 #elif defined(HAVE_NTL)
1066 BuildIrred (NTLIrredpoly, d*2);
1076 else if ((
p == 3 && d < 4) || ((
p == 5 ||
p == 7) && d < 3))
1078 bool primFail=
false;
1081 ASSERT (!primFail,
"failure in integer factorizer");
1083 nmod_poly_t Irredpoly;
1085 nmod_poly_randtest_monic_irreducible(Irredpoly,
FLINTrandom, 2*d+1);
1088 #elif defined(HAVE_NTL)
1095 BuildIrred (NTLIrredpoly, d*2);
1107 F=
mapUp (F, a, v2, primElem, imPrimElem, source, dest);
1108 G=
mapUp (
G, a, v2, primElem, imPrimElem, source, dest);
1113 lcF =
LC( F,
x ); lcG =
LC(
G,
x );
1114 lcD =
gcd( lcF, lcG );
1134 int goodPointCount= 0;
1139 if( !
findeval( F,
G, Fb, Gb, Db,
b,
delta, degF, degG, maxeval,
count, o,
1186 F=
mapDown (F, primElem, imPrimElem, oldA, dest, source);
1194 else if (
delta == degG)
1213 G=
mapDown (
G, primElem, imPrimElem, oldA, dest, source);
1233 if( !
findeval(F,
G,Fbt,Gbt,Dbt, bt,
delta, degF, degG, maxeval,
count, o,
1272 if (goodPointCount == 5)
1280 Db = Dbt; Fb = Fbt; Gb = Gbt;
1301 F=
mapDown (F, primElem, imPrimElem, oldA, dest, source);
1309 else if (
delta == degG)
1328 G=
mapDown (
G, primElem, imPrimElem, oldA, dest, source);
1352 xxx1 =
gcd( DD[1], Db );
1400 DD[2] = DD[2] * (
b( lcDD[2] ) /
lc( DD[2] ) );
1401 DD[1] = DD[1] * (
b( lcDD[1] ) /
lc( DD[1] ) );
1439 gcdfound=
Hensel (
B*lcD, DD,
b, lcDD);
1486 cand = DD[2] / contcand;
1492 "time for termination test EZ_P: ");
1494 if (passToGF && gcdfound)
1502 if (
k > 1 && gcdfound)
1507 if (extOfExt && gcdfound)
CanonicalForm convertnmod_poly_t2FacCF(const nmod_poly_t poly, const Variable &x)
conversion of a FLINT poly over Z/p to CanonicalForm
CanonicalForm convertNTLzzpX2CF(const zz_pX &poly, const Variable &x)
const CanonicalForm CFMap CFMap & N
STATIC_VAR int maxNumEval
static CanonicalForm gcd_mon(CanonicalForm F, CanonicalForm G)
static const double log2exp
static int Hensel(const CanonicalForm &UU, CFArray &G, const Evaluation &AA, const CFArray &LeadCoeffs)
const CanonicalForm CFMap & M
STATIC_VAR int sizePerVars1
static bool findeval(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Fb, CanonicalForm &Gb, CanonicalForm &Db, REvaluation &b, int delta, int degF, int degG, int maxeval, int &count, int &k, int bound, int &l)
bool gcd_test_one(const CanonicalForm &f, const CanonicalForm &g, bool swap, int &d)
Coprimality Check. f and g are assumed to have the same level. If swap is true, the main variables of...
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 const CanonicalForm & cand
CanonicalForm modGCDFp(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &coF, CanonicalForm &coG, bool &topLevel, CFList &l)
CanonicalForm sparseGCDFp(const CanonicalForm &F, const CanonicalForm &G, bool &topLevel, CFList &l)
CanonicalForm modGCDGF(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &coF, CanonicalForm &coG, CFList &l, bool &topLevel)
GCD of F and G over GF, based on Alg. 7.2. as described in "Algorithms for Computer Algebra" by Gedde...
bool fdivides(const CanonicalForm &f, const CanonicalForm &g)
bool fdivides ( const CanonicalForm & f, const CanonicalForm & g )
#define ASSERT(expression, message)
static const int SW_USE_EZGCD_P
set to 1 to use EZGCD over F_q
#define GaloisFieldDomain
CanonicalForm mapPrimElem(const CanonicalForm &primElem, const Variable &alpha, const Variable &beta)
compute the image of a primitive element of in . We assume .
CanonicalForm GFMapDown(const CanonicalForm &F, int k)
maps a polynomial over to a polynomial over , d needs to be a multiple of k
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
CanonicalForm GFMapUp(const CanonicalForm &F, int k)
maps a polynomial over to a polynomial over , d needs to be a multiple of k
CanonicalForm GF2FalphaRep(const CanonicalForm &F, const Variable &alpha)
changes representation by primitive element to representation by residue classes modulo a Conway poly...
int cf_getBigPrime(int i)
GLOBAL_VAR flint_rand_t FLINTrandom
VAR void(* factoryError)(const char *s)
int ipower(int b, int m)
int ipower ( int b, int m )
generate random elements in F_p(alpha)
generate random elements in F_p
generate random elements in GF
factory's class for variables
TIMING_END_AND_PRINT(fac_alg_resultant, "time to compute resultant0: ")
TIMING_START(fac_alg_resultant)
nmod_poly_init(FLINTmipo, getCharacteristic())
nmod_poly_clear(FLINTmipo)
Variable FACTORY_PUBLIC rootOf(const CanonicalForm &, char name='@')
returns a symbolic root of polynomial with name name Use it to define algebraic variables
void prune1(const Variable &alpha)
CanonicalForm getMipo(const Variable &alpha, const Variable &x)
void FACTORY_PUBLIC prune(Variable &alpha)
template CanonicalForm tmax(const CanonicalForm &, const CanonicalForm &)
template CanonicalForm tmin(const CanonicalForm &, const CanonicalForm &)
INST_VAR CanonicalForm gf_mipo
bool delta(X x, Y y, D d)
int status int void size_t count