[SCM] an open source computer algebra system branch, cleanedupstream, updated. 6125e540ca6d66c307958938a9d53b245507c323
Bernhard R. Link
brlink at debian.org
Tue Apr 24 15:53:36 UTC 2012
The following commit has been merged in the cleanedupstream branch:
commit c9ea733ec26b5d146c8d6dff1a66c5cc72599d2a
Author: Yue Ren <ren at mathematik.uni-kl.de>
Date: Thu Feb 16 18:21:25 2012 +0100
NEW: scalingPolytope, overloaded '*'
scalingPolytope scales a polytope by an integer factor,
can be used through overloaded '*' if polymake is loaded.
diff --git a/callgfanlib/bbpolytope.cc b/callgfanlib/bbpolytope.cc
index f19f00d..12b9cde 100644
--- a/callgfanlib/bbpolytope.cc
+++ b/callgfanlib/bbpolytope.cc
@@ -493,6 +493,33 @@ BOOLEAN newtonPolytope(leftv res, leftv args)
return TRUE;
}
+BOOLEAN scalePolytope(leftv res, leftv args)
+{
+ leftv u = args;
+ if ((u != NULL) && (u->Typ() == INT_CMD))
+ {
+ leftv v = u->next;
+ if ((v != NULL) && (v->Typ() == polytopeID))
+ {
+
+ int* n = (int*) u->Data();
+ gfan::ZCone* zp = (gfan::ZCone*) v->Data();
+ gfan::ZMatrix zm = zp->extremeRays();
+ for (int i=1; i<zm.getHeight(); i++)
+ for (int j=1; j<zm.getWidth(); j++)
+ zm[i][j]+=1;
+ gfan::ZCone* zq = new gfan::ZCone();
+ *zq = gfan::ZCone::givenByRays(zm,gfan::ZMatrix(0, zm.getWidth()));
+ res->rtyp = polytopeID;
+ res->data = (char*) zq;
+ return FALSE;
+ }
+ }
+ WerrorS("scalePolytope: unexpected parameters");
+ return TRUE;
+
+}
+
void bbpolytope_setup()
{
blackbox *b=(blackbox*)omAlloc0(sizeof(blackbox));
@@ -511,6 +538,7 @@ void bbpolytope_setup()
iiAddCproc("","quickPolytopeViaNormals",FALSE,quickPolytopeViaNormals);
iiAddCproc("","getVertices",FALSE,getVertices);
iiAddCproc("","newtonPolytope",FALSE,newtonPolytope);
+ iiAddCproc("","scalePolytope",FALSE,scalePolytope);
/********************************************************/
/* the following functions are implemented in bbcone.cc */
// iiAddCproc("","getAmbientDimension",FALSE,getAmbientDimension);
diff --git a/callpolymake/polymake.cc b/callpolymake/polymake.cc
index 328efbb..645e647 100755
--- a/callpolymake/polymake.cc
+++ b/callpolymake/polymake.cc
@@ -317,16 +317,16 @@ polymake::perl::Object ZFan2PmFan (gfan::ZFan* zf)
/*******************************************************/
-static BOOLEAN bbpolytope_Op2(int op, leftv res, leftv p, leftv q)
+static BOOLEAN bbpolytope_Op2(int op, leftv res, leftv i1, leftv i2)
{
- gfan::ZCone* zp = (gfan::ZCone*) p->Data();
+ gfan::ZCone* zp = (gfan::ZCone*) i1->Data();
switch(op)
{
case '+':
{
- if (q->Typ()==polytopeID)
+ if (i2->Typ()==polytopeID)
{
- gfan::ZCone* zq = (gfan::ZCone*) q->Data();
+ gfan::ZCone* zq = (gfan::ZCone*) i2->Data();
gfan::ZCone* ms;
try
{
@@ -347,10 +347,27 @@ static BOOLEAN bbpolytope_Op2(int op, leftv res, leftv p, leftv q)
}
return TRUE;
}
+ case '*':
+ {
+ if (i2->Typ()==INT_CMD)
+ {
+ int* s = (int*) i2->Data();
+ gfan::ZMatrix zm = zp->extremeRays();
+ for (int i=1; i<zm.getHeight(); i++)
+ for (int j=1; j<zm.getWidth(); j++)
+ zm[i][j]+=1;
+ gfan::ZCone* zs = new gfan::ZCone();
+ *zs = gfan::ZCone::givenByRays(zm,gfan::ZMatrix(0, zm.getWidth()));
+ res->rtyp = polytopeID;
+ res->data = (void*) zs;
+ return FALSE;
+ }
+ return TRUE;
+ }
default:
- return blackboxDefaultOp2(op,res,p,q);
+ return blackboxDefaultOp2(op,res,i1,i2);
}
- return blackboxDefaultOp2(op,res,p,q);
+ return blackboxDefaultOp2(op,res,i1,i2);
}
--
an open source computer algebra system
More information about the debian-science-commits
mailing list