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

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


The following commit has been merged in the cleanedupstream branch:
commit 2e792e0e69f7f2b0ce1bb0697f8d15f7d67c0b85
Author: Martin Lee <martinlee84 at web.de>
Date:   Fri Mar 16 16:08:58 2012 +0100

    chg/fix: handling of minpolys over Q[t]\Z[t]

diff --git a/factory/facBivar.cc b/factory/facBivar.cc
index f54ff29..dc8a972 100644
--- a/factory/facBivar.cc
+++ b/factory/facBivar.cc
@@ -630,7 +630,8 @@ CFList biFactorize (const CanonicalForm& F, const Variable& v)
   int liftBound= degree (A, y) + 1;
 
   modpk b= modpk();
-  if ( !extension)
+  bool mipoHasDen= false;
+  if (!extension)
   {
     Off (SW_RATIONAL);
     int i= 0;
@@ -654,6 +655,8 @@ CFList biFactorize (const CanonicalForm& F, const Variable& v)
     // make factors elements of Z(a)[x] disable for modularDiophant
     for (CFListIterator i= uniFactors; i.hasItem(); i++)
       i.getItem()= i.getItem()*bCommonDen(i.getItem());
+    mipoHasDen= !bCommonDen(mipo).isOne();
+    mipo *= bCommonDen (mipo);
     Off (SW_RATIONAL);
     int i= 0;
     ZZX NTLmipo= convertFacCF2NTLZZX (mipo);
@@ -684,6 +687,16 @@ CFList biFactorize (const CanonicalForm& F, const Variable& v)
 
   CanonicalForm MODl= power (y, liftBound);
 
+  if (mipoHasDen)
+  {
+    Variable vv;
+    for (CFListIterator iter= uniFactors; iter.hasItem(); iter++)
+      if (hasFirstAlgVar (iter.getItem(), vv))
+        break;
+    for (CFListIterator iter= uniFactors; iter.hasItem(); iter++)
+      iter.getItem()= replacevar (iter.getItem(), vv, v);
+  }
+
   factors= factorRecombination (uniFactors, A, MODl, degs, 1,
                                 uniFactors.length()/2, b);
 
diff --git a/factory/facBivar.h b/factory/facBivar.h
index e363f23..bf73faa 100644
--- a/factory/facBivar.h
+++ b/factory/facBivar.h
@@ -80,37 +80,9 @@ ratBiSqrfFactorize (const CanonicalForm & G,        ///< [in] a bivariate poly
   mat_ZZ M;
   vec_ZZ S;
   F= compress (F, M, S);
-  Variable tmp1, tmp2;
-  CanonicalForm mipoTmp1;
-  bool substAlgVar= false;
-  if (v.level() != 1)
-  {
-    mipoTmp1= getMipo (v);
-    if (!bCommonDen (getMipo (v)).isOne())
-    {
-      tmp2= v;
-      mipoTmp1 *= bCommonDen (mipoTmp1);
-      mipoTmp1= replacevar (mipoTmp1, v, Variable (1));
-      tmp1= rootOf (mipoTmp1);
-      F= replacevar (F, tmp2, tmp1);
-      substAlgVar= true;
-    }
-    else
-      tmp1= v;
-  }
-  else
-    tmp1= v;
-  CFList result= biFactorize (F, tmp1);
-  if (substAlgVar)
-  {
-    for (CFListIterator i= result; i.hasItem(); i++)
-      i.getItem()= N (decompress (replacevar (i.getItem(), tmp1, tmp2), M, S));
-  }
-  else
-  {
-    for (CFListIterator i= result; i.hasItem(); i++)
-      i.getItem()= N (decompress (i.getItem(), M, S));
-  }
+  CFList result= biFactorize (F, v);
+  for (CFListIterator i= result; i.hasItem(); i++)
+    i.getItem()= N (decompress (i.getItem(), M, S));
   for (CFFListIterator i= contentXFactors; i.hasItem(); i++)
     result.append (N(i.getItem().factor()));
   for (CFFListIterator i= contentYFactors; i.hasItem(); i++)
@@ -213,47 +185,15 @@ ratBiFactorize (const CanonicalForm & G,         ///< [in] a bivariate poly
   mat_ZZ M;
   vec_ZZ S;
   F= compress (F, M, S);
-  Variable tmp1, tmp2;
-  CanonicalForm mipoTmp1;
-  bool substAlgVar= false;
-  if (v.level() != 1)
-  {
-    mipoTmp1= getMipo (v);
-    if (!bCommonDen (getMipo (v)).isOne())
-    {
-      tmp2= v;
-      mipoTmp1 *= bCommonDen (mipoTmp1);
-      mipoTmp1= replacevar (mipoTmp1, v, Variable (1));
-      tmp1= rootOf (mipoTmp1);
-      F= replacevar (F, tmp2, tmp1);
-      substAlgVar= true;
-    }
-    else
-      tmp1= v;
-  }
-  else
-    tmp1= v;
   CFFList sqrfFactors= sqrFree (F);
   for (CFFListIterator i= sqrfFactors; i.hasItem(); i++)
   {
-    CFList tmp= ratBiSqrfFactorize (i.getItem().factor(), tmp1);
-    if (substAlgVar)
+    CFList tmp= ratBiSqrfFactorize (i.getItem().factor(), v);
+    for (CFListIterator j= tmp; j.hasItem(); j++)
     {
-      for (CFListIterator j= tmp; j.hasItem(); j++)
-      {
-        if (j.getItem().inCoeffDomain()) continue;
-        result.append (CFFactor (N (decompress (replacevar (j.getItem(),
-                                 tmp1, tmp2), M, S)), i.getItem().exp()));
-      }
-    }
-    else
-    {
-      for (CFListIterator j= tmp; j.hasItem(); j++)
-      {
-        if (j.getItem().inCoeffDomain()) continue;
-        result.append (CFFactor (N (decompress (j.getItem(), M, S)),
-                                 i.getItem().exp()));
-      }
+      if (j.getItem().inCoeffDomain()) continue;
+      result.append (CFFactor (N (decompress (j.getItem(), M, S)),
+                               i.getItem().exp()));
     }
   }
   result= Union (result, contentXFactors);
diff --git a/factory/facFqBivar.cc b/factory/facFqBivar.cc
index 9e6ddbf..9386b18 100644
--- a/factory/facFqBivar.cc
+++ b/factory/facFqBivar.cc
@@ -33,6 +33,7 @@
 #include "facFqBivarUtil.h"
 #include "facFqBivar.h"
 #include "cfNewtonPolygon.h"
+#include "algext.h"
 
 #ifdef HAVE_NTL
 #include "NTLconvert.h"
@@ -520,19 +521,33 @@ factorRecombination (CFList& factors, CanonicalForm& F,
         continue;
       else
       {
-        test= prodMod0 (S, M, b);
+        if (!isRat)
+          On (SW_RATIONAL);
+        test= prodMod0 (S, M);
+        if (!isRat)
+        {
+          test *= bCommonDen (test);
+          Off (SW_RATIONAL);
+        }
         test= mulNTL (test, LCBuf, b);
         test= mod (test, M);
         if (uniFdivides (test, buf0))
         {
+          if (!isRat)
+            On (SW_RATIONAL);
           S.insert (LCBuf);
           g= prodMod (S, M);
           S.removeFirst();
+          if (!isRat)
+          {
+            g *= bCommonDen(g);
+            Off (SW_RATIONAL);
+          }
           if (b.getp() != 0)
             g= b(g);
-          g /= content (g, x);
           if (!isRat)
             On (SW_RATIONAL);
+          g /= content (g, x);
           if (fdivides (g, buf, quot))
           {
             recombination= true;
@@ -677,12 +692,19 @@ earlyFactorDetection (CFList& reconstructedFactors, CanonicalForm& F, CFList&
         test0= mod (mulNTL (i.getItem() (0,x), LCBuf, b), M);
         if (uniFdivides (test0, buf0))
         {
+          if (!isRat)
+            On (SW_RATIONAL);
           g= mulMod2 (i.getItem(), LCBuf, M);
+          if (!isRat)
+          {
+            g *= bCommonDen(g);
+            Off (SW_RATIONAL);
+          }
           if (b.getp() != 0)
             g= b(g);
-          g /= content (g, x);
           if (!isRat)
             On (SW_RATIONAL);
+          g /= content (g, x);
           if (fdivides (g, buf, quot))
           {
             reconstructedFactors.append (g);
@@ -910,6 +932,7 @@ henselLiftAndEarly (CanonicalForm& A, bool& earlySuccess, CFList&
   CFList bufUniFactors= uniFactors;
   CanonicalForm bufA= A;
   CanonicalForm lcA0= 0;
+  bool mipoHasDen= false;
   if (getCharacteristic() == 0 && b.getp() != 0)
   {
     if (alpha.level() == 1)
@@ -923,13 +946,10 @@ henselLiftAndEarly (CanonicalForm& A, bool& earlySuccess, CFList&
     else
     {
       lcA0= Lc (A (0,2));
-      ZZX NTLlcA0= convertFacCF2NTLZZX (lcA0);
-      ZZX NTLmipo= convertFacCF2NTLZZX (getMipo (alpha));
-      ZZ NTLpk= power_ZZ (b.getp(), b.getk());
-      ZZ_p::init (NTLpk);
-      ZZ_pX S, T, G;
-      XGCD (G, S, T, to_ZZ_pX (NTLlcA0), to_ZZ_pX(NTLmipo));
-      CanonicalForm lcA0inverse= convertNTLZZX2CF (to_ZZX (S), alpha);
+      On (SW_RATIONAL);
+      mipoHasDen= !bCommonDen(getMipo(alpha)).isOne();
+      Off (SW_RATIONAL);
+      CanonicalForm lcA0inverse= b.inverse (lcA0);
       A *= lcA0inverse;
       A= b (A);
       // Lc of bufUniFactors is in Z
@@ -948,15 +968,38 @@ henselLiftAndEarly (CanonicalForm& A, bool& earlySuccess, CFList&
   for (int i= 0; i < uniFactors.length(); i++)
     factorsFoundIndex [i]= 0;
 
+  CFList bufBufUniFactors;
+  Variable v= alpha;
   if (smallFactorDeg >= liftBound || degree (A,y) <= 4)
     henselLift12 (A, bufUniFactors, liftBound, Pi, diophant, M, b, true);
   else if (sizeOfLiftPre > 1 && sizeOfLiftPre < 30)
   {
     henselLift12 (A, bufUniFactors, smallFactorDeg, Pi, diophant, M, b, true);
+    if (mipoHasDen)
+    {
+      for (CFListIterator iter= bufUniFactors; iter.hasItem(); iter++)
+        if (hasFirstAlgVar (iter.getItem(), v))
+          break;
+      if (v != alpha)
+      {
+        bufBufUniFactors= bufUniFactors;
+        for (CFListIterator iter= bufBufUniFactors; iter.hasItem(); iter++)
+          iter.getItem()= replacevar (iter.getItem(), v, alpha);
+        A= replacevar (A, alpha, v);
+      }
+    }
+
     if (!extension)
-      earlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
-                            factorsFoundIndex, degs, earlySuccess,
-                            smallFactorDeg, b);
+    {
+      if (v==alpha)
+        earlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
+                              factorsFoundIndex, degs, earlySuccess,
+                              smallFactorDeg, b);
+      else
+        earlyFactorDetection(earlyFactors, bufA, bufBufUniFactors, newLiftBound,
+                             factorsFoundIndex, degs, earlySuccess,
+                             smallFactorDeg, b);
+    }
     else
       extEarlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
                                factorsFoundIndex, degs, earlySuccess, info,
@@ -969,12 +1012,25 @@ henselLiftAndEarly (CanonicalForm& A, bool& earlySuccess, CFList&
         bufUniFactors.insert (LC (A, x));
         henselLiftResume12 (A, bufUniFactors, smallFactorDeg,
                             liftPre[sizeOfLiftPre-1] + 1, Pi, diophant, M, b);
+        if (v!=alpha)
+        {
+          bufBufUniFactors= bufUniFactors;
+          for (CFListIterator iter= bufBufUniFactors; iter.hasItem(); iter++)
+            iter.getItem()= replacevar (iter.getItem(), v, alpha);
+        }
         if (!extension)
+        {
+          if (v==alpha)
           earlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
                                 factorsFoundIndex, degs, earlySuccess,
                                 liftPre[sizeOfLiftPre-1] + 1, b);
+          else
+          earlyFactorDetection (earlyFactors,bufA,bufBufUniFactors,newLiftBound,
+                                factorsFoundIndex, degs, earlySuccess,
+                                liftPre[sizeOfLiftPre-1] + 1, b);
+        }
         else
-          extEarlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
+          extEarlyFactorDetection (earlyFactors,bufA,bufUniFactors,newLiftBound,
                                    factorsFoundIndex, degs, earlySuccess, info,
                                    eval, liftPre[sizeOfLiftPre-1] + 1);
       }
@@ -990,12 +1046,25 @@ henselLiftAndEarly (CanonicalForm& A, bool& earlySuccess, CFList&
         bufUniFactors.insert (LC (A, x));
         henselLiftResume12 (A, bufUniFactors, liftPre[i] + 1,
                             liftPre[i-1] + 1, Pi, diophant, M, b);
+        if (v!=alpha)
+        {
+          bufBufUniFactors= bufUniFactors;
+          for (CFListIterator iter= bufBufUniFactors; iter.hasItem(); iter++)
+            iter.getItem()= replacevar (iter.getItem(), v, alpha);
+        }
         if (!extension)
+        {
+          if (v==alpha)
           earlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
                                 factorsFoundIndex, degs, earlySuccess,
                                 liftPre[i-1] + 1, b);
+          else
+          earlyFactorDetection (earlyFactors,bufA,bufBufUniFactors,newLiftBound,
+                                factorsFoundIndex, degs, earlySuccess,
+                                liftPre[i-1] + 1, b);
+        }
         else
-          extEarlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
+          extEarlyFactorDetection (earlyFactors,bufA,bufUniFactors,newLiftBound,
                                    factorsFoundIndex, degs, earlySuccess, info,
                                    eval, liftPre[i-1] + 1);
       }
@@ -1013,10 +1082,30 @@ henselLiftAndEarly (CanonicalForm& A, bool& earlySuccess, CFList&
   else
   {
     henselLift12 (A, bufUniFactors, smallFactorDeg, Pi, diophant, M, b, true);
+    if (mipoHasDen)
+    {
+      for (CFListIterator iter= bufUniFactors; iter.hasItem(); iter++)
+        if (hasFirstAlgVar (iter.getItem(), v))
+          break;
+      if (v != alpha)
+      {
+        bufBufUniFactors= bufUniFactors;
+        for (CFListIterator iter= bufBufUniFactors; iter.hasItem(); iter++)
+          iter.getItem()= replacevar (iter.getItem(), v, alpha);
+        A= replacevar (A, alpha, v);
+      }
+    }
     if (!extension)
+    {
+      if (v==alpha)
       earlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
                             factorsFoundIndex, degs, earlySuccess,
                             smallFactorDeg, b);
+      else
+      earlyFactorDetection (earlyFactors, bufA, bufBufUniFactors, newLiftBound,
+                            factorsFoundIndex, degs, earlySuccess,
+                            smallFactorDeg, b);
+    }
     else
       extEarlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
                                factorsFoundIndex, degs, earlySuccess, info,
@@ -1030,11 +1119,23 @@ henselLiftAndEarly (CanonicalForm& A, bool& earlySuccess, CFList&
       bufUniFactors.insert (LC (A, x));
       henselLiftResume12 (A, bufUniFactors, smallFactorDeg,
                           dummy, Pi, diophant, M, b);
+      if (v!=alpha)
+      {
+        bufBufUniFactors= bufUniFactors;
+        for (CFListIterator iter= bufBufUniFactors; iter.hasItem(); iter++)
+          iter.getItem()= replacevar (iter.getItem(), v, alpha);
+      }
       if (!extension)
+      {
+        if (v==alpha)
         earlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
                               factorsFoundIndex, degs, earlySuccess, dummy, b);
+        else
+        earlyFactorDetection (earlyFactors, bufA,bufBufUniFactors, newLiftBound,
+                              factorsFoundIndex, degs, earlySuccess, dummy, b);
+      }
       else
-        extEarlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
+        extEarlyFactorDetection (earlyFactors, bufA,bufUniFactors, newLiftBound,
                                  factorsFoundIndex, degs, earlySuccess, info,
                                  eval, dummy);
     }
@@ -1046,11 +1147,23 @@ henselLiftAndEarly (CanonicalForm& A, bool& earlySuccess, CFList&
         dummy= tmin (degree (A,y)+1, (degree (A,y)/4)*(i+1)+4);
         henselLiftResume12 (A, bufUniFactors, (degree (A,y)/4)*i + 4,
                             dummy, Pi, diophant, M, b);
+        if (v!=alpha)
+        {
+          bufBufUniFactors= bufUniFactors;
+          for (CFListIterator iter= bufBufUniFactors; iter.hasItem(); iter++)
+            iter.getItem()= replacevar (iter.getItem(), v, alpha);
+        }
         if (!extension)
+        {
+          if (v==alpha)
           earlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
                                 factorsFoundIndex, degs, earlySuccess, dummy,b);
+          else
+          earlyFactorDetection (earlyFactors,bufA,bufBufUniFactors,newLiftBound,
+                                factorsFoundIndex, degs, earlySuccess, dummy,b);
+        }
         else
-          extEarlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
+          extEarlyFactorDetection (earlyFactors,bufA,bufUniFactors,newLiftBound,
                                    factorsFoundIndex, degs, earlySuccess, info,
                                    eval, dummy);
       }
diff --git a/factory/facHensel.cc b/factory/facHensel.cc
index 3637ae1..c70cd67 100644
--- a/factory/facHensel.cc
+++ b/factory/facHensel.cc
@@ -451,12 +451,21 @@ CFList
 diophantineHenselQa (const CanonicalForm & F, const CanonicalForm& G,
                      const CFList& factors, modpk& b, const Variable& alpha)
 {
-  int p= b.getp();
-  setCharacteristic (p);
   bool fail= false;
   CFList recResult;
   CanonicalForm modMipo, mipo;
+  //here SW_RATIONAL is off
+  On (SW_RATIONAL);
   mipo= getMipo (alpha);
+  bool mipoHasDen= false;
+  if (!bCommonDen (mipo).isOne())
+  {
+    mipo *= bCommonDen (mipo);
+    mipoHasDen= true;
+  }
+  Off (SW_RATIONAL);
+  int p= b.getp();
+  setCharacteristic (p);
   setReduce (alpha, false);
   while (1)
   {
@@ -494,7 +503,8 @@ diophantineHenselQa (const CanonicalForm & F, const CanonicalForm& G,
     else
       bufFactors [k]= i.getItem();
   }
-  CanonicalForm tmp, quot;
+  CanonicalForm tmp;
+  On (SW_RATIONAL);
   for (k= 0; k < factors.length(); k++) //TODO compute b's faster
   {
     tmp= 1;
@@ -505,24 +515,88 @@ diophantineHenselQa (const CanonicalForm & F, const CanonicalForm& G,
       else
         tmp= mulNTL (tmp, bufFactors[l]);
     }
-    L.append (tmp);
+    L.append (tmp*bCommonDen(tmp));
+  }
+
+  Variable gamma;
+  CanonicalForm den;
+  if (mipoHasDen)
+  {
+    modMipo= getMipo (alpha);
+    den= bCommonDen (modMipo);
+    modMipo *= den;
+    Off (SW_RATIONAL);
+    setReduce (alpha, false);
+    gamma= rootOf (b (modMipo*b.inverse (den)));
+    setReduce (alpha, true);
   }
 
   setCharacteristic (p);
+  Variable beta;
+  Off (SW_RATIONAL);
+  if (mipoHasDen)
+  {
+    setReduce (alpha, false);
+    modMipo= modMipo.mapinto();
+    modMipo /= lc (modMipo);
+    beta= rootOf (modMipo);
+    setReduce (alpha, true);
+  }
+
   for (k= 0; k < factors.length(); k++)
-    bufFactors [k]= bufFactors[k].mapinto();
+  {
+    if (!mipoHasDen)
+      bufFactors [k]= bufFactors[k].mapinto();
+    else
+    {
+      bufFactors [k]= bufFactors[k].mapinto();
+      bufFactors [k]= replacevar (bufFactors[k], alpha, beta);
+    }
+  }
   setCharacteristic(0);
 
   CFListIterator j= L;
+  for (;j.hasItem(); j++)
+  {
+    if (mipoHasDen)
+      j.getItem()= replacevar (b(j.getItem()*b.inverse(lc(j.getItem()))),
+                               alpha, gamma);
+    else
+      j.getItem()= b(j.getItem()*b.inverse(lc(j.getItem())));
+  }
+  j= L;
   for (CFListIterator i= recResult; i.hasItem(); i++, j++)
-    e= b (e - mulNTL (i.getItem(),j.getItem(), b));
+  {
+    if (mipoHasDen)
+      e= b (e - mulNTL (replacevar (i.getItem(), alpha, gamma),j.getItem(), b));
+    else
+      e= b (e - mulNTL (i.getItem(), j.getItem(), b));
+  }
 
   if (e.isZero())
+  {
+    if (mipoHasDen)
+    {
+      for (CFListIterator i= recResult; i.hasItem(); i++)
+        i.getItem()= replacevar (i.getItem(), alpha, gamma);
+    }
     return recResult;
+  }
   CanonicalForm coeffE;
   CFList result= recResult;
+  if (mipoHasDen)
+  {
+    for (CFListIterator i= result; i.hasItem(); i++)
+      i.getItem()= replacevar (i.getItem(), alpha, gamma);
+  }
   setCharacteristic (p);
   recResult= mapinto (recResult);
+  if (mipoHasDen)
+  {
+    for (CFListIterator i= recResult; i.hasItem(); i++)
+      i.getItem()= replacevar (i.getItem(), alpha, beta);
+  }
+
   setCharacteristic (0);
   CanonicalForm g;
   CanonicalForm modulus= p;
@@ -532,6 +606,8 @@ diophantineHenselQa (const CanonicalForm & F, const CanonicalForm& G,
     coeffE= div (e, modulus);
     setCharacteristic (p);
     coeffE= coeffE.mapinto();
+    if (mipoHasDen)
+      coeffE= replacevar (coeffE, gamma, beta);
     setCharacteristic (0);
     if (!coeffE.isZero())
     {
@@ -545,8 +621,17 @@ diophantineHenselQa (const CanonicalForm & F, const CanonicalForm& G,
         g= mulNTL (coeffE, j.getItem());
         g= modNTL (g, bufFactors[ii]);
         setCharacteristic (0);
-        k.getItem() += g.mapinto()*modulus;
-        e -= mulNTL (g.mapinto()*modulus, l.getItem(), b);
+        if (mipoHasDen)
+        {
+          k.getItem() += replacevar (g.mapinto()*modulus, beta, gamma);
+          e -= mulNTL (replacevar (g.mapinto(), beta, gamma)*modulus,
+                                   l.getItem(), b);
+        }
+        else
+        {
+          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)));
@@ -848,6 +933,25 @@ henselLift12 (const CanonicalForm& F, CFList& factors, int l, CFArray& Pi,
   Pi= CFArray (factors.length() - 1);
   CFListIterator j= factors;
   diophant= diophantine (F[0], F, factors, b);
+  CanonicalForm bufF= F;
+  if (getCharacteristic() == 0 && b.getp() != 0)
+  {
+    Variable v;
+    bool hasAlgVar= hasFirstAlgVar (F, v);
+    for (CFListIterator i= factors; i.hasItem() && !hasAlgVar; i++)
+      hasAlgVar= hasFirstAlgVar (i.getItem(), v);
+    Variable w;
+    bool hasAlgVar2= false;
+    for (CFListIterator i= diophant; i.hasItem() && !hasAlgVar2; i++)
+      hasAlgVar2= hasFirstAlgVar (i.getItem(), w);
+    if (hasAlgVar && hasAlgVar2 && v!=w)
+    {
+      bufF= replacevar (bufF, v, w);
+      for (CFListIterator i= factors; i.hasItem(); i++)
+        i.getItem()= replacevar (i.getItem(), v, w);
+    }
+  }
+
   DEBOUTLN (cerr, "diophant= " << diophant);
   j++;
   Pi [0]= mulNTL (j.getItem(), mod (factors.getFirst(), F.mvar()), b);
@@ -870,7 +974,7 @@ henselLift12 (const CanonicalForm& F, CFList& factors, int l, CFArray& Pi,
       bufFactors[i]= k.getItem();
   }
   for (i= 1; i < l; i++)
-    henselStep12 (F, factors, bufFactors, diophant, M, Pi, i, b);
+    henselStep12 (bufF, factors, bufFactors, diophant, M, Pi, i, b);
 
   CFListIterator k= factors;
   for (i= 0; i < factors.length (); i++, k++)

-- 
an open source computer algebra system



More information about the debian-science-commits mailing list