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

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


The following commit has been merged in the cleanedupstream branch:
commit b33fad824ac3a9fc560ae33def768577fa4e260c
Author: Martin Lee <martinlee84 at web.de>
Date:   Thu Mar 22 14:12:44 2012 +0100

    chg: avoid adding of constant factors to squarefree factorization
    chg: divide out contents first in squarefree factorization

diff --git a/factory/facFqSquarefree.cc b/factory/facFqSquarefree.cc
index 91b2efe..a6258a1 100644
--- a/factory/facFqSquarefree.cc
+++ b/factory/facFqSquarefree.cc
@@ -84,7 +84,7 @@ sqrfPosDer (const CanonicalForm & F, const Variable & x,
   while (j < p - 1 && degree(u) >= 0)
   {
     g= gcd (w, u);
-    if (degree(g) > 0)
+    if (!g.inCoeffDomain())
       result.append (CFFactor (g, j));
     w= w/g;
     c= c/w;
@@ -92,7 +92,7 @@ sqrfPosDer (const CanonicalForm & F, const Variable & x,
     u= v - deriv (w, x);
     j++;
   }
-  if (degree(w) > 0)
+  if (!w.inCoeffDomain())
     result.append (CFFactor (w, j));
   return result;
 }
@@ -129,7 +129,7 @@ squarefreeFactorization (const CanonicalForm & F, const Variable & alpha)
       {
         found= false;
         CFFListIterator k= tmp2;
-        if (!k.hasItem()) tmp2.append (j.getItem());
+        if (!k.hasItem() && !j.getItem().factor().inCoeffDomain()) tmp2.append (j.getItem());
         else
         {
           for (; k.hasItem(); k++)
@@ -141,7 +141,7 @@ squarefreeFactorization (const CanonicalForm & F, const Variable & alpha)
               found= true;
             }
           }
-          if (found == false)
+          if (found == false && !j.getItem().factor().inCoeffDomain())
             tmp2.append(j.getItem());
         }
       }
@@ -169,7 +169,7 @@ squarefreeFactorization (const CanonicalForm & F, const Variable & alpha)
       tmp= gcd (i.getItem().factor(), j.getItem().factor());
       i.getItem()= CFFactor (i.getItem().factor()/tmp, i.getItem().exp());
       j.getItem()= CFFactor (j.getItem().factor()/tmp, j.getItem().exp());
