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

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


The following commit has been merged in the cleanedupstream branch:
commit 1fdb303d6292ed0c94d8589fb30a50fba0f878d4
Author: Martin Lee <martinlee84 at web.de>
Date:   Tue Jan 24 17:47:03 2012 +0100

    chg: substitution in the top level routines

diff --git a/factory/facBivar.h b/factory/facBivar.h
index 688ac2b..1b92b63 100644
--- a/factory/facBivar.h
+++ b/factory/facBivar.h
@@ -37,9 +37,10 @@ biFactorize (const CanonicalForm& F,       ///< [in] a bivariate poly
 /// @ return @a ratBiSqrfFactorize returns a list of monic factors, the first
 ///         element is the leading coefficient.
 inline
-CFList ratBiSqrfFactorize (const CanonicalForm & G, ///< [in] a bivariate poly
-                           const Variable& v
-                         )
+CFList
+ratBiSqrfFactorize (const CanonicalForm & G, ///< [in] a bivariate poly
+                    const Variable& v        ///< [in] algebraic variable
+                   )
 {
   CFMap N;
   CanonicalForm F= compress (G, N);
@@ -90,12 +91,56 @@ CFList ratBiSqrfFactorize (const CanonicalForm & G, ///< [in] a bivariate poly
 /// @return @a ratBiFactorize returns a list of monic factors with
 ///         multiplicity, the first element is the leading coefficient.
 inline
-CFFList ratBiFactorize (const CanonicalForm & G, ///< [in] a bivariate poly
-                        const Variable& v
-                      )
+CFFList
+ratBiFactorize (const CanonicalForm & G, ///< [in] a bivariate poly
+                const Variable& v,       ///< [in] algebraic variable
+                bool substCheck= true    ///< [in] enables substitute check
+               )
 {
   CFMap N;
   CanonicalForm F= compress (G, N);
+
+  if (substCheck)
+  {
+    bool foundOne= false;
+    int * substDegree= new int [F.level()];
+    for (int i= 1; i <= F.level(); i++)
+    {
+      substDegree[i-1]= substituteCheck (F, Variable (i));
+      if (substDegree [i-1] > 1)
+      {
+        foundOne= true;
+        subst (F, F, substDegree[i-1], Variable (i));
+      }
+    }
+    if (foundOne)
+    {
+      CFFList result= ratBiFactorize (F, v, false);
+      CFFList newResult, tmp;
+      CanonicalForm tmp2;
+      newResult.insert (result.getFirst());
+      result.removeFirst();
+      for (CFFListIterator i= result; i.hasItem(); i++)
+      {
+        tmp2= i.getItem().factor();
+        for (int j= 1; j <= F.level(); j++)
+        {
+          if (substDegree[j-1] > 1)
+            tmp2= reverseSubst (tmp2, substDegree[j-1], Variable (j));
+        }
+        tmp= ratBiFactorize (tmp2, v, false);
+        tmp.removeFirst();
+        for (CFFListIterator j= tmp; j.hasItem(); j++)
+          newResult.append (CFFactor (j.getItem().factor(),
+                                      j.getItem().exp()*i.getItem().exp()));
+      }
+      decompress (newResult, N);
+      delete [] substDegree;
+      return newResult;
+    }
+    delete [] substDegree;
+  }
+
   CanonicalForm LcF= Lc (F);
   CanonicalForm contentX= content (F, 1);
   CanonicalForm contentY= content (F, 2);
diff --git a/factory/facFactorize.h b/factory/facFactorize.h
index 9be53d6..c6802a6 100644
--- a/factory/facFactorize.h
+++ b/factory/facFactorize.h
@@ -31,9 +31,10 @@ multiFactorize (const CanonicalForm& F,     ///< [in] poly to be factored
 /// @return @a ratSqrfFactorize returns a list of monic factors, the first
 ///         element is the leading coefficient.
 inline
-CFList ratSqrfFactorize (const CanonicalForm & G, ///< [in] a multivariate poly
-                         const Variable& v
-                       )
+CFList
+ratSqrfFactorize (const CanonicalForm & G,       ///<[in] a multivariate poly
+                  const Variable& v              ///<[in] algebraic variable
+                 )
 {
   if (getNumVars (G) == 2)
     return ratBiSqrfFactorize (G, v);
@@ -54,9 +55,11 @@ CFList ratSqrfFactorize (const CanonicalForm & G, ///< [in] a multivariate poly
 /// @return @a ratFactorize returns a list of monic factors with
 ///         multiplicity, the first element is the leading coefficient.
 inline
-CFFList ratFactorize (const CanonicalForm& G, ///< [in] a multivariate poly
-                      const Variable& v
-                    )
+CFFList
+ratFactorize (const CanonicalForm& G,        ///<[in] a multivariate poly
+              const Variable& v,             ///<[in] algebraic variable
+              bool substCheck= true          ///<[in] enables substitute check
+             )
 {
   if (getNumVars (G) == 2)
   {
@@ -64,6 +67,52 @@ CFFList ratFactorize (const CanonicalForm& G, ///< [in] a multivariate poly
     return result;
   }
   CanonicalForm F= G;
+
+  if (substCheck)
+  {
+    bool foundOne= false;
+    int * substDegree= new int [F.level()];
+    for (int i= 1; i <= F.level(); i++)
+    {
+      if (degree (F, i) > 0)
+      {
+        substDegree[i-1]= substituteCheck (F, Variable (i));
+        if (substDegree [i-1] > 1)
+        {
+          foundOne= true;
+          subst (F, F, substDegree[i-1], Variable (i));
+        }
+      }
+      else
+        substDegree[i-1]= -1;
+    }
+    if (foundOne)
+    {
+      CFFList result= ratFactorize (F, v, false);
+      CFFList newResult, tmp;
+      CanonicalForm tmp2;
+      newResult.insert (result.getFirst());
+      result.removeFirst();
+      for (CFFListIterator i= result; i.hasItem(); i++)
+      {
+        tmp2= i.getItem().factor();
+        for (int j= 1; j <= G.level(); j++)
+        {
+          if (substDegree[j-1] > 1)
+            tmp2= reverseSubst (tmp2, substDegree[j-1], Variable (j));
+        }
+        tmp= ratFactorize (tmp2, v, false);
+        tmp.removeFirst();
+        for (CFFListIterator j= tmp; j.hasItem(); j++)
+          newResult.append (CFFactor (j.getItem().factor(),
+                                      j.getItem().exp()*i.getItem().exp()));
+      }
+      delete [] substDegree;
+      return newResult;
+    }
+    delete [] substDegree;
+  }
+
   CanonicalForm LcF= Lc (F);
   if (isOn (SW_RATIONAL))
     F *= bCommonDen (F);
diff --git a/factory/facFqBivar.h b/factory/facFqBivar.h
index 72211fa..7933a6b 100644
--- a/factory/facFqBivar.h
+++ b/factory/facFqBivar.h
@@ -197,12 +197,56 @@ CFList GFBiSqrfFactorize (const CanonicalForm & G ///< [in] a bivariate poly
 ///         multiplicity, the first element is the leading coefficient.
 /// @sa FqBiFactorize(), GFBiFactorize()
 inline
-CFFList FpBiFactorize (const CanonicalForm & G ///< [in] a bivariate poly
-                      )
+CFFList
+FpBiFactorize (const CanonicalForm & G, ///< [in] a bivariate poly
+               bool substCheck= true    ///< [in] enables substitute check
+              )
 {
   ExtensionInfo info= ExtensionInfo (false);
   CFMap N;
   CanonicalForm F= compress (G, N);
+
+  if (substCheck)
+  {
+    bool foundOne= false;
+    int * substDegree= new int [F.level()];
+    for (int i= 1; i <= F.level(); i++)
+    {
+      substDegree[i-1]= substituteCheck (F, Variable (i));
+      if (substDegree [i-1] > 1)
+      {
+        foundOne= true;
+        subst (F, F, substDegree[i-1], Variable (i));
+      }
+    }
+    if (foundOne)
+    {
+      CFFList result= FpBiFactorize (F, false);
+      CFFList newResult, tmp;
+      CanonicalForm tmp2;
+      newResult.insert (result.getFirst());
+      result.removeFirst();
+      for (CFFListIterator i= result; i.hasItem(); i++)
+      {
+        tmp2= i.getItem().factor();
+        for (int j= 1; j <= F.level(); j++)
+        {
+          if (substDegree[j-1] > 1)
+            tmp2= reverseSubst (tmp2, substDegree[j-1], Variable (j));
+        }
+        tmp= FpBiFactorize (tmp2, false);
+        tmp.removeFirst();
+        for (CFFListIterator j= tmp; j.hasItem(); j++)
+          newResult.append (CFFactor (j.getItem().factor(),
+                                      j.getItem().exp()*i.getItem().exp()));
+      }
+      decompress (newResult, N);
+      delete [] substDegree;
+      return newResult;
+    }
+    delete [] substDegree;
+  }
+
   CanonicalForm LcF= Lc (F);
   CanonicalForm contentX= content (F, 1);
   CanonicalForm contentY= content (F, 2);
@@ -235,7 +279,7 @@ CFFList FpBiFactorize (const CanonicalForm & G ///< [in] a bivariate poly
   if (degree (pthRoot) > 0)
   {
     pthRoot= maxpthRoot (pthRoot, p, l);
-    result= FpBiFactorize (pthRoot);
+    result= FpBiFactorize (pthRoot, false);
     result.removeFirst();
     for (CFFListIterator i= result; i.hasItem(); i++)
       i.getItem()= CFFactor (N (decompress (i.getItem().factor(), M, S)),
@@ -257,7 +301,7 @@ CFFList FpBiFactorize (const CanonicalForm & G ///< [in] a bivariate poly
   }
   if (degree (A) > 0)
   {
-    resultRoot= FpBiFactorize (A);
+    resultRoot= FpBiFactorize (A, false);
     resultRoot.removeFirst();
     for (CFFListIterator i= resultRoot; i.hasItem(); i++)
       i.getItem()= CFFactor (N (decompress (i.getItem().factor(), M, S)),
@@ -277,13 +321,57 @@ CFFList FpBiFactorize (const CanonicalForm & G ///< [in] a bivariate poly
 ///         multiplicity, the first element is the leading coefficient.
 /// @sa FpBiFactorize(), FqBiFactorize()
 inline
-CFFList FqBiFactorize (const CanonicalForm & G, ///< [in] a bivariate poly
-                       const Variable & alpha   ///< [in] algebraic variable
-                      )
+CFFList
+FqBiFactorize (const CanonicalForm & G, ///< [in] a bivariate poly
+               const Variable & alpha,  ///< [in] algebraic variable
+               bool substCheck= true    ///< [in] enables substitute check
+              )
 {
   ExtensionInfo info= ExtensionInfo (alpha, false);
   CFMap N;
   CanonicalForm F= compress (G, N);
+
+  if (substCheck)
+  {
+    bool foundOne= false;
+    int * substDegree= new int [F.level()];
+    for (int i= 1; i <= F.level(); i++)
+    {
+      substDegree[i-1]= substituteCheck (F, Variable (i));
+      if (substDegree [i-1] > 1)
+      {
+        foundOne= true;
+        subst (F, F, substDegree[i-1], Variable (i));
+      }
+    }
+    if (foundOne)
+    {
+      CFFList result= FqBiFactorize (F, alpha, false);
+      CFFList newResult, tmp;
+      CanonicalForm tmp2;
+      newResult.insert (result.getFirst());
+      result.removeFirst();
+      for (CFFListIterator i= result; i.hasItem(); i++)
+      {
+        tmp2= i.getItem().factor();
+        for (int j= 1; j <= F.level(); j++)
+        {
+          if (substDegree[j-1] > 1)
+            tmp2= reverseSubst (tmp2, substDegree[j-1], Variable (j));
+        }
+        tmp= FqBiFactorize (tmp2, alpha, false);
+        tmp.removeFirst();
+        for (CFFListIterator j= tmp; j.hasItem(); j++)
+          newResult.append (CFFactor (j.getItem().factor(),
+                                      j.getItem().exp()*i.getItem().exp()));
+      }
+      decompress (newResult, N);
+      delete [] substDegree;
+      return newResult;
+    }
+    delete [] substDegree;
+  }
+
   CanonicalForm LcF= Lc (F);
   CanonicalForm contentX= content (F, 1);
   CanonicalForm contentY= content (F, 2);
@@ -318,7 +406,7 @@ CFFList FqBiFactorize (const CanonicalForm & G, ///< [in] a bivariate poly
   if (degree (pthRoot) > 0)
   {
     pthRoot= maxpthRoot (pthRoot, q, l);
-    result= FqBiFactorize (pthRoot, alpha);
+    result= FqBiFactorize (pthRoot, alpha, false);
     result.removeFirst();
     for (CFFListIterator i= result; i.hasItem(); i++)
       i.getItem()= CFFactor (N (decompress (i.getItem().factor(), M, S)),
@@ -340,7 +428,7 @@ CFFList FqBiFactorize (const CanonicalForm & G, ///< [in] a bivariate poly
   }
   if (degree (A) > 0)
   {
-    resultRoot= FqBiFactorize (A, alpha);
+    resultRoot= FqBiFactorize (A, alpha, false);
     resultRoot.removeFirst();
     for (CFFListIterator i= resultRoot; i.hasItem(); i++)
       i.getItem()= CFFactor (N (decompress (i.getItem().factor(), M, S)),
@@ -360,14 +448,58 @@ CFFList FqBiFactorize (const CanonicalForm & G, ///< [in] a bivariate poly
 ///         multiplicity, the first element is the leading coefficient.
 /// @sa FpBiFactorize(), FqBiFactorize()
 inline
-CFFList GFBiFactorize (const CanonicalForm & G ///< [in] a bivariate poly
-                      )
+CFFList
+GFBiFactorize (const CanonicalForm & G, ///< [in] a bivariate poly
+               bool substCheck= true    ///< [in] enables substitute check
+              )
 {
   ASSERT (CFFactory::gettype() == GaloisFieldDomain,
           "GF as base field expected");
   ExtensionInfo info= ExtensionInfo (getGFDegree(), gf_name, false);
   CFMap N;
   CanonicalForm F= compress (G, N);
+
+  if (substCheck)
+  {
+    bool foundOne= false;
+    int * substDegree= new int [F.level()];
+    for (int i= 1; i <= F.level(); i++)
+    {
+      substDegree[i-1]= substituteCheck (F, Variable (i));
+      if (substDegree [i-1] > 1)
+      {
+        foundOne= true;
+        subst (F, F, substDegree[i-1], Variable (i));
+      }
+    }
+    if (foundOne)
+    {
+      CFFList result= GFBiFactorize (F, false);
+      CFFList newResult, tmp;
+      CanonicalForm tmp2;
+      newResult.insert (result.getFirst());
+      result.removeFirst();
+      for (CFFListIterator i= result; i.hasItem(); i++)
+      {
+        tmp2= i.getItem().factor();
+        for (int j= 1; j <= F.level(); j++)
+        {
+          if (substDegree[j-1] > 1)
+            tmp2= reverseSubst (tmp2, substDegree[j-1], Variable (j));
+        }
+        tmp= GFBiFactorize (tmp2, false);
+        tmp.removeFirst();
+        for (CFFListIterator j= tmp; j.hasItem(); j++)
+          newResult.append (CFFactor (j.getItem().factor(),
+                                      j.getItem().exp()*i.getItem().exp()));
+      }
+      decompress (newResult, N);
+      delete [] substDegree;
+      return newResult;
+    }
+    delete [] substDegree;
+  }
+
   CanonicalForm LcF= Lc (F);
   CanonicalForm contentX= content (F, 1);
   CanonicalForm contentY= content (F, 2);
@@ -401,7 +533,7 @@ CFFList GFBiFactorize (const CanonicalForm & G ///< [in] a bivariate poly
   if (degree (pthRoot) > 0)
   {
     pthRoot= maxpthRoot (pthRoot, q, l);
-    result= GFBiFactorize (pthRoot);
+    result= GFBiFactorize (pthRoot, false);
     result.removeFirst();
     for (CFFListIterator i= result; i.hasItem(); i++)
       i.getItem()= CFFactor (N (decompress (i.getItem().factor(), M, S)),
@@ -423,7 +555,7 @@ CFFList GFBiFactorize (const CanonicalForm & G ///< [in] a bivariate poly
   }
   if (degree (A) > 0)
   {
-    resultRoot= GFBiFactorize (A);
+    resultRoot= GFBiFactorize (A, false);
     resultRoot.removeFirst();
     for (CFFListIterator i= resultRoot; i.hasItem(); i++)
       i.getItem()= CFFactor (N (decompress (i.getItem().factor(), M, S)),
diff --git a/factory/facFqFactorize.h b/factory/facFqFactorize.h
index 4e84a22..19ac77c 100644
--- a/factory/facFqFactorize.h
+++ b/factory/facFqFactorize.h
@@ -92,11 +92,59 @@ CFList GFSqrfFactorize (const CanonicalForm & F ///< [in] a multivariate poly
 ///         multiplicity, the first element is the leading coefficient.
 /// @sa FqFactorize(), GFFactorize()
 inline
-CFFList FpFactorize (const CanonicalForm& F ///< [in] a multivariate poly
+CFFList FpFactorize (const CanonicalForm& G,///< [in] a multivariate poly
+                     bool substCheck= true  ///< [in] enables substitute check
                     )
 {
-  if (getNumVars (F) == 2)
-    return FpBiFactorize (F);
+  if (getNumVars (G) == 2)
+    return FpBiFactorize (G, substCheck);
+
+  CanonicalForm F= G;
+  if (substCheck)
+  {
+    bool foundOne= false;
+    int * substDegree= new int [F.level()];
+    for (int i= 1; i <= F.level(); i++)
+    {
+      if (degree (F, i) > 0)
+      {
+        substDegree[i-1]= substituteCheck (F, Variable (i));
+        if (substDegree [i-1] > 1)
+        {
+          foundOne= true;
+          subst (F, F, substDegree[i-1], Variable (i));
+        }
+      }
+      else
+        substDegree[i-1]= -1;
+    }
+    if (foundOne)
+    {
+      CFFList result= FpFactorize (F, false);
+      CFFList newResult, tmp;
+      CanonicalForm tmp2;
+      newResult.insert (result.getFirst());
+      result.removeFirst();
+      for (CFFListIterator i= result; i.hasItem(); i++)
+      {
+        tmp2= i.getItem().factor();
+        for (int j= 1; j <= G.level(); j++)
+        {
+          if (substDegree[j-1] > 1)
+            tmp2= reverseSubst (tmp2, substDegree[j-1], Variable (j));
+        }
+        tmp= FpFactorize (tmp2, false);
+        tmp.removeFirst();
+        for (CFFListIterator j= tmp; j.hasItem(); j++)
+          newResult.append (CFFactor (j.getItem().factor(),
+                                      j.getItem().exp()*i.getItem().exp()));
+      }
+      delete [] substDegree;
+      return newResult;
+    }
+    delete [] substDegree;
+  }
+
   ExtensionInfo info= ExtensionInfo (false);
   Variable a= Variable (1);
   CanonicalForm LcF= Lc (F);
@@ -109,7 +157,7 @@ CFFList FpFactorize (const CanonicalForm& F ///< [in] a multivariate poly
   if (degree (pthRoot) > 0)
   {
     pthRoot= maxpthRoot (pthRoot, p, l);
-    result= FpFactorize (pthRoot);
+    result= FpFactorize (pthRoot, false);
     result.removeFirst();
     for (CFFListIterator i= result; i.hasItem(); i++)
       i.getItem()= CFFactor(i.getItem().factor(),i.getItem().exp()*ipower(p,l));
@@ -124,7 +172,7 @@ CFFList FpFactorize (const CanonicalForm& F ///< [in] a multivariate poly
   }
   if (degree (A) > 0)
   {
-    resultRoot= FpFactorize (A);
+    resultRoot= FpFactorize (A, false);
     resultRoot.removeFirst();
     result= Union (result, resultRoot);
   }
@@ -138,12 +186,60 @@ CFFList FpFactorize (const CanonicalForm& F ///< [in] a multivariate poly
 ///         multiplicity, the first element is the leading coefficient.
 /// @sa FpFactorize(), GFFactorize()
 inline
-CFFList FqFactorize (const CanonicalForm& F, ///< [in] a multivariate poly
-                     const Variable& alpha   ///< [in] algebraic variable
+CFFList FqFactorize (const CanonicalForm& G, ///< [in] a multivariate poly
+                     const Variable& alpha,  ///< [in] algebraic variable
+                     bool substCheck= true   ///< [in] enables substitute check
                     )
 {
-  if (getNumVars (F) == 2)
-    return FqBiFactorize (F, alpha);
+  if (getNumVars (G) == 2)
+    return FqBiFactorize (G, alpha, substCheck);
+
+  CanonicalForm F= G;
+  if (substCheck)
+  {
+    bool foundOne= false;
+    int * substDegree= new int [F.level()];
+    for (int i= 1; i <= F.level(); i++)
+    {
+      if (degree (F, i) > 0)
+      {
+        substDegree[i-1]= substituteCheck (F, Variable (i));
+        if (substDegree [i-1] > 1)
+        {
+          foundOne= true;
+          subst (F, F, substDegree[i-1], Variable (i));
+        }
+      }
+      else
+        substDegree[i-1]= -1;
+    }
+    if (foundOne)
+    {
+      CFFList result= FqFactorize (F, alpha, false);
+      CFFList newResult, tmp;
+      CanonicalForm tmp2;
+      newResult.insert (result.getFirst());
+      result.removeFirst();
+      for (CFFListIterator i= result; i.hasItem(); i++)
+      {
+        tmp2= i.getItem().factor();
+        for (int j= 1; j <= G.level(); j++)
+        {
+          if (substDegree[j-1] > 1)
+            tmp2= reverseSubst (tmp2, substDegree[j-1], Variable (j));
+        }
+        tmp= FqFactorize (tmp2, alpha, false);
+        tmp.removeFirst();
+        for (CFFListIterator j= tmp; j.hasItem(); j++)
+          newResult.append (CFFactor (j.getItem().factor(),
+                                      j.getItem().exp()*i.getItem().exp()));
+      }
+      delete [] substDegree;
+      return newResult;
+    }
+    delete [] substDegree;
+  }
+
   ExtensionInfo info= ExtensionInfo (alpha, false);
   CanonicalForm LcF= Lc (F);
   CanonicalForm pthRoot, A;
@@ -156,7 +252,7 @@ CFFList FqFactorize (const CanonicalForm& F, ///< [in] a multivariate poly
   if (degree (pthRoot) > 0)
   {
     pthRoot= maxpthRoot (pthRoot, q, l);
-    result= FqFactorize (pthRoot, alpha);
+    result= FqFactorize (pthRoot, alpha, false);
     result.removeFirst();
     for (CFFListIterator i= result; i.hasItem(); i++)
       i.getItem()= CFFactor(i.getItem().factor(),i.getItem().exp()*ipower(p,l));
@@ -171,7 +267,7 @@ CFFList FqFactorize (const CanonicalForm& F, ///< [in] a multivariate poly
   }
   if (degree (A) > 0)
   {
-    resultRoot= FqFactorize (A, alpha);
+    resultRoot= FqFactorize (A, alpha, false);
     resultRoot.removeFirst();
     result= Union (result, resultRoot);
   }
@@ -185,13 +281,61 @@ CFFList FqFactorize (const CanonicalForm& F, ///< [in] a multivariate poly
 ///         multiplicity, the first element is the leading coefficient.
 /// @sa FpFactorize(), FqFactorize()
 inline
-CFFList GFFactorize (const CanonicalForm& F ///< [in] a multivariate poly
+CFFList GFFactorize (const CanonicalForm& G, ///< [in] a multivariate poly
+                     bool substCheck= true   ///< [in] enables substitute check
                     )
 {
   ASSERT (CFFactory::gettype() == GaloisFieldDomain,
           "GF as base field expected");
-  if (getNumVars (F) == 2)
-    return GFBiFactorize (F);
+  if (getNumVars (G) == 2)
+    return GFBiFactorize (G, substCheck);
+
+  CanonicalForm F= G;
+  if (substCheck)
+  {
+    bool foundOne= false;
+    int * substDegree= new int [F.level()];
+    for (int i= 1; i <= F.level(); i++)
+    {
+      if (degree (F, i) > 0)
+      {
+        substDegree[i-1]= substituteCheck (F, Variable (i));
+        if (substDegree [i-1] > 1)
+        {
+          foundOne= true;
+          subst (F, F, substDegree[i-1], Variable (i));
+        }
+      }
+      else
+        substDegree[i-1]= -1;
+    }
+    if (foundOne)
+    {
+      CFFList result= GFFactorize (F, false);
+      CFFList newResult, tmp;
+      CanonicalForm tmp2;
+      newResult.insert (result.getFirst());
+      result.removeFirst();
+      for (CFFListIterator i= result; i.hasItem(); i++)
+      {
+        tmp2= i.getItem().factor();
+        for (int j= 1; j <= G.level(); j++)
+        {
+          if (substDegree[j-1] > 1)
+            tmp2= reverseSubst (tmp2, substDegree[j-1], Variable (j));
+        }
+        tmp= GFFactorize (tmp2, false);
+        tmp.removeFirst();
+        for (CFFListIterator j= tmp; j.hasItem(); j++)
+          newResult.append (CFFactor (j.getItem().factor(),
+                                      j.getItem().exp()*i.getItem().exp()));
+      }
+      delete [] substDegree;
+      return newResult;
+    }
+    delete [] substDegree;
+  }
+
   Variable a= Variable (1);
   ExtensionInfo info= ExtensionInfo (getGFDegree(), gf_name, false);
   CanonicalForm LcF= Lc (F);
@@ -205,7 +349,7 @@ CFFList GFFactorize (const CanonicalForm& F ///< [in] a multivariate poly
   if (degree (pthRoot) > 0)
   {
     pthRoot= maxpthRoot (pthRoot, q, l);
-    result= GFFactorize (pthRoot);
+    result= GFFactorize (pthRoot, false);
     result.removeFirst();
     for (CFFListIterator i= result; i.hasItem(); i++)
       i.getItem()= CFFactor(i.getItem().factor(),i.getItem().exp()*ipower(p,l));
@@ -220,7 +364,7 @@ CFFList GFFactorize (const CanonicalForm& F ///< [in] a multivariate poly
   }
   if (degree (A) > 0)
   {
-    resultRoot= GFFactorize (A);
+    resultRoot= GFFactorize (A, false);
     resultRoot.removeFirst();
     result= Union (result, resultRoot);
   }

-- 
an open source computer algebra system



More information about the debian-science-commits mailing list