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

Bernhard R. Link brlink at debian.org
Tue Apr 24 15:53:39 UTC 2012


The following commit has been merged in the cleanedupstream branch:
commit 2f17c3906111450fd9abd0a3ee638c43cf489e57
Author: Yue Ren <ren at mathematik.uni-kl.de>
Date:   Fri Feb 24 16:15:33 2012 +0100

    NEW: shortcuts for equating, intersecting and uniting cones and polytopes
    
    equating: c==d;
    intersecting: c&d;
    uniting: c|d;

diff --git a/callgfanlib/bbcone.cc b/callgfanlib/bbcone.cc
index 20f584e..987a231 100644
--- a/callgfanlib/bbcone.cc
+++ b/callgfanlib/bbcone.cc
@@ -206,6 +206,77 @@ void * bbcone_Copy(blackbox*b, void *d)
   return newZc;
 }
 
+static BOOLEAN bbcone_Op2(int op, leftv res, leftv i1, leftv i2)
+{
+  gfan::ZCone* zp = (gfan::ZCone*) i1->Data();
+  switch(op)
+  {
+    case '&':
+    {  
+      if (i2->Typ()==coneID)
+      {
+        gfan::ZCone* zq = (gfan::ZCone*) i2->Data();
+        int d1 = zp->ambientDimension();
+        int d2 = zq->ambientDimension();
+        if (d1 != d2)
+        {
+          Werror("mismatching ambient dimensions");
+          return TRUE;
+        }
+        gfan::ZCone* zs = new gfan::ZCone();
+        *zs = gfan::intersection(*zp, *zq);
+        zs->canonicalize();
+        res->rtyp = coneID;
+        res->data = (void*) zs;
+        return FALSE;
+      }
+      return blackboxDefaultOp2(op,res,i1,i2);
+    }
+    case '|':
+    {
+      if(i2->Typ()==coneID)
+      {
+        gfan::ZCone* zq = (gfan::ZCone*) i2->Data();
+        int d1 = zp->ambientDimension();
+        int d2 = zq->ambientDimension();
+        if (d1 != d2)
+        {
+          Werror("mismatching ambient dimensions");
+          return TRUE;
+        }
+        gfan::ZMatrix rays = zp->extremeRays();
+        rays.append(zq->extremeRays());
+        gfan::ZMatrix lineality = zp->generatorsOfLinealitySpace();
+        lineality.append(zq->generatorsOfLinealitySpace());
+        gfan::ZCone* zs = new gfan::ZCone();
+        *zs = gfan::ZCone::givenByRays(rays,lineality);
+        zs->canonicalize();
+        res->rtyp = coneID;
+        res->data = (void*) zs;
+        return FALSE;
+      }
+    return blackboxDefaultOp2(op,res,i1,i2);
+    }
+    case EQUAL_EQUAL:
+    {
+      if(i2->Typ()==coneID)
+      {
+        gfan::ZCone* zq = (gfan::ZCone*) i2->Data();
+        zp->canonicalize();
+        zq->canonicalize();
+        bool b = !((*zp)!=(*zq));
+        res->rtyp = INT_CMD;
+        res->data = (char*) (int) b;
+        return FALSE;
+      }
+      return blackboxDefaultOp2(op,res,i1,i2);
+    }
+    default:
+      return blackboxDefaultOp2(op,res,i1,i2);
+  }
+  return blackboxDefaultOp2(op,res,i1,i2);
+}
+
 static BOOLEAN jjCONERAYS1(leftv res, leftv v)
 {
   /* method for generating a cone object from half-lines
@@ -1236,6 +1307,7 @@ void bbcone_setup()
   b->blackbox_Init=bbcone_Init;
   b->blackbox_Copy=bbcone_Copy;
   b->blackbox_Assign=bbcone_Assign;
+  b->blackbox_Op2=bbcone_Op2;
   iiAddCproc("","canonicalizeCone",FALSE,canonicalizeCone);
   iiAddCproc("","coneViaRays",FALSE,coneViaRays);
   iiAddCproc("","coneViaNormals",FALSE,coneViaNormals);
diff --git a/callpolymake/polymake.cc b/callpolymake/polymake.cc
index 1fe1a3a..35d6102 100755
--- a/callpolymake/polymake.cc
+++ b/callpolymake/polymake.cc
@@ -23,6 +23,7 @@
 #include <Singular/blackbox.h>
 #include <Singular/ipshell.h>
 #include <Singular/subexpr.h>
+#include <Singular/tok.h>
 
 using namespace polymake;
 
@@ -345,7 +346,7 @@ static BOOLEAN bbpolytope_Op2(int op, leftv res, leftv i1, leftv i2)
         res->data = (void*) ms;
         return FALSE;
       }
-      return TRUE;
+      return blackboxDefaultOp2(op,res,i1,i2);
     }
     case '*':
     {
@@ -362,7 +363,67 @@ static BOOLEAN bbpolytope_Op2(int op, leftv res, leftv i1, leftv i2)
         res->data = (void*) zs;
         return FALSE;
       }
-      return TRUE;
+      return blackboxDefaultOp2(op,res,i1,i2);
+    }
+    case '&':
+    {  
+      if (i2->Typ()==polytopeID)
+      {
+        gfan::ZCone* zq = (gfan::ZCone*) i2->Data();
+        int d1 = zp->ambientDimension();
+        int d2 = zq->ambientDimension();
+        if (d1 != d2)
+        {
+          Werror("mismatching ambient dimensions");
+          return TRUE;
+        }
+        gfan::ZCone* zs = new gfan::ZCone();
+        *zs = gfan::intersection(*zp, *zq);
+        zs->canonicalize();
+        res->rtyp = polytopeID;
+        res->data = (void*) zs;
+        return FALSE;
+      }
+      return blackboxDefaultOp2(op,res,i1,i2);
+    }
+    case '|':
+    {
+      if(i2->Typ()==polytopeID)
+      {
+        gfan::ZCone* zq = (gfan::ZCone*) i2->Data();
+        int d1 = zp->ambientDimension();
+        int d2 = zq->ambientDimension();
+        if (d1 != d2)
+        {
+          Werror("mismatching ambient dimensions");
+          return TRUE;
+        }
+        gfan::ZMatrix rays = zp->extremeRays();
+        rays.append(zq->extremeRays());
+        gfan::ZMatrix lineality = zp->generatorsOfLinealitySpace();
+        lineality.append(zq->generatorsOfLinealitySpace());
+        gfan::ZCone* zs = new gfan::ZCone();
+        *zs = gfan::ZCone::givenByRays(rays,lineality);
+        zs->canonicalize();
+        res->rtyp = polytopeID;
+        res->data = (void*) zs;
+        return FALSE;
+      }
+    return blackboxDefaultOp2(op,res,i1,i2);
+    }
+    case EQUAL_EQUAL:
+    {
+      if(i2->Typ()==polytopeID)
+      {
+        gfan::ZCone* zq = (gfan::ZCone*) i2->Data();
+        zp->canonicalize();
+        zq->canonicalize();
+        bool b = !((*zp)!=(*zq));
+        res->rtyp = INT_CMD;
+        res->data = (char*) (int) b;
+        return FALSE;
+      }
+      return blackboxDefaultOp2(op,res,i1,i2);
     }
     default:
       return blackboxDefaultOp2(op,res,i1,i2);

-- 
an open source computer algebra system



More information about the debian-science-commits mailing list