-      if (degree (tmp) > 0 && tmp.level() > 0)
+      if (!tmp.inCoeffDomain())
       {
         tmp= M (tmp);
         result.append (CFFactor (tmp/Lc(tmp),
@@ -179,7 +179,7 @@ squarefreeFactorization (const CanonicalForm & F, const Variable & alpha)
   }
   for (CFFListIterator i= tmp2; i.hasItem(); i++)
   {
-    if (degree (i.getItem().factor()) > 0 && i.getItem().factor().level() >= 0)
+    if (!i.getItem().factor().inCoeffDomain())
     {
       tmp= M (i.getItem().factor());
       result.append (CFFactor (tmp/Lc(tmp), i.getItem().exp()));
@@ -187,7 +187,7 @@ squarefreeFactorization (const CanonicalForm & F, const Variable & alpha)
   }
   for (CFFListIterator j= tmp1; j.hasItem(); j++)
   {
-    if (degree (j.getItem().factor()) > 0 && j.getItem().factor().level() >= 0)
+    if (!j.getItem().factor().inCoeffDomain())
     {
       tmp= M (j.getItem().factor());
       result.append (CFFactor (tmp/Lc(tmp), j.getItem().exp()*p));
diff --git a/factory/facFqSquarefree.h b/factory/facFqSquarefree.h
index 64f8190..7d425b0 100644
--- a/factory/facFqSquarefree.h
+++ b/factory/facFqSquarefree.h
@@ -15,7 +15,7 @@
 #define FAC_FQ_SQUAREFREE_H
 
 #include "assert.h"
-
+#include "fac_sqrfree.h"
 
 /// squarefree factorization over a finite field
 /// @a return a list of squarefree factors with multiplicity
@@ -33,11 +33,36 @@ squarefreeFactorization
 ///
 /// @return a list of squarefree factors with multiplicity
 inline
-CFFList FpSqrf (const CanonicalForm& F ///< [in] a poly
+CFFList FpSqrf (const CanonicalForm& F, ///< [in] a poly
+                bool sort= true         ///< [in] sort factors by exponent?
                )
 {
   Variable a= 1;
-  CFFList result= squarefreeFactorization (F, a);
+  int n= F.level();
+  CanonicalForm cont, bufF= F;
+  CFFList bufResult;
+
+  CFFList result;
+  for (int i= n; i >= 1; i++)
+  {
+    cont= content (bufF, i);
+    bufResult= squarefreeFactorization (cont, a);
+    if (bufResult.getFirst().factor().inCoeffDomain())
+      bufResult.removeFirst();
+    result= Union (result, bufResult);
+    bufF /= cont;
+    if (bufF.inCoeffDomain())
+      break;
+  }
+  if (!bufF.inCoeffDomain())
+  {
+    bufResult= squarefreeFactorization (bufF, a);
+    if (bufResult.getFirst().factor().inCoeffDomain())
+      bufResult.removeFirst();
+    result= Union (result, bufResult);
+  }
+  if (sort)
+    result= sortCFFList (result);
   result.insert (CFFactor (Lc(F), 1));
   return result;
 }
@@ -48,10 +73,35 @@ CFFList FpSqrf (const CanonicalForm& F ///< [in] a poly
 /// @return a list of squarefree factors with multiplicity
 inline
 CFFList FqSqrf (const CanonicalForm& F, ///< [in] a poly
-                const Variable& alpha   ///< [in] algebraic variable
+                const Variable& alpha,  ///< [in] algebraic variable
+                bool sort= true         ///< [in] sort factors by exponent?
                )
 {
-  CFFList result= squarefreeFactorization (F, alpha);
+  int n= F.level();
+  CanonicalForm cont, bufF= F;
+  CFFList bufResult;
+
+  CFFList result;
+  for (int i= n; i >= 1; i++)
+  {
+    cont= content (bufF, i);
+    bufResult= squarefreeFactorization (cont, alpha);
+    if (bufResult.getFirst().factor().inCoeffDomain())
+      bufResult.removeFirst();
+    result= Union (result, bufResult);
+    bufF /= cont;
+    if (bufF.inCoeffDomain())
+      break;
+  }
+  if (!bufF.inCoeffDomain())
+  {
+    bufResult= squarefreeFactorization (bufF, alpha);
+    if (bufResult.getFirst().factor().inCoeffDomain())
+      bufResult.removeFirst();
+    result= Union (result, bufResult);
+  }
+  if (sort)
+    result= sortCFFList (result);
   result.insert (CFFactor (Lc(F), 1));
   return result;
 }
@@ -61,15 +111,13 @@ CFFList FqSqrf (const CanonicalForm& F, ///< [in] a poly
 ///
 /// @return a list of squarefree factors with multiplicity
 inline
-CFFList GFSqrf (const CanonicalForm& F ///< [in] a poly
+CFFList GFSqrf (const CanonicalForm& F, ///< [in] a poly
+                bool sort= true         ///< [in] sort factors by exponent?
                )
 {
   ASSERT (CFFactory::gettype() == GaloisFieldDomain,
           "GF as base field expected");
-  Variable a= 1;
-  CFFList result= squarefreeFactorization (F, a);
-  result.insert (CFFactor (Lc(F), 1));
-  return result;
+  return FpSqrf (F, sort);
 }
 
 /// squarefree part of @a F/g, where g is the product of those squarefree

-- 
an open source computer algebra system



More information about the debian-science-commits mailing list