Skip to content

Commit

Permalink
chg: more reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
mmklee committed Apr 4, 2012
1 parent 0e2e232 commit 81d96ce
Show file tree
Hide file tree
Showing 7 changed files with 704 additions and 717 deletions.
11 changes: 6 additions & 5 deletions factory/cf_gcd_smallp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "timing.h"

#include "canonicalform.h"
#include "algext.h"
#include "cf_map.h"
#include "cf_util.h"
#include "templates/ftmpl_functions.h"
Expand Down Expand Up @@ -4031,8 +4032,8 @@ int Hensel_P (const CanonicalForm & UU, CFArray & G, const Evaluation & AA,
CFArray lcs= CFArray (2);
lcs [0]= shiftedLCsEval1.getFirst();
lcs [1]= shiftedLCsEval2.getFirst();
henselLift122 (UEval.getFirst(), factors, liftBound, Pi, diophant, M,
lcs, false);
nonMonicHenselLift12 (UEval.getFirst(), factors, liftBound, Pi, diophant, M,
lcs, false);

for (CFListIterator i= factors; i.hasItem(); i++)
{
Expand All @@ -4048,9 +4049,9 @@ int Hensel_P (const CanonicalForm & UU, CFArray & G, const Evaluation & AA,
liftBounds[0]= liftBound;
for (int i= 1; i < U.level() - 1; i++)
liftBounds[i]= degree (shiftedU, Variable (i + 2)) + 1;
factors= henselLift2 (UEval, factors, liftBounds, U.level() - 1, false,
shiftedLCsEval1, shiftedLCsEval2, Pi, diophant,
noOneToOne);
factors= nonMonicHenselLift2 (UEval, factors, liftBounds, U.level() - 1,
false, shiftedLCsEval1, shiftedLCsEval2, Pi,
diophant, noOneToOne);
delete [] liftBounds;
if (noOneToOne)
return 0;
Expand Down
4 changes: 2 additions & 2 deletions factory/facFactorize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,8 @@ precomputeLeadingCoeff (const CanonicalForm& LCF, const CFList& LCFFactors,
CFMatrix M= CFMatrix (liftBound, factors.length() - 1);
CFArray Pi;
CFList diophant;
henselLift122 (newSqrfPartF, factors, liftBound, Pi, diophant, M,
leadingCoeffs, false);
nonMonicHenselLift12 (newSqrfPartF, factors, liftBound, Pi, diophant, M,
leadingCoeffs, false);

if (sqrfPartF.level() > 2)
{
Expand Down
1 change: 1 addition & 0 deletions factory/facFqBivarUtil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "config.h"

#include "cf_map.h"
#include "algext.h"
#include "cf_map_ext.h"
#include "templates/ftmpl_functions.h"
#include "ExtensionInfo.h"
Expand Down
4 changes: 2 additions & 2 deletions factory/facFqFactorize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1657,8 +1657,8 @@ precomputeLeadingCoeff (const CanonicalForm& LCF, const CFList& LCFFactors,
CFMatrix M= CFMatrix (liftBound, factors.length() - 1);
CFArray Pi;
CFList diophant;
henselLift122 (newSqrfPartF, factors, liftBound, Pi, diophant, M,
leadingCoeffs, false);
nonMonicHenselLift12 (newSqrfPartF, factors, liftBound, Pi, diophant, M,
leadingCoeffs, false);

if (sqrfPartF.level() > 2)
{
Expand Down
96 changes: 49 additions & 47 deletions factory/facHensel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#include "debug.h"
#include "timing.h"

#include "algext.h"
#include "facHensel.h"
#include "facMul.h"
#include "cf_util.h"
#include "fac_util.h"
#include "cf_algorithm.h"
#include "cf_primes.h"
Expand Down Expand Up @@ -124,7 +124,7 @@ void tryDiophantine (CFList& result, const CanonicalForm& F,
}
}

static inline
static
CFList mapinto (const CFList& L)
{
CFList result;
Expand All @@ -133,7 +133,7 @@ CFList mapinto (const CFList& L)
return result;
}

static inline
static
int mod (const CFList& L, const CanonicalForm& p)
{
for (CFListIterator i= L; i.hasItem(); i++)
Expand All @@ -145,7 +145,7 @@ int mod (const CFList& L, const CanonicalForm& p)
}


static inline void
static void
chineseRemainder (const CFList & x1, const CanonicalForm & q1,
const CFList & x2, const CanonicalForm & q2,
CFList & xnew, CanonicalForm & qnew)
Expand All @@ -161,7 +161,7 @@ chineseRemainder (const CFList & x1, const CanonicalForm & q1,
qnew= tmp2;
}

static inline
static
CFList Farey (const CFList& L, const CanonicalForm& q)
{
CFList result;
Expand All @@ -170,7 +170,7 @@ CFList Farey (const CFList& L, const CanonicalForm& q)
return result;
}

static inline
static
CFList replacevar (const CFList& L, const Variable& a, const Variable& b)
{
CFList result;
Expand Down Expand Up @@ -358,7 +358,6 @@ void sortList (CFList& list, const Variable& x)
}
}

static inline
CFList diophantine (const CanonicalForm& F, const CFList& factors)
{
if (getCharacteristic() == 0)
Expand Down Expand Up @@ -668,9 +667,8 @@ henselLiftResume12 (const CanonicalForm& F, CFList& factors, int start, int
return;
}

static inline
CFList
biDiophantine (const CanonicalForm& F, const CFList& factors, const int d)
biDiophantine (const CanonicalForm& F, const CFList& factors, int d)
{
Variable y= F.mvar();
CFList result;
Expand Down Expand Up @@ -769,10 +767,9 @@ biDiophantine (const CanonicalForm& F, const CFList& factors, const int d)
}
}

static inline
CFList
multiRecDiophantine (const CanonicalForm& F, const CFList& factors,
const CFList& recResult, const CFList& M, const int d)
const CFList& recResult, const CFList& M, int d)
{
Variable y= F.mvar();
CFList result;
Expand Down Expand Up @@ -858,7 +855,7 @@ multiRecDiophantine (const CanonicalForm& F, const CFList& factors,
return result;
}

static inline
static
void
henselStep (const CanonicalForm& F, const CFList& factors, CFArray& bufFactors,
const CFList& diophant, CFMatrix& M, CFArray& Pi, int j,
Expand Down Expand Up @@ -1100,7 +1097,7 @@ henselStep (const CanonicalForm& F, const CFList& factors, CFArray& bufFactors,
}

CFList
henselLift23 (const CFList& eval, const CFList& factors, const int* l, CFList&
henselLift23 (const CFList& eval, const CFList& factors, int* l, CFList&
diophant, CFArray& Pi, CFMatrix& M)
{
CFList buf= factors;
Expand Down Expand Up @@ -1167,8 +1164,7 @@ henselLiftResume (const CanonicalForm& F, CFList& factors, int start, int end,

CFList
henselLift (const CFList& F, const CFList& factors, const CFList& MOD, CFList&
diophant, CFArray& Pi, CFMatrix& M, const int lOld, const int
lNew)
diophant, CFArray& Pi, CFMatrix& M, int lOld, int lNew)
{
diophant= multiRecDiophantine (F.getFirst(), factors, diophant, MOD, lOld);
int k= 0;
Expand Down Expand Up @@ -1208,8 +1204,8 @@ henselLift (const CFList& F, const CFList& factors, const CFList& MOD, CFList&
}

CFList
henselLift (const CFList& eval, const CFList& factors, const int* l, const int
lLength, bool sort)
henselLift (const CFList& eval, const CFList& factors, int* l, int lLength,
bool sort)
{
CFList diophant;
CFList buf= factors;
Expand Down Expand Up @@ -1242,10 +1238,12 @@ henselLift (const CFList& eval, const CFList& factors, const int* l, const int
return result;
}

// nonmonic

void
henselStep122 (const CanonicalForm& F, const CFList& factors,
CFArray& bufFactors, const CFList& diophant, CFMatrix& M,
CFArray& Pi, int j, const CFArray& /*LCs*/)
nonMonicHenselStep12 (const CanonicalForm& F, const CFList& factors,
CFArray& bufFactors, const CFList& diophant, CFMatrix& M,
CFArray& Pi, int j, const CFArray& /*LCs*/)
{
Variable x= F.mvar();
CanonicalForm xToJ= power (x, j);
Expand Down Expand Up @@ -1454,8 +1452,9 @@ henselStep122 (const CanonicalForm& F, const CFList& factors,
}

void
henselLift122 (const CanonicalForm& F, CFList& factors, int l, CFArray& Pi,
CFList& diophant, CFMatrix& M, const CFArray& LCs, bool sort)
nonMonicHenselLift12 (const CanonicalForm& F, CFList& factors, int l,
CFArray& Pi, CFList& diophant, CFMatrix& M,
const CFArray& LCs, bool sort)
{
if (sort)
sortList (factors, Variable (1));
Expand Down Expand Up @@ -1521,7 +1520,7 @@ henselLift122 (const CanonicalForm& F, CFList& factors, int l, CFArray& Pi,
}

for (i= 1; i < l; i++)
henselStep122 (F, bufFactors2, bufFactors, diophant, M, Pi, i, LCs);
nonMonicHenselStep12 (F, bufFactors2, bufFactors, diophant, M, Pi, i, LCs);

factors= CFList();
for (i= 0; i < bufFactors.size(); i++)
Expand All @@ -1532,7 +1531,6 @@ henselLift122 (const CanonicalForm& F, CFList& factors, int l, CFArray& Pi,

/// solve \f$ E=sum_{i= 1}^{r}{\sigma_{i}prod_{j=1, j\neq i}^{r}{f_{i}}}\f$
/// mod M, products contains \f$ prod_{j=1, j\neq i}^{r}{f_{i}}} \f$
static inline
CFList
diophantine (const CFList& recResult, const CFList& factors,
const CFList& products, const CFList& M, const CanonicalForm& E,
Expand Down Expand Up @@ -1611,11 +1609,11 @@ diophantine (const CFList& recResult, const CFList& factors,
return result;
}

static inline
void
henselStep2 (const CanonicalForm& F, const CFList& factors, CFArray& bufFactors,
const CFList& diophant, CFMatrix& M, CFArray& Pi,
const CFList& products, int j, const CFList& MOD, bool& noOneToOne)
nonMonicHenselStep (const CanonicalForm& F, const CFList& factors,
CFArray& bufFactors, const CFList& diophant, CFMatrix& M,
CFArray& Pi, const CFList& products, int j,
const CFList& MOD, bool& noOneToOne)
{
CanonicalForm E;
CanonicalForm xToJ= power (F.mvar(), j);
Expand Down Expand Up @@ -1851,9 +1849,9 @@ CanonicalForm replaceLC (const CanonicalForm& F, const CanonicalForm& c)
}

CFList
henselLift232 (const CFList& eval, const CFList& factors, int* l, CFList&
diophant, CFArray& Pi, CFMatrix& M, const CFList& LCs1,
const CFList& LCs2, bool& bad)
nonMonicHenselLift232(const CFList& eval, const CFList& factors, int* l, CFList&
diophant, CFArray& Pi, CFMatrix& M, const CFList& LCs1,
const CFList& LCs2, bool& bad)
{
CFList buf= factors;
int k= 0;
Expand Down Expand Up @@ -1901,7 +1899,8 @@ henselLift232 (const CFList& eval, const CFList& factors, int* l, CFList&

for (int d= 1; d < l[1]; d++)
{
henselStep2 (j.getItem(), buf, bufFactors, diophant, M, Pi, products, d, MOD, bad);
nonMonicHenselStep (j.getItem(), buf, bufFactors, diophant, M, Pi, products,
d, MOD, bad);
if (bad)
return CFList();
}
Expand All @@ -1913,9 +1912,10 @@ henselLift232 (const CFList& eval, const CFList& factors, int* l, CFList&


CFList
henselLift2 (const CFList& F, const CFList& factors, const CFList& MOD, CFList&
diophant, CFArray& Pi, CFMatrix& M, const int lOld, int&
lNew, const CFList& LCs1, const CFList& LCs2, bool& bad)
nonMonicHenselLift2 (const CFList& F, const CFList& factors, const CFList& MOD,
CFList& diophant, CFArray& Pi, CFMatrix& M, int lOld,
int& lNew, const CFList& LCs1, const CFList& LCs2, bool& bad
)
{
int k= 0;
CFArray bufFactors= CFArray (factors.length());
Expand Down Expand Up @@ -1962,7 +1962,8 @@ henselLift2 (const CFList& F, const CFList& factors, const CFList& MOD, CFList&

for (int d= 1; d < lNew; d++)
{
henselStep2 (F.getLast(), buf, bufFactors, diophant, M, Pi, products, d, MOD, bad);
nonMonicHenselStep (F.getLast(), buf, bufFactors, diophant, M, Pi, products,
d, MOD, bad);
if (bad)
return CFList();
}
Expand All @@ -1974,18 +1975,18 @@ henselLift2 (const CFList& F, const CFList& factors, const CFList& MOD, CFList&
}

CFList
henselLift2 (const CFList& eval, const CFList& factors, int* l, const int
lLength, bool sort, const CFList& LCs1, const CFList& LCs2,
const CFArray& Pi, const CFList& diophant, bool& bad)
nonMonicHenselLift2 (const CFList& eval, const CFList& factors, int* l, int
lLength, bool sort, const CFList& LCs1, const CFList& LCs2,
const CFArray& Pi, const CFList& diophant, bool& bad)
{
CFList bufDiophant= diophant;
CFList buf= factors;
if (sort)
sortList (buf, Variable (1));
CFArray bufPi= Pi;
CFMatrix M= CFMatrix (l[1], factors.length());
CFList result= henselLift232(eval, buf, l, bufDiophant, bufPi, M, LCs1, LCs2,
bad);
CFList result=
nonMonicHenselLift232(eval, buf, l, bufDiophant, bufPi, M, LCs1, LCs2, bad);
if (bad)
return CFList();

Expand Down Expand Up @@ -2013,8 +2014,8 @@ henselLift2 (const CFList& eval, const CFList& factors, int* l, const int
bufLCs1.append (jj.getItem());
bufLCs2.append (jjj.getItem());
M= CFMatrix (l[i], factors.length());
result= henselLift2 (bufEval, result, MOD, bufDiophant, bufPi, M, l[i - 1],
l[i], bufLCs1, bufLCs2, bad);
result= nonMonicHenselLift2 (bufEval, result, MOD, bufDiophant, bufPi, M,
l[i - 1], l[i], bufLCs1, bufLCs2, bad);
if (bad)
return CFList();
MOD.append (power (Variable (i + 2), l[i]));
Expand Down Expand Up @@ -2111,7 +2112,8 @@ nonMonicHenselLift23 (const CanonicalForm& F, const CFList& factors, const
MOD.insert (yToL);
for (int d= 1; d < liftBound; d++)
{
henselStep2 (F, factors, bufFactors, diophant, M, Pi, products, d, MOD, bad);
nonMonicHenselStep (F, factors, bufFactors, diophant, M, Pi, products, d,
MOD, bad);
if (bad)
return CFList();
}
Expand All @@ -2124,7 +2126,7 @@ nonMonicHenselLift23 (const CanonicalForm& F, const CFList& factors, const

CFList
nonMonicHenselLift (const CFList& F, const CFList& factors, const CFList& LCs,
CFList& diophant, CFArray& Pi, CFMatrix& M, const int lOld,
CFList& diophant, CFArray& Pi, CFMatrix& M, int lOld,
int& lNew, const CFList& MOD, bool& noOneToOne
)
{
Expand Down Expand Up @@ -2191,8 +2193,8 @@ nonMonicHenselLift (const CFList& F, const CFList& factors, const CFList& LCs,

for (int d= 1; d < lNew; d++)
{
henselStep2 (F.getLast(), factors, bufFactors, diophant, M, Pi, products, d,
MOD, noOneToOne);
nonMonicHenselStep (F.getLast(), factors, bufFactors, diophant, M, Pi,
products, d, MOD, noOneToOne);
if (noOneToOne)
return CFList();
}
Expand Down
Loading

0 comments on commit 81d96ce

Please sign in to comment.