Changeset 803956 in git


Ignore:
Timestamp:
Apr 7, 2013, 2:20:04 AM (9 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '48f1dd268d0ff74ef2f7dccbf02545425002ddcc')
Children:
919cae9250ad682976bdd4a2ecfe501d48b672dd
Parents:
52cccfd3872fe7f123040534ad2fdbde32e83b75
git-author:
Martin Lee <martinlee84@web.de>2013-04-07 02:20:04+02:00
git-committer:
Martin Lee <martinlee84@web.de>2013-04-08 14:42:32+02:00
Message:
fix: wrong computation of pth root due to int overflow
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/facFqSquarefree.cc

    r52cccfd r803956  
    2424#include "facFqSquarefree.h"
    2525
     26#ifdef HAVE_NTL
     27#include "NTLconvert.h"
     28#endif
     29
    2630static inline
    2731CanonicalForm
     
    4347  }
    4448}
     49
     50#ifdef HAVE_NTL
     51CanonicalForm
     52pthRoot (const CanonicalForm & F, const ZZ& q, const Variable& alpha)
     53{
     54  CanonicalForm A= F;
     55  int p= getCharacteristic ();
     56  if (A.inCoeffDomain())
     57  {
     58    zz_p::init (p);
     59    zz_pX NTLMipo= convertFacCF2NTLzzpX (getMipo (alpha));
     60    zz_pE::init (NTLMipo);
     61    zz_pX NTLA= convertFacCF2NTLzzpX (A);
     62    zz_pE NTLA2= to_zz_pE (NTLA);
     63    power (NTLA2, NTLA2, q/p);
     64    A= convertNTLzzpE2CF (NTLA2, alpha);
     65    return A;
     66  }
     67  else
     68  {
     69    CanonicalForm buf= 0;
     70    for (CFIterator i= A; i.hasTerms(); i++)
     71      buf= buf + power(A.mvar(), i.exp()/p)*pthRoot (i.coeff(), q, alpha);
     72    return buf;
     73  }
     74}
     75#endif
    4576
    4677CanonicalForm
     
    157188    return CFFList (CFFactor (F/Lc(F), 1));
    158189
    159   CanonicalForm buffer= pthRoot (A, ipower (p, k));
     190  CanonicalForm buffer;
     191#ifdef HAVE_NTL
     192  if (alpha.level() == 1)
     193#endif
     194    buffer= pthRoot (A, ipower (p, k));
     195#ifdef HAVE_NTL
     196  else
     197  {
     198    ZZ q;
     199    power (q, p, k);
     200    buffer= pthRoot (A, q, alpha);
     201  }
     202#endif
    160203
    161204  tmp1= squarefreeFactorization (buffer, alpha);
Note: See TracChangeset for help on using the changeset viewer.