[SCM] an open source computer algebra system branch, cleanedupstream, updated. 6125e540ca6d66c307958938a9d53b245507c323

Bernhard R. Link brlink at debian.org
Tue Apr 24 15:54:55 UTC 2012


The following commit has been merged in the cleanedupstream branch:
commit 9bbac079f2f0c38fd5f2f50b98e154231c94c5bd
Author: Martin Lee <martinlee84 at web.de>
Date:   Thu Feb 16 16:08:44 2012 +0100

    chg: added diophantine equation solver using p-adic lifting

diff --git a/factory/facHensel.cc b/factory/facHensel.cc
index 46578f1..888da06 100644
--- a/factory/facHensel.cc
+++ b/factory/facHensel.cc
@@ -354,10 +354,102 @@ void sortList (CFList& list, const Variable& x)
   }
 }
 
-CFList diophantine (const CanonicalForm& F, const CFList& factors)
+CFList
+diophantine (const CanonicalForm& F, const CFList& factors);
+
+CFList
+diophantineHensel (const CanonicalForm & F, const CFList& factors,
+                   const modpk& b)
+{
+  int p= b.getp();
+  setCharacteristic (p);
+  CFList recResult= diophantine (mapinto (F), mapinto (factors));
+  setCharacteristic (0);
+  recResult= mapinto (recResult);
+  CanonicalForm e= 1;
+  CFList L;
+  CFArray bufFactors= CFArray (factors.length());
+  int k= 0;
+  for (CFListIterator i= factors; i.hasItem(); i++, k++)
+  {
+    if (k == 0)
+      bufFactors[k]= i.getItem() (0);
+    else
+      bufFactors [k]= i.getItem();
+  }
+  CanonicalForm tmp, quot;
+  for (k= 0; k < factors.length(); k++) //TODO compute b's faster
+  {
+    tmp= 1;
+    for (int l= 0; l < factors.length(); l++)
+    {
+      if (l == k)
+        continue;
+      else
+      {
+        tmp= mulNTL (tmp, bufFactors[l]);
+      }
+    }
+    L.append (tmp);
+  }
+
+  setCharacteristic (p);
+  for (k= 0; k < factors.length(); k++)
+    bufFactors [k]= bufFactors[k].mapinto();
+  setCharacteristic(0);
+
+  CFListIterator j= L;
+  for (CFListIterator i= recResult; i.hasItem(); i++, j++)
+    e= b (e - mulNTL (i.getItem(),j.getItem(), b));
+
+  if (e.isZero())
+    return recResult;
+  CanonicalForm coeffE;
+  CFList s;
+  CFList result= recResult;
+  CanonicalForm g;
+  CanonicalForm modulus= p;
+  int d= b.getk();
+  for (int i= 1; i < d; i++)
+  {
+    coeffE= div (e, modulus);
+    setCharacteristic (p);
+    coeffE= coeffE.mapinto();
+    setCharacteristic (0);
+    if (!coeffE.isZero())
+    {
+      CFListIterator k= result;
+      CFListIterator l= L;
+      int ii= 0;
+      j= recResult;
+      for (; j.hasItem(); j++, k++, l++, ii++)
+      {
+        setCharacteristic (p);
+        g= coeffE*j.getItem();
+        g= mod (g, bufFactors[ii]);
+        setCharacteristic (0);
+        k.getItem() += g.mapinto()*modulus;
+        e -= mulNTL (g.mapinto()*modulus, l.getItem(), b);
+        e= b(e);
+        DEBOUTLN (cerr, "mod (e, power (y, i + 1))= " <<
+                  mod (e, power (y, i + 1)));
+      }
+    }
+    modulus *= p;
+    if (e.isZero())
+      break;
+  }
+
+  return result;
+}
+
+CFList
+diophantine (const CanonicalForm& F, const CFList& factors, const modpk& b)
 {
   if (getCharacteristic() == 0)
   {
+    if (b.getp() != 0)
+      return diophantineHensel (F, factors, b);
     Variable v;
     bool hasAlgVar= hasFirstAlgVar (F, v);
     for (CFListIterator i= factors; i.hasItem() && !hasAlgVar; i++)
@@ -396,6 +488,13 @@ CFList diophantine (const CanonicalForm& F, const CFList& factors)
   return result;
 }
 
+CFList
+diophantine (const CanonicalForm& F, const CFList& factors)
+{
+  modpk b= modpk();
+  return diophantine (F, factors, b);
+}
+
 void
 henselStep12 (const CanonicalForm& F, const CFList& factors,
               CFArray& bufFactors, const CFList& diophant, CFMatrix& M,

-- 
an open source computer algebra system



More information about the debian-science-commits mailing list