Changeset 583cb9 in git


Ignore:
Timestamp:
Feb 16, 2012, 4:08:44 PM (11 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
a090c889f1e12a81de12b9d046e6b570d92ff592
Parents:
eb481bfd5b0d2091758933b4dc457ec82ff37ce7
git-author:
Martin Lee <martinlee84@web.de>2012-02-16 16:08:44+01:00
git-committer:
Martin Lee <martinlee84@web.de>2012-04-04 14:42:25+02:00
Message:
chg: added diophantine equation solver using p-adic lifting
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/facHensel.cc

    reb481b r583cb9  
    359359}
    360360
    361 CFList diophantine (const CanonicalForm& F, const CFList& factors)
     361CFList
     362diophantine (const CanonicalForm& F, const CFList& factors);
     363
     364CFList
     365diophantineHensel (const CanonicalForm & F, const CFList& factors,
     366                   const modpk& b)
     367{
     368  int p= b.getp();
     369  setCharacteristic (p);
     370  CFList recResult= diophantine (mapinto (F), mapinto (factors));
     371  setCharacteristic (0);
     372  recResult= mapinto (recResult);
     373  CanonicalForm e= 1;
     374  CFList L;
     375  CFArray bufFactors= CFArray (factors.length());
     376  int k= 0;
     377  for (CFListIterator i= factors; i.hasItem(); i++, k++)
     378  {
     379    if (k == 0)
     380      bufFactors[k]= i.getItem() (0);
     381    else
     382      bufFactors [k]= i.getItem();
     383  }
     384  CanonicalForm tmp, quot;
     385  for (k= 0; k < factors.length(); k++) //TODO compute b's faster
     386  {
     387    tmp= 1;
     388    for (int l= 0; l < factors.length(); l++)
     389    {
     390      if (l == k)
     391        continue;
     392      else
     393      {
     394        tmp= mulNTL (tmp, bufFactors[l]);
     395      }
     396    }
     397    L.append (tmp);
     398  }
     399
     400  setCharacteristic (p);
     401  for (k= 0; k < factors.length(); k++)
     402    bufFactors [k]= bufFactors[k].mapinto();
     403  setCharacteristic(0);
     404
     405  CFListIterator j= L;
     406  for (CFListIterator i= recResult; i.hasItem(); i++, j++)
     407    e= b (e - mulNTL (i.getItem(),j.getItem(), b));
     408
     409  if (e.isZero())
     410    return recResult;
     411  CanonicalForm coeffE;
     412  CFList s;
     413  CFList result= recResult;
     414  CanonicalForm g;
     415  CanonicalForm modulus= p;
     416  int d= b.getk();
     417  for (int i= 1; i < d; i++)
     418  {
     419    coeffE= div (e, modulus);
     420    setCharacteristic (p);
     421    coeffE= coeffE.mapinto();
     422    setCharacteristic (0);
     423    if (!coeffE.isZero())
     424    {
     425      CFListIterator k= result;
     426      CFListIterator l= L;
     427      int ii= 0;
     428      j= recResult;
     429      for (; j.hasItem(); j++, k++, l++, ii++)
     430      {
     431        setCharacteristic (p);
     432        g= coeffE*j.getItem();
     433        g= mod (g, bufFactors[ii]);
     434        setCharacteristic (0);
     435        k.getItem() += g.mapinto()*modulus;
     436        e -= mulNTL (g.mapinto()*modulus, l.getItem(), b);
     437        e= b(e);
     438        DEBOUTLN (cerr, "mod (e, power (y, i + 1))= " <<
     439                  mod (e, power (y, i + 1)));
     440      }
     441    }
     442    modulus *= p;
     443    if (e.isZero())
     444      break;
     445  }
     446
     447  return result;
     448}
     449
     450CFList
     451diophantine (const CanonicalForm& F, const CFList& factors, const modpk& b)
    362452{
    363453  if (getCharacteristic() == 0)
    364454  {
     455    if (b.getp() != 0)
     456      return diophantineHensel (F, factors, b);
    365457    Variable v;
    366458    bool hasAlgVar= hasFirstAlgVar (F, v);
     
    399491  }
    400492  return result;
     493}
     494
     495CFList
     496diophantine (const CanonicalForm& F, const CFList& factors)
     497{
     498  modpk b= modpk();
     499  return diophantine (F, factors, b);
    401500}
    402501
Note: See TracChangeset for help on using the changeset viewer.