[SCM] an open source computer algebra system branch, cleanedupstream, updated. 6125e540ca6d66c307958938a9d53b245507c323
Bernhard R. Link
brlink at debian.org
Tue Apr 24 15:53:35 UTC 2012
The following commit has been merged in the cleanedupstream branch:
commit 46cd85fe41bbe71f2fd44758cfd5edd1feb4e6b0
Author: Yue Ren <ren at mathematik.uni-kl.de>
Date: Thu Feb 16 16:37:28 2012 +0100
NEW: overloading '+' for polytopes
polytope + polytope now possible, in case polymake.so is loaded
(as of now, minkowski sum is not implmented in gfanlib yet, not sure whether that will ever be planned)
diff --git a/callgfanlib/Makefile b/callgfanlib/Makefile
index 3542982..6312633 100755
--- a/callgfanlib/Makefile
+++ b/callgfanlib/Makefile
@@ -6,7 +6,8 @@ gfanlib:
g++ -DOM_DEBUG -DNDEBUG -o bbpolytope.o -fpic -I../ -c -g bbpolytope.cc
g++ -DOM_DEBUG -DNDEBUG -o gfanlib.o -fpic -I../ -c -g gfanlib.cc
g++ -shared -o gfanlib.so bbcone.o bbfan.o bbpolytope.o gfanlib.o ../gfanlib/*.o -L/usr/local/lib -lcddgmp -lgmpxx
+ cp gfanlib.so ../Singular/gfanlib.so
clean:
rm *.so *.o
-
+ rm ../Singular/gfanlib.so
diff --git a/callpolymake/Makefile b/callpolymake/Makefile
index e67971d..5af062d 100755
--- a/callpolymake/Makefile
+++ b/callpolymake/Makefile
@@ -11,7 +11,9 @@ all: polymake
polymake:
g++ -o polymake.o -I. ${PM_INC} ${PM_CFLAGS} ${CFLAGS} ${LDFLAGS} -I../ -c -g polymake.cc
g++ -shared -o polymake.so ${PM_LDFLAGS} ${LDFLAGS} -g polymake.o ${PM_LIBS} -lgmpxx -lgmp
+ cp polymake.so ../Singular/polymake.so
clean:
rm *.so *.o
+ rm ../Singular/polymake.so
diff --git a/callpolymake/polymake.cc b/callpolymake/polymake.cc
index ca3a902..328efbb 100755
--- a/callpolymake/polymake.cc
+++ b/callpolymake/polymake.cc
@@ -20,6 +20,7 @@
#include <callgfanlib/bbfan.h>
#include <callgfanlib/bbpolytope.h>
+#include <Singular/blackbox.h>
#include <Singular/ipshell.h>
#include <Singular/subexpr.h>
@@ -312,6 +313,47 @@ polymake::perl::Object ZFan2PmFan (gfan::ZFan* zf)
return pf;
}
+
+/*******************************************************/
+
+
+static BOOLEAN bbpolytope_Op2(int op, leftv res, leftv p, leftv q)
+{
+ gfan::ZCone* zp = (gfan::ZCone*) p->Data();
+ switch(op)
+ {
+ case '+':
+ {
+ if (q->Typ()==polytopeID)
+ {
+ gfan::ZCone* zq = (gfan::ZCone*) q->Data();
+ gfan::ZCone* ms;
+ try
+ {
+ polymake::perl::Object pp = ZPolytope2PmPolytope(zp);
+ polymake::perl::Object pq = ZPolytope2PmPolytope(zq);
+ polymake::perl::Object pms;
+ CallPolymakeFunction("minkowski_sum", pp, pq) >> pms;
+ ms = new gfan::ZCone(PmPolytope2ZPolytope(&pms));
+ }
+ catch (const std::exception& ex)
+ {
+ std::cerr << "ERROR: " << ex.what() << endl;
+ return TRUE;
+ }
+ res->rtyp = polytopeID;
+ res->data = (void*) ms;
+ return FALSE;
+ }
+ return TRUE;
+ }
+ default:
+ return blackboxDefaultOp2(op,res,p,q);
+ }
+ return blackboxDefaultOp2(op,res,p,q);
+}
+
+
/* Functions for using Polymake in Singular */
// BOOLEAN cube(leftv res, leftv args)
@@ -1668,4 +1710,7 @@ extern "C" int mod_init(void* polymakesingular)
iiAddCproc("","testingvisuals",FALSE,testingvisuals);
iiAddCproc("","testingstrings",FALSE,testingstrings);
+ blackbox* b=getBlackboxStuff(polytopeID);
+ b->blackbox_Op2=bbpolytope_Op2;
+
}
--
an open source computer algebra system
More information about the debian-science-commits
mailing list