Changeset a07784 in git for factory/facHensel.cc


Ignore:
Timestamp:
Dec 5, 2012, 4:03:45 PM (11 years ago)
Author:
Alexander Dreyer <adreyer@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
ae900ff750a6fe0dbab70a5aa87cc48fc3dd280e
Parents:
b3646035aca6a8d660df952d443268649a51090907ff965ddd552fe3a981f417b2da928dca53a8f2
Message:
Merge branch 'spielwiese' of github.com:Singular/Sources into spielwiese-pyobject
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/facHensel.cc

    rb36460 ra07784  
    450450  CanonicalForm modulus= p;
    451451  int d= b.getk();
     452  modpk b2;
    452453  for (int i= 1; i < d; i++)
    453454  {
     
    456457    coeffE= coeffE.mapinto();
    457458    setCharacteristic (0);
     459    b2= modpk (p, d - i);
    458460    if (!coeffE.isZero())
    459461    {
     
    465467      {
    466468        setCharacteristic (p);
    467         g= mulNTL (coeffE, j.getItem());
     469        g= modNTL (coeffE, bufFactors[ii]);
     470        g= mulNTL (g, j.getItem());
    468471        g= modNTL (g, bufFactors[ii]);
    469472        setCharacteristic (0);
    470473        k.getItem() += g.mapinto()*modulus;
    471         e -= mulNTL (g.mapinto()*modulus, l.getItem(), b);
     474        e -= mulNTL (g.mapinto(), b2 (l.getItem()), b2)*modulus;
    472475        e= b(e);
    473476      }
     
    629632  CanonicalForm modulus= p;
    630633  int d= b.getk();
     634  modpk b2;
    631635  for (int i= 1; i < d; i++)
    632636  {
     
    647651      coeffE= replacevar (coeffE, alpha, beta);
    648652    setCharacteristic (0);
     653    b2= modpk (p, d - i);
    649654    if (!coeffE.isZero())
    650655    {
     
    656661      {
    657662        setCharacteristic (p);
    658         g= mulNTL (coeffE, j.getItem());
     663        g= modNTL (coeffE, bufFactors[ii]);
     664        g= mulNTL (g, j.getItem());
    659665        g= modNTL (g, bufFactors[ii]);
    660666        setCharacteristic (0);
     
    663669          setReduce (beta, false);
    664670          k.getItem() += replacevar (g.mapinto()*modulus, beta, gamma);
    665           e -= mulNTL (replacevar (g.mapinto(), beta, gamma)*modulus,
    666                        l.getItem(), b);
     671          e -= mulNTL (replacevar (g.mapinto(), beta, gamma),
     672                       b2 (l.getItem()), b2)*modulus;
    667673          setReduce (beta, true);
    668674        }
    669675        else
    670676        {
     677          setReduce (beta, false);
    671678          k.getItem() += replacevar (g.mapinto()*modulus, beta, alpha);
    672           e -= mulNTL (replacevar (g.mapinto()*modulus, beta, alpha),
    673                        l.getItem(), b);
     679          e -= mulNTL (replacevar (g.mapinto(), beta, alpha),
     680                       b2 (l.getItem()), b2)*modulus;
     681          setReduce (beta, true);
    674682        }
    675683        e= b(e);
     
    681689  }
    682690
     691  return result;
     692}
     693
     694CFList
     695diophantineQa (const CanonicalForm& F, const CanonicalForm& G,
     696               const CFList& factors, modpk& b, const Variable& alpha)
     697{
     698  bool fail= false;
     699  CFList recResult;
     700  CanonicalForm modMipo, mipo;
     701  //here SW_RATIONAL is off
     702  On (SW_RATIONAL);
     703  mipo= getMipo (alpha);
     704  bool mipoHasDen= false;
     705  if (!bCommonDen (mipo).isOne())
     706  {
     707    mipo *= bCommonDen (mipo);
     708    mipoHasDen= true;
     709  }
     710  Off (SW_RATIONAL);
     711  int p= b.getp();
     712  setCharacteristic (p);
     713  setReduce (alpha, false);
     714  while (1)
     715  {
     716    setCharacteristic (p);
     717    modMipo= mapinto (mipo);
     718    modMipo /= lc (modMipo);
     719    tryDiophantine (recResult, mapinto (F), mapinto (factors), modMipo, fail);
     720    if (fail)
     721    {
     722      int i= 0;
     723      while (cf_getBigPrime (i) < p)
     724        i++;
     725      findGoodPrime (F, i);
     726      findGoodPrime (G, i);
     727      p=cf_getBigPrime(i);
     728      b = coeffBound( G, p, mipo );
     729      modpk bb= coeffBound (F, p, mipo );
     730      if (bb.getk() > b.getk() ) b=bb;
     731      fail= false;
     732    }
     733    else
     734      break;
     735  }
     736  setReduce (alpha, true);
     737  setCharacteristic (0);
     738
     739  Variable gamma= alpha;
     740  CanonicalForm den;
     741  if (mipoHasDen)
     742  {
     743    On (SW_RATIONAL);
     744    modMipo= getMipo (alpha);
     745    den= bCommonDen (modMipo);
     746    modMipo *= den;
     747    Off (SW_RATIONAL);
     748    setReduce (alpha, false);
     749    gamma= rootOf (b (modMipo*b.inverse (den)));
     750    setReduce (alpha, true);
     751  }
     752
     753  Variable x= Variable (1);
     754  CanonicalForm buf1, buf2, buf3, S;
     755  CFList bufFactors= factors;
     756  CFListIterator i= bufFactors;
     757  if (mipoHasDen)
     758  {
     759    for (; i.hasItem(); i++)
     760      i.getItem()= replacevar (i.getItem(), alpha, gamma);
     761  }
     762  i= bufFactors;
     763  CFList result;
     764  if (i.hasItem())
     765    i++;
     766  buf1= 0;
     767  CanonicalForm Freplaced;
     768  if (mipoHasDen)
     769  {
     770    Freplaced= replacevar (F, alpha, gamma);
     771    buf2= divNTL (Freplaced, replacevar (i.getItem(), alpha, gamma), b);
     772  }
     773  else
     774    buf2= divNTL (F, i.getItem(), b);
     775  ZZ_p::init (convertFacCF2NTLZZ (b.getpk()));
     776  ZZ_pX NTLmipo= to_ZZ_pX (convertFacCF2NTLZZX (getMipo (gamma)));
     777  ZZ_pE::init (NTLmipo);
     778  ZZ_pEX NTLS, NTLT, NTLbuf3;
     779  ZZ_pEX NTLbuf1= convertFacCF2NTLZZ_pEX (buf1, NTLmipo);
     780  ZZ_pEX NTLbuf2= convertFacCF2NTLZZ_pEX (buf2, NTLmipo);
     781  XGCD (NTLbuf3, NTLS, NTLT, NTLbuf1, NTLbuf2);
     782  result.append (b (convertNTLZZ_pEX2CF (NTLS, x, gamma)));
     783  result.append (b (convertNTLZZ_pEX2CF (NTLT, x, gamma)));
     784  if (i.hasItem())
     785    i++;
     786  for (; i.hasItem(); i++)
     787  {
     788    if (mipoHasDen)
     789      buf1= divNTL (Freplaced, i.getItem(), b);
     790    else
     791      buf1= divNTL (F, i.getItem(), b);
     792    XGCD (NTLbuf3, NTLS, NTLT, NTLbuf3, convertFacCF2NTLZZ_pEX (buf1, NTLmipo));
     793    CFListIterator k= bufFactors;
     794    S= convertNTLZZ_pEX2CF (NTLS, x, gamma);
     795    for (CFListIterator j= result; j.hasItem(); j++, k++)
     796    {
     797      j.getItem()= mulNTL (j.getItem(), S, b);
     798      j.getItem()= modNTL (j.getItem(), k.getItem(), b);
     799    }
     800    result.append (b (convertNTLZZ_pEX2CF (NTLT, x, gamma)));
     801  }
    683802  return result;
    684803}
     
    698817      if (b.getp() != 0)
    699818      {
    700         CFList result= diophantineHenselQa (F, G, factors, b, v);
     819        CFList result= diophantineQa (F, G, factors, b, v);
    701820        return result;
    702821      }
Note: See TracChangeset for help on using the changeset viewer.