[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 0df91b643e22e8fbda01f9d2781c16ca3d4f0813
Author: Martin Lee <martinlee84 at web.de>
Date:   Thu Jan 5 13:03:48 2012 +0100

    chg/fix: remove redundant points from polygon
    add: new function to obtain the slopes of the right edges of a polygon

diff --git a/factory/cfNewtonPolygon.cc b/factory/cfNewtonPolygon.cc
index 788a115..b41bc6d 100644
--- a/factory/cfNewtonPolygon.cc
+++ b/factory/cfNewtonPolygon.cc
@@ -141,7 +141,7 @@ int grahamScan (int** points, int sizePoints)
     k++;
     i++;
   }
-  if (i + 1 < sizePoints)
+  if (i + 1 <= sizePoints || i == sizePoints)
   {
     int relArea=
     (points [i-2][0] - points [i-1][0])*(points [0][1] - points [i-1][1])-
@@ -677,3 +677,58 @@ decompress (const CanonicalForm& F, const mat_ZZ& inverseM, const vec_ZZ& A)
   return result/Lc (result); //normalize
 }
 #endif
+
+//assumes the input is a Newton polygon of a bivariate polynomial which is
+//primitive wrt. x and y, i.e. there is at least one point of the polygon lying
+//on the x-axis and one lying on the y-axis
+int* getRightSide (int** polygon, int sizeOfPolygon, int& sizeOfOutput)
+{
+  int maxY= polygon [0][0];
+  int indexY= 0;
+  for (int i= 1; i < sizeOfPolygon; i++)
+  {
+    if (maxY < polygon [i][0])
+    {
+      maxY= polygon [i][0];
+      indexY= i;
+    }
+    else if (maxY == polygon [i][0])
+    {
+      if (polygon [indexY][1] < polygon[i][1])
+        indexY= i;
+    }
+    if (maxY > polygon [i][0])
+      break;
+  }
+
+  int count= -1;
+  for (int i= indexY; i < sizeOfPolygon; i++)
+  {
+    if (polygon[i][0] == 0)
+    {
+      count= i - indexY;
+      break;
+    }
+  }
+
+  int * result;
+  int index= 0;
+  if (count < 0)
+  {
+    result= new int [sizeOfPolygon - indexY];
+    sizeOfOutput= sizeOfPolygon - indexY;
+    count= sizeOfPolygon - indexY - 1;
+    result [0]= polygon[sizeOfPolygon - 1][0] - polygon [0] [0];
+    index= 1;
+  }
+  else
+  {
+    sizeOfOutput= count;
+    result= new int [count];
+  }
+
+  for (int i= indexY + count; i > indexY; i--, index++)
+    result [index]= polygon [i - 1] [0] - polygon [i] [0];
+
+  return result;
+}
diff --git a/factory/cfNewtonPolygon.h b/factory/cfNewtonPolygon.h
index 8499abe..449b0ba 100644
--- a/factory/cfNewtonPolygon.h
+++ b/factory/cfNewtonPolygon.h
@@ -45,6 +45,16 @@ bool isInPolygon (int ** points, ///< [in] an array of points in the
                   int* point     ///< [in] a point in the plane
                  );
 
+/// get the y-direction slopes of all edges with positive slope in y-direction
+/// of a convex polygon with at least one point of the polygon lying on the
+/// x-axis and one lying on the y-axis
+///
+/// @return an array containing the slopes as described above
+int* getRightSide (int** polygon,     ///<[in] vertices of a polygon
+                   int sizeOfPolygon, ///<[in] number of vertices
+                   int& sizeOfOutput  ///<[in,out] size of the output
+                  );
+
 #ifdef HAVE_NTL
 /// Algorithm 5 as described in Convex-Dense Bivariate Polynomial Factorization
 /// by Berthomieu, Lecerf

-- 
an open source computer algebra system



More information about the debian-science-commits mailing list