[SCM] an open source computer algebra system branch, cleanedupstream, updated. 6125e540ca6d66c307958938a9d53b245507c323
Bernhard R. Link
brlink at debian.org
Tue Apr 24 15:53:01 UTC 2012
The following commit has been merged in the cleanedupstream branch:
commit fe6a3200cb65d69770a8081870fbf66ef7aa6964
Author: Yue Ren <ren at mathematik.uni-kl.de>
Date: Thu Feb 9 17:30:51 2012 +0100
added newtonPolytope
diff --git a/Singular/bbcone.cc b/Singular/bbcone.cc
index 138b752..b2e9826 100644
--- a/Singular/bbcone.cc
+++ b/Singular/bbcone.cc
@@ -68,6 +68,16 @@ gfan::ZMatrix intmat2ZMatrix(const intvec* iMat)
return ret;
}
+gfan::ZVector intStar2ZVector(const int d, const int* i)
+{
+ gfan::ZVector zv(d);
+ for(int j=0; j<d; j++)
+ {
+ zv[j]=i[j];
+ }
+ return zv;
+}
+
/* expects iMat to have just one row */
gfan::ZVector intvec2ZVector(const intvec* iVec)
{
diff --git a/Singular/bbpolytope.cc b/Singular/bbpolytope.cc
index 8d60edc..7149d25 100644
--- a/Singular/bbpolytope.cc
+++ b/Singular/bbpolytope.cc
@@ -12,6 +12,8 @@
#include <kernel/bbcone.h>
#include <Singular/ipshell.h>
#include <kernel/intvec.h>
+#include <kernel/ring.h>
+#include <kernel/polys.h>
#include <sstream>
@@ -442,6 +444,61 @@ int getDimension(gfan::ZCone* zc)
return zc->dimension()-1;
}
+// intvec* IntStar2IntvecStar(int d, const int* i)
+// {
+// assume(i != NULL);
+// intvec* iv = new intvec(1,d);
+// for(int j=1; i<=d; i++)
+// {
+// IMATELEM(*iv, 1, i)=i[j]
+// }
+// return iv;
+// }
+
+gfan::ZVector intStar2ZVectorWithLeadingOne(const int d, const int* i)
+{
+ gfan::ZVector zv(d+1);
+ zv[0]=1;
+ for(int j=1; j<=d; j++)
+ {
+ zv[j]=i[j];
+ }
+ return zv;
+}
+
+BOOLEAN newtonPolytope(leftv res, leftv args)
+{
+ leftv u = args;
+ if ((u != NULL) && (u->Typ() == POLY_CMD))
+ {
+ poly p = (poly)u->Data();
+ int r = rVar(currRing);
+ gfan::ZMatrix zm(1,r+1);
+ int *leadexpv = (int*)omAlloc((r+1)*sizeof(int));
+ pGetExpV(p,leadexpv);
+ gfan::ZVector zv = intStar2ZVectorWithLeadingOne(r, leadexpv);
+ zm.appendRow(zv);
+ poly pNextTerm = p;
+ while(pNext(pNextTerm)!=NULL)
+ {
+ pNextTerm=pNext(pNextTerm);
+ int *tailexpv=(int*)omAlloc((r+1)*sizeof(int));
+ pGetExpV(pNextTerm,tailexpv);
+ gfan::ZVector zv = intStar2ZVectorWithLeadingOne(r, tailexpv);
+ zm.appendRow(zv);
+ omFree(tailexpv);
+ }
+ omFree(leadexpv);
+ gfan::ZCone* zc = new gfan::ZCone();
+ *zc = gfan::ZCone::givenByRays(zm, gfan::ZMatrix(0, zm.getWidth()));
+ res->rtyp = polytopeID;
+ res->data = (char*) zc;
+ return FALSE;
+ }
+ WerrorS("newtonPolytope: unexpected parameters");
+ return TRUE;
+}
+
void bbpolytope_setup()
{
blackbox *b=(blackbox*)omAlloc0(sizeof(blackbox));
@@ -459,6 +516,7 @@ void bbpolytope_setup()
iiAddCproc("","quickPolytopeViaVertices",FALSE,quickPolytopeViaVertices);
iiAddCproc("","quickPolytopeViaNormals",FALSE,quickPolytopeViaNormals);
iiAddCproc("","getVertices",FALSE,getVertices);
+ iiAddCproc("","newtonPolytope",FALSE,newtonPolytope);
/********************************************************/
/* the following functions are implemented in bbcone.cc */
// iiAddCproc("","getAmbientDimension",FALSE,getAmbientDimension);
diff --git a/kernel/bbcone.h b/kernel/bbcone.h
index 84bb001..c3e67fc 100755
--- a/kernel/bbcone.h
+++ b/kernel/bbcone.h
@@ -10,6 +10,7 @@ void bbcone_setup();
intvec* zVector2Intvec(const gfan::ZVector zv);
intvec* zMatrix2Intvec(const gfan::ZMatrix zm);
gfan::ZMatrix intmat2ZMatrix(const intvec* iMat);
+gfan::ZVector intStar2ZVector(const int d, const int* i);
gfan::ZVector intvec2ZVector(const intvec* iVec);
std::string toString(gfan::ZMatrix const &m, char *tab=0);
int integerToInt(gfan::Integer const &V, bool &ok);
--
an open source computer algebra system
More information about the debian-science-commits
mailing list