Changeset f36755 in git for factory


Ignore:
Timestamp:
Aug 15, 2013, 1:36:09 PM (11 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
d2fc7499626d249cfc3ad438edba68d30192d631
Parents:
dfa84937f0c3f7da5b22bc6282fb9c46eccad506
git-author:
Martin Lee <martinlee84@web.de>2013-08-15 13:36:09+02:00
git-committer:
Martin Lee <martinlee84@web.de>2013-08-30 13:48:32+02:00
Message:
chg: choose smaller evaluation point
chg: more checks to avoid wrong mipos
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/facAbsBiFact.cc

    rdfa849 rf36755  
    157157
    158158//TODO optimize choice of p -> choose p as large as possible (better than small p since factorization mod p does not require field extension, also less lifting)
    159 int choosePoint (const CanonicalForm& F, int tdegF, CFArray& eval, bool rec)
     159int
     160choosePoint (const CanonicalForm& F, int tdegF, CFArray& eval, bool rec,
     161             int absValue)
    160162{
    161   REvaluation E1 (1, 1, IntRandom (25));
    162   REvaluation E2 (2, 2, IntRandom (25));
     163  REvaluation E1 (1, 1, IntRandom (absValue));
     164  REvaluation E2 (2, 2, IntRandom (absValue));
    163165  if (rec)
    164166  {
     
    166168    E2.nextpoint();
    167169  }
     170
    168171  CanonicalForm f, f1, f2, Fp;
    169172  int i, p;
    170   eval=CFArray (2);
     173  CFFList f1Factors, f2Factors;
     174  CFFListIterator iter;
     175  int count= 0;
    171176  while (1)
    172177  {
    173     f1= E1(F);
    174     if (!f1.isZero() && factorize (f1).length() == 2)
    175     {
    176       Off (SW_RATIONAL);
    177       f= E2(f1);
    178       f2= E2 (F);
    179       if ((!f.isZero()) && (abs(f)>cf_getSmallPrime (cf_getNumSmallPrimes()-1)))
     178    count++;
     179    f1= E1 (F);
     180    if (!f1.isZero() && degree (f1) == degree (F,2))
     181    {
     182      f1Factors= factorize (f1);
     183      if (f1Factors.getFirst().factor().inCoeffDomain())
     184        f1Factors.removeFirst();
     185      if (f1Factors.length() == 1 && f1Factors.getFirst().exp() == 1)
    180186      {
    181         for (i= cf_getNumPrimes()-1; i >= 0; i--)
     187        f= E2(f1);
     188        f2= E2 (F);
     189        f2Factors= factorize (f2);
     190        Off (SW_RATIONAL);
     191        if (f2Factors.getFirst().factor().inCoeffDomain())
     192          f2Factors.removeFirst();
     193        if (f2Factors.length() == 1 && f2Factors.getFirst().exp() == 1)
    182194        {
    183           if (f % CanonicalForm (cf_getPrime (i)) == 0)
     195          ZZX NTLf1= convertFacCF2NTLZZX (f1);
     196          ZZX NTLf2= convertFacCF2NTLZZX (f2);
     197          ZZ NTLD1= discriminant (NTLf1);
     198          ZZ NTLD2= discriminant (NTLf2);
     199          CanonicalForm D1= convertZZ2CF (NTLD1);
     200          CanonicalForm D2= convertZZ2CF (NTLD2);
     201          if ((!f.isZero()) &&
     202              (abs(f)>cf_getSmallPrime (cf_getNumSmallPrimes()-1)))
    184203          {
    185             p= cf_getPrime(i);
    186             Fp= mod (F,p);
    187             if (totaldegree (Fp) == tdegF &&
    188                 degree (mod (f2,p), 1) == degree (F,1) &&
    189                 degree (mod (f1, p),2) == degree (F,2))
     204            for (i= cf_getNumPrimes()-1; i >= 0; i--)
    190205            {
    191               eval[0]= E1[1];
    192               eval[1]= E2[2];
    193               return p;
     206              if (f % CanonicalForm (cf_getPrime (i)) == 0)
     207              {
     208                p= cf_getPrime(i);
     209                Fp= mod (F,p);
     210                if (totaldegree (Fp) == tdegF &&
     211                    degree (mod (f2,p), 1) == degree (F,1) &&
     212                    degree (mod (f1, p),2) == degree (F,2))
     213                {
     214                  if (mod (D1, p) != 0 && mod (D2, p) != 0)
     215                  {
     216                    eval[0]= E1[1];
     217                    eval[1]= E2[2];
     218                    return p;
     219                  }
     220                }
     221              }
     222            }
     223          }
     224          else if (!f.isZero())
     225          {
     226            for (i= cf_getNumSmallPrimes()-1; i >= 0; i--)
     227            {
     228              if (f % CanonicalForm (cf_getSmallPrime (i)) == 0)
     229              {
     230                p= cf_getSmallPrime (i);
     231                Fp= mod (F,p);
     232                if (totaldegree (Fp) == tdegF &&
     233                    degree (mod (f2, p),1) == degree (F,1) &&
     234                    degree (mod (f1,p),2) == degree (F,2))
     235                {
     236                  if (mod (D1, p) != 0 && mod (D2, p) != 0)
     237                  {
     238                    eval[0]= E1[1];
     239                    eval[1]= E2[2];
     240                    return p;
     241                  }
     242                }
     243              }
    194244            }
    195245          }
    196246        }
     247        E2.nextpoint();
     248        On (SW_RATIONAL);
    197249      }
    198       else if (!f.isZero())
    199       {
    200         for (i= cf_getNumSmallPrimes()-1; i >= 0; i--)
    201         {
    202           if (f % CanonicalForm (cf_getSmallPrime (i)) == 0)
    203           {
    204             p= cf_getSmallPrime (i);
    205             Fp= mod (F,p);
    206             if (totaldegree (Fp) == tdegF &&
    207                 degree (mod (f2, p),1) == degree (F,1) &&
    208                 degree (mod (f1,p),2) == degree (F,2))
    209             {
    210               eval[0]= E1[1];
    211               eval[1]= E2[2];
    212               return p;
    213             }
    214           }
    215         }
    216       }
     250    }
     251    E1.nextpoint();
     252    if (count == 2)
     253    {
     254      count= 0;
     255      absValue++;
     256      E1=REvaluation (1, 1, IntRandom (absValue));
     257      E2=REvaluation (2, 2, IntRandom (absValue));
     258      E1.nextpoint();
    217259      E2.nextpoint();
    218       On (SW_RATIONAL);
    219     }
    220     E1.nextpoint();
     260    }
    221261  }
    222262  return 0;
     
    231271  F /= icontent (F);
    232272  On (SW_RATIONAL);
    233   CFArray eval;
    234273  int minTdeg, tdegF= totaldegree (F);
    235274  CanonicalForm Fp, smallestFactor;
     
    242281  CanonicalForm bufF= F;
    243282  CFFListIterator iter;
     283  CFArray eval= CFArray (2);
     284  int absValue= 1;
    244285differentevalpoint:
    245286  while (1)
    246287  {
    247288    TIMING_START (fac_evalpoint);
    248     p= choosePoint (F, tdegF, eval, rec);
     289    p= choosePoint (F, tdegF, eval, rec, absValue);
    249290    TIMING_END_AND_PRINT (fac_evalpoint, "time to find eval point: ");
    250291
Note: See TracChangeset for help on using the changeset viewer.