Changeset 8a30b1 in git for factory/facFactorize.cc


Ignore:
Timestamp:
Jul 19, 2012, 12:14:06 PM (11 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '1d362c315e551a5b527ab0759f8839cf0e94f3a5')
Children:
4fee0ed1233fdc5967b5508da747cc77fe30de63
Parents:
e0af3ef0dd8793dabc30eac5d848f0b020acd362
git-author:
Martin Lee <martinlee84@web.de>2012-07-19 12:14:06+02:00
git-committer:
Martin Lee <martinlee84@web.de>2012-09-04 17:25:37+02:00
Message:
fix: bug in precomputation of leading coefficient
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/facFactorize.cc

    re0af3ef r8a30b1  
    268268
    269269  CFMap N, M;
    270   CFArray dummy= CFArray (1);
     270  CFArray dummy= CFArray (2);
    271271  dummy [0]= LCF;
     272  dummy [1]= Variable (2);
    272273  compress (dummy, M, N);
    273274  CanonicalForm F= M (LCF);
     
    321322  CFList evalSqrfPartF, bufFactors;
    322323  CFArray evalPoint= CFArray (evaluation.length() - 1);
     324  CFArray buf= CFArray (evaluation.length());
     325  CFArray swap= CFArray (evaluation.length());
    323326  CFListIterator iter= evaluation;
    324   for (int i= evaluation.length() - 2; i > -1; i--, iter++)
    325     evalPoint[i]= iter.getItem();
     327  CanonicalForm vars=getVars (LCF);
     328  for (int i= evaluation.length() +1; i > 1; i--, iter++)
     329  {
     330    buf[i-2]=iter.getItem();
     331    if (degree (vars, i) > 0)
     332      swap[M(Variable (i)).level()-1]=buf[i-2];
     333  }
     334  buf= swap;
     335  for (int i= 0; i < evaluation.length() - 1; i++)
     336    evalPoint[i]= buf[i+1];
     337
    326338  //TODO sqrfPartF einmal berechnen nicht stÀndig
    327339  int pass= testFactors (F, factors, sqrfPartF,
     
    335347  {
    336348    int lev= 0;
     349    CanonicalForm bufF;
     350    CFList bufBufFactors;
    337351    for (int i= 0; i < length; i++)
    338352    {
    339       CanonicalForm bufF, swap;
    340       CFList bufBufFactors;
    341       CFArray buf;
    342353      if (!differentSecondVarLCs [i].isEmpty())
    343354      {
     
    363374        bufBufFactors= bufFactors;
    364375        evalPoint= CFArray (evaluation.length() - 1);
    365         buf= CFArray (evaluation.length());
    366         iter= evaluation;
    367         int k= evaluation.length() - 1;
    368         for (; iter.hasItem(); iter++, k--)
    369           buf[k]= iter.getItem();
    370         swap= buf[z.level() - 1];
    371         buf[z.level() - 1]= buf[0];
    372         buf[0]= 0;
    373         int l= 0;
    374         for (k= 0; k < evaluation.length(); k++)
     376        for (int k= 0; k < evaluation.length()-1; k++)
    375377        {
    376           if (buf[k].isZero())
    377             continue;
    378           evalPoint[l]= buf[k];
    379           l++;
     378          if (k+1 != lev)
     379            evalPoint[k]= buf[k+1];
     380          else
     381            evalPoint[k]= buf[0];
    380382        }
    381383        pass= testFactors (bufF, bufBufFactors, sqrfPartF, bufFactors,
     
    421423  bufFactors= factors;
    422424  CFList evaluation2;
    423   if (y == x)
    424     evaluation2= evaluation;
    425   else
    426   {
    427     CanonicalForm tmp;
    428     evaluation2= evaluation;
    429     int i= evaluation.length() + 1;
    430     for (CFListIterator iter= evaluation2; iter.hasItem(); iter++, i--)
    431     {
    432       if (i == y.level())
    433       {
    434         tmp= iter.getItem();
    435         iter.getItem()= evaluation2.getLast();
    436         evaluation2.removeLast();
    437         evaluation2.append (tmp);
    438         break;
    439       }
    440     }
    441   }
     425  for (int i= 0; i < F.level()-1; i++)
     426    evaluation2.insert (evalPoint[i]);
    442427
    443428  CFList interMedResult;
    444429  CanonicalForm oldSqrfPartF= sqrfPartF;
    445   sqrfPartF= shift2Zero (sqrfPartF, evalSqrfPartF, evaluation2, 1);
     430  sqrfPartF= shift2Zero (sqrfPartF, evalSqrfPartF, evaluation2);
    446431  if (factors.length() > 1)
    447432  {
     
    451436      leadingCoeffs.append (LC1);
    452437
    453     CFList LC1eval= evaluateAtEval (LC1, evaluation2, 1);
     438    CFList LC1eval= evaluateAtEval (LC1, evaluation2,2);
    454439    CFList oldFactors= factors;
    455440    for (CFListIterator i= oldFactors; i.hasItem(); i++)
     
    460445    if (size (oldSqrfPartFPowLC)/getNumVars (oldSqrfPartFPowLC) < 500 &&
    461446        LucksWangSparseHeuristic (oldSqrfPartFPowLC,
    462                                   oldFactors, 1, leadingCoeffs, factors))
     447                                  oldFactors, 2, leadingCoeffs, factors))
    463448    {
    464449      interMedResult= recoverFactors (oldSqrfPartF, factors);
     
    475460
    476461      for (CFListIterator i= factors; i.hasItem(); i++)
    477       {
    478         i.getItem()= i.getItem() (x + evaluation2.getLast(), x);
    479462        i.getItem() *= LC1 (0,2)/Lc (i.getItem());
    480       }
    481463      factors.insert (1);
    482464
     
    522504      }
    523505      for (CFListIterator iter= factors; iter.hasItem(); iter++)
    524         iter.getItem()= reverseShift (iter.getItem(), evaluation2, 1);
     506        iter.getItem()= reverseShift (iter.getItem(), evaluation2);
    525507
    526508      interMedResult=
    527       recoverFactors (reverseShift(evalSqrfPartF.getLast(),evaluation2,1),
     509      recoverFactors (reverseShift(evalSqrfPartF.getLast(),evaluation2),
    528510                      factors);
    529511    }
Note: See TracChangeset for help on using the changeset viewer.