Changeset 53e6c3 in git for factory


Ignore:
Timestamp:
Aug 26, 2014, 11:21:22 AM (10 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'spielwiese', '4a9821a93ffdc22a6696668bd4f6b8c9de3e6c5f')
Children:
98abec57dad14f757407f31931b9555ceee6c4ad
Parents:
30e27f8a94644c552a6548c8b0d0b2026ceb2068
git-author:
Martin Lee <martinlee84@web.de>2014-08-26 11:21:22+02:00
git-committer:
Martin Lee <martinlee84@web.de>2014-08-26 12:29:12+02:00
Message:
deleted some redundant code
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/cfEzgcd.cc

    r30e27f r53e6c3  
    307307  for (int i= A.min(); i <= A.max(); i++)
    308308  {
    309     if (!A[i].isZero())
     309    if (!A[i].isZero() &&
     310        ((getCharacteristic() > degree (U,i)) || getCharacteristic() == 0))
    310311    {
    311312      termEstimate *= degree (U,i)*2;
     
    433434}
    434435
     436/// real implementation of EZGCD over Z
    435437static CanonicalForm
    436438ezgcd ( const CanonicalForm & FF, const CanonicalForm & GG, REvaluation & b,
     
    776778#endif
    777779
     780/// Extended Zassenhaus GCD over Z.
     781/// In case things become too dense we switch to a modular algorithm.
    778782CanonicalForm
    779783ezgcd ( const CanonicalForm & FF, const CanonicalForm & GG )
     
    790794
    791795#ifdef HAVE_NTL
    792 static inline
    793 int Hensel_P (const CanonicalForm & UU, CFArray & G, const Evaluation & AA,
    794               const CFArray& LeadCoeffs )
    795 {
    796   CFList factors;
    797   factors.append (G[1]);
    798   factors.append (G[2]);
    799 
    800   CFMap NN, MM;
    801   Evaluation A= optimize4Lift (UU, MM, NN, AA);
    802 
    803   CanonicalForm U= MM (UU);
    804   CFArray LCs= CFArray (1,2);
    805   LCs [1]= MM (LeadCoeffs [1]);
    806   LCs [2]= MM (LeadCoeffs [2]);
    807 
    808   CFList evaluation;
    809   long termEstimate= size (U);
    810   for (int i= A.min(); i <= A.max(); i++)
    811   {
    812     if (!A[i].isZero() && (getCharacteristic() > degree (U,i))) //TODO find a good estimate for getCharacteristic() <= degree (U,i)
    813     {
    814       termEstimate *= degree (U,i)*2;
    815       termEstimate /= 3;
    816     }
    817     evaluation.append (A [i]);
    818   }
    819   if (termEstimate/getNumVars(U) > 500)
    820     return -1;
    821   CFList UEval;
    822   CanonicalForm shiftedU= myShift2Zero (U, UEval, evaluation);
    823 
    824   if (size (shiftedU)/getNumVars (U) > 500)
    825     return -1;
    826 
    827   CFArray shiftedLCs= CFArray (2);
    828   CFList shiftedLCsEval1, shiftedLCsEval2;
    829   shiftedLCs[0]= myShift2Zero (LCs[1], shiftedLCsEval1, evaluation);
    830   shiftedLCs[1]= myShift2Zero (LCs[2], shiftedLCsEval2, evaluation);
    831   factors.insert (1);
    832   int liftBound= degree (UEval.getLast(), 2) + 1;
    833   CFArray Pi;
    834   CFMatrix M= CFMatrix (liftBound, factors.length() - 1);
    835   CFList diophant;
    836   CFArray lcs= CFArray (2);
    837   lcs [0]= shiftedLCsEval1.getFirst();
    838   lcs [1]= shiftedLCsEval2.getFirst();
    839   nonMonicHenselLift12 (UEval.getFirst(), factors, liftBound, Pi, diophant, M,
    840                         lcs, false);
    841 
    842   for (CFListIterator i= factors; i.hasItem(); i++)
    843   {
    844     if (!fdivides (i.getItem(), UEval.getFirst()))
    845       return 0;
    846   }
    847 
    848   int * liftBounds;
    849   bool noOneToOne= false;
    850   if (U.level() > 2)
    851   {
    852     liftBounds= new int [U.level() - 1]; /* index: 0.. U.level()-2 */
    853     liftBounds[0]= liftBound;
    854     for (int i= 1; i < U.level() - 1; i++)
    855       liftBounds[i]= degree (shiftedU, Variable (i + 2)) + 1;
    856     factors= nonMonicHenselLift2 (UEval, factors, liftBounds, U.level() - 1,
    857                                   false, shiftedLCsEval1, shiftedLCsEval2, Pi,
    858                                   diophant, noOneToOne);
    859     delete [] liftBounds;
    860     if (noOneToOne)
    861       return 0;
    862   }
    863   G[1]= factors.getFirst();
    864   G[2]= factors.getLast();
    865   G[1]= myReverseShift (G[1], evaluation);
    866   G[2]= myReverseShift (G[2], evaluation);
    867   G[1]= NN (G[1]);
    868   G[2]= NN (G[2]);
    869   return 1;
    870 }
    871 
    872 static inline
    873 bool findeval_P (const CanonicalForm & F, const CanonicalForm & G,
    874                  CanonicalForm & Fb, CanonicalForm & Gb, CanonicalForm & Db,
    875                  REvaluation & b, int delta, int degF, int degG, int maxeval,
    876                  int & count, int& k, int bound, int& l)
    877 {
    878   if( count == 0 && delta != 0)
    879   {
    880     if( count++ > maxeval )
    881       return false;
    882   }
    883   if (count > 0)
    884   {
    885     b.nextpoint(k);
    886     if (k == 0)
    887       k++;
    888     l++;
    889     if (l > bound)
    890     {
    891       l= 1;
    892       k++;
    893       if (k > tmax (F.level(), G.level()) - 1)
    894         return false;
    895       b.nextpoint (k);
    896     }
    897     if (count++ > maxeval)
    898       return false;
    899   }
    900   while( true )
    901   {
    902     Fb = b( F );
    903     if( degree( Fb, 1 ) == degF )
    904     {
    905       Gb = b( G );
    906       if( degree( Gb, 1 ) == degG )
    907       {
    908         Db = gcd( Fb, Gb );
    909         if( delta > 0 )
    910         {
    911           if( degree( Db, 1 ) <= delta )
    912             return true;
    913         }
    914         else
    915           return true;
    916       }
    917     }
    918     if (k == 0)
    919       k++;
    920     b.nextpoint(k);
    921     l++;
    922     if (l > bound)
    923     {
    924       l= 1;
    925       k++;
    926       if (k > tmax (F.level(), G.level()) - 1)
    927         return false;
    928       b.nextpoint (k);
    929     }
    930     if( count++ > maxeval )
    931       return false;
    932   }
    933 }
    934 
    935796// parameters for heuristic
    936797static int maxNumEval= 200;
     
    938799
    939800/// Extended Zassenhaus GCD for finite fields.
    940 /// In case things become too dense we switch to a modular algorithm
     801/// In case things become too dense we switch to a modular algorithm.
    941802CanonicalForm EZGCD_P( const CanonicalForm & FF, const CanonicalForm & GG )
    942803{
     
    11541015  {
    11551016    TIMING_START (ez_p_eval);
    1156     if( !findeval_P( F, G, Fb, Gb, Db, b, delta, degF, degG, maxeval, count, o,
     1017    if( !findeval( F, G, Fb, Gb, Db, b, delta, degF, degG, maxeval, count, o,
    11571018         maxeval/maxNumVars, t ))
    11581019    { // too many eval. used --> try another method
     
    12481109      bt = b;
    12491110      TIMING_START (ez_p_eval);
    1250       if( !findeval_P(F,G,Fbt,Gbt,Dbt, bt, delta, degF, degG, maxeval, count, o,
     1111      if( !findeval(F,G,Fbt,Gbt,Dbt, bt, delta, degF, degG, maxeval, count, o,
    12511112           maxeval/maxNumVars, t ))
    12521113      { // too many eval. used --> try another method
     
    14531314
    14541315      TIMING_START (ez_p_hensel_lift);
    1455       gcdfound= Hensel_P (B*lcD, DD, b, lcDD);
     1316      gcdfound= Hensel (B*lcD, DD, b, lcDD);
    14561317      TIMING_END_AND_PRINT (ez_p_hensel_lift, "time for Hensel lift in EZ_P: ");
    14571318
Note: See TracChangeset for help on using the changeset viewer.