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

Bernhard R. Link brlink at debian.org
Tue Apr 24 15:54:22 UTC 2012


The following commit has been merged in the cleanedupstream branch:
commit d1dacca65877cafb671e54ab6685465867b552f9
Author: Yue Ren <ren at mathematik.uni-kl.de>
Date:   Sun Mar 18 17:11:42 2012 +0100

    chg: conversion functions now return pointers

diff --git a/callpolymake/polymake_conversion.cc b/callpolymake/polymake_conversion.cc
index 310b881..4aa4e79 100644
--- a/callpolymake/polymake_conversion.cc
+++ b/callpolymake/polymake_conversion.cc
@@ -193,7 +193,7 @@ polymake::Matrix<polymake::Integer> Intvec2PmMatrixInteger (const intvec* im)
 /* Functions for converting cones and fans in between gfan and polymake,
    Singular shares the same cones and fans with gfan */
 
-gfan::ZCone PmCone2ZCone (polymake::perl::Object* pc)
+gfan::ZCone* PmCone2ZCone (polymake::perl::Object* pc)
 {
   if (pc->isa("Cone"))
   {
@@ -240,14 +240,14 @@ gfan::ZCone PmCone2ZCone (polymake::perl::Object* pc)
     else
       zy = gfan::ZMatrix(0, ambientdim2);
 
-    gfan::ZCone zc = gfan::ZCone(zv,zw,zx,zy,zz,3);
+    gfan::ZCone* zc = new gfan::ZCone(zv,zw,zx,zy,zz,3);
 
     return zc;
   }
   WerrorS("PmCone2ZCone: unexpected parameters");
 }
 
-gfan::ZCone PmPolytope2ZPolytope (polymake::perl::Object* pp)
+gfan::ZCone* PmPolytope2ZPolytope (polymake::perl::Object* pp)
 {
   if (pp->isa("Polytope<Rational>"))
   {
@@ -256,7 +256,6 @@ gfan::ZCone PmPolytope2ZPolytope (polymake::perl::Object* pp)
     if (!ok)
     {
       WerrorS("overflow while converting polymake::Integer to int");
-      return TRUE;
     }
     polymake::Matrix<polymake::Rational> ineqrational = pp->give("FACETS");
     polymake::Matrix<polymake::Rational> eqrational = pp->give("AFFINE_HULL");
@@ -297,70 +296,71 @@ gfan::ZCone PmPolytope2ZPolytope (polymake::perl::Object* pp)
     else
       zy = gfan::ZMatrix(0, ambientdim2);
 
-    gfan::ZCone zp = gfan::ZCone(zv,zw,zx,zy,zz,3);  
+    gfan::ZCone* zp = new gfan::ZCone(zv,zw,zx,zy,zz,3);  
     return zp;
   }
   WerrorS("PmPolytope2ZPolytope: unexpected parameters");
 }
 
-gfan::ZFan PmFan2ZFan (polymake::perl::Object* pf)
+gfan::ZFan* PmFan2ZFan (polymake::perl::Object* pf)
 {
   if (pf->isa("PolyhedralFan"))
   {
     int d = (int) pf->give("FAN_AMBIENT_DIM");
-    gfan::ZFan zf = gfan::ZFan(d);
+    Print("creating an empty fan of dimension %d\n",d);
+    gfan::ZFan* zf = new gfan::ZFan(d);
 
     int n = pf->give("N_MAXIMAL_CONES");
     for (int i=0; i<n; i++)
       {
         polymake::perl::Object pmcone=pf->CallPolymakeMethod("cone",i);
-        gfan::ZCone zc=PmCone2ZCone(&pmcone);
-        zf.insert(zc);
+        gfan::ZCone* zc=PmCone2ZCone(&pmcone);
+        zf->insert(*zc);
       }
     return zf;
   }
   WerrorS("PmFan2ZFan: unexpected parameters");
 }
 
-polymake::perl::Object ZCone2PmCone (gfan::ZCone* zc)
+polymake::perl::Object* ZCone2PmCone (gfan::ZCone* zc)
 {
-  polymake::perl::Object gc("Cone<Rational>");
+  polymake::perl::Object* gc = new polymake::perl::Object("Cone<Rational>");
 
   gfan::ZMatrix inequalities = zc->getInequalities();
-  gc.take("FACETS") << GfZMatrix2PmMatrixInteger(&inequalities);
+  gc->take("FACETS") << GfZMatrix2PmMatrixInteger(&inequalities);
 
   gfan::ZMatrix equations = zc->getEquations();
-  gc.take("LINEAR_SPAN") << GfZMatrix2PmMatrixInteger(&equations);
+  gc->take("LINEAR_SPAN") << GfZMatrix2PmMatrixInteger(&equations);
 
   if(zc->areExtremeRaysKnown())
     {  
       gfan::ZMatrix extremeRays = zc->extremeRays();
-      gc.take("RAYS") << GfZMatrix2PmMatrixInteger(&extremeRays);
+      gc->take("RAYS") << GfZMatrix2PmMatrixInteger(&extremeRays);
     }
 
   if(zc->areGeneratorsOfLinealitySpaceKnown())
     {
       gfan::ZMatrix lineality = zc->generatorsOfLinealitySpace();
-      gc.take("LINEALITY_SPACE") << GfZMatrix2PmMatrixInteger(&lineality);
+      gc->take("LINEALITY_SPACE") << GfZMatrix2PmMatrixInteger(&lineality);
     }
 
   return gc;
 }
 
-polymake::perl::Object ZPolytope2PmPolytope (gfan::ZCone* zc)
+polymake::perl::Object* ZPolytope2PmPolytope (gfan::ZCone* zc)
 {
-  polymake::perl::Object pp("Polytope<Rational>");
+  polymake::perl::Object* pp = new polymake::perl::Object("Polytope<Rational>");
 
   gfan::ZMatrix inequalities = zc->getInequalities();
-  pp.take("FACETS") << GfZMatrix2PmMatrixInteger(&inequalities);
+  pp->take("FACETS") << GfZMatrix2PmMatrixInteger(&inequalities);
 
   gfan::ZMatrix equations = zc->getEquations();
-  pp.take("LINEAR_SPAN") << GfZMatrix2PmMatrixInteger(&equations);
+  pp->take("LINEAR_SPAN") << GfZMatrix2PmMatrixInteger(&equations);
 
   if(zc->areExtremeRaysKnown())
     {
       gfan::ZMatrix vertices = zc->extremeRays();
-      pp.take("VERTICES") << GfZMatrix2PmMatrixInteger(&vertices);
+      pp->take("VERTICES") << GfZMatrix2PmMatrixInteger(&vertices);
     }
 
   return pp;
@@ -434,15 +434,15 @@ polymake::Array<polymake::Set<int> > conesOf(gfan::ZFan* zf)
   return L;
 }
 
-polymake::perl::Object ZFan2PmFan (gfan::ZFan* zf)
+polymake::perl::Object* ZFan2PmFan (gfan::ZFan* zf)
 {
-  polymake::perl::Object pf("PolyhedralFan");
+  polymake::perl::Object* pf = new polymake::perl::Object("PolyhedralFan");
 
   polymake::Matrix<polymake::Integer> zm = raysOf(zf);
-  pf.take("INPUT_RAYS") << zm;
+  pf->take("INPUT_RAYS") << zm;
 
   polymake::Array<polymake::Set<int> > ar = conesOf(zf);
-  pf.take("INPUT_CONES") << ar;
+  pf->take("INPUT_CONES") << ar;
 
   return pf;
 }
diff --git a/callpolymake/polymake_conversion.h b/callpolymake/polymake_conversion.h
index e83747c..f862d39 100644
--- a/callpolymake/polymake_conversion.h
+++ b/callpolymake/polymake_conversion.h
@@ -61,9 +61,9 @@ polymake::Matrix<polymake::Integer> Intvec2PmMatrixInteger (const intvec* im);
 /* Functions for converting cones and fans in between gfan and polymake,
    Singular shares the same cones and fans with gfan */
 
-gfan::ZCone PmCone2ZCone (polymake::perl::Object* pc);
-gfan::ZCone PmPolytope2ZPolytope (polymake::perl::Object* pp);
-gfan::ZFan PmFan2ZFan (polymake::perl::Object* pf);
-polymake::perl::Object ZCone2PmCone (gfan::ZCone* zc);
-polymake::perl::Object ZPolytope2PmPolytope (gfan::ZCone* zc);
-polymake::perl::Object ZFan2PmFan (gfan::ZFan* zf);
+gfan::ZCone* PmCone2ZCone (polymake::perl::Object* pc);
+gfan::ZCone* PmPolytope2ZPolytope (polymake::perl::Object* pp);
+gfan::ZFan* PmFan2ZFan (polymake::perl::Object* pf);
+polymake::perl::Object* ZCone2PmCone (gfan::ZCone* zc);
+polymake::perl::Object* ZPolytope2PmPolytope (gfan::ZCone* zc);
+polymake::perl::Object* ZFan2PmFan (gfan::ZFan* zf);
diff --git a/callpolymake/polymake_wrapper.cc b/callpolymake/polymake_wrapper.cc
index db17794..a129ce6 100644
--- a/callpolymake/polymake_wrapper.cc
+++ b/callpolymake/polymake_wrapper.cc
@@ -46,11 +46,12 @@ static BOOLEAN bbpolytope_Op2(int op, leftv res, leftv i1, leftv i2)
         gfan::ZCone* ms;
         try
         {
-          polymake::perl::Object pp = ZPolytope2PmPolytope(zp);
-          polymake::perl::Object pq = ZPolytope2PmPolytope(zq);
+          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));
+          CallPolymakeFunction("minkowski_sum", *pp, *pq) >> pms;
+          ms = PmPolytope2ZPolytope(&pms);
+          delete pp, pq;
         }
         catch (const std::exception& ex) 
         {
@@ -220,8 +221,9 @@ BOOLEAN PMisBounded(leftv res, leftv args)
     bool b;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      b = p.give("BOUNDED");
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      b = p->give("BOUNDED");
+      delete p;
     }
     catch (const std::exception& ex) 
     {
@@ -246,8 +248,9 @@ BOOLEAN PMisReflexive(leftv res, leftv args)
     bool b;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      b = p.give("REFLEXIVE");
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      b = p->give("REFLEXIVE");
+      delete p;
     }
     catch (const std::exception& ex) 
     {
@@ -272,8 +275,9 @@ BOOLEAN PMisGorenstein(leftv res, leftv args)
     bool b;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      b = p.give("GORENSTEIN");
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      b = p->give("GORENSTEIN");
+      delete p;
     }
     catch (const std::exception& ex) 
     {
@@ -296,26 +300,27 @@ BOOLEAN PMgorensteinIndex(leftv res, leftv args)
   {
     gfan::ZCone* zp = (gfan::ZCone*)u->Data();
     int gi;
+    bool ok = true;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      polymake::Integer pgi = p.give("GORENSTEIN_INDEX");
-      bool ok = true;
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      polymake::Integer pgi = p->give("GORENSTEIN_INDEX");
       gi = PmInteger2Int(pgi,ok); 
-      if (!ok)
-      {
-        WerrorS("overflow while converting polymake::Integer to int");
-        return TRUE;
-      }
-      res->rtyp = INT_CMD;
-      res->data = (char*) (int) gi;
-      return FALSE;
+      delete p;
     }
     catch (const std::exception& ex)
     {
       WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n");
       return TRUE;
     }
+    if (!ok)
+    {
+      WerrorS("overflow while converting polymake::Integer to int");
+      return TRUE;
+    }
+    res->rtyp = INT_CMD;
+    res->data = (char*) (int) gi;
+    return FALSE;
   }
   WerrorS("gorensteinIndex: unexpected parameters");
   return TRUE;
@@ -332,8 +337,9 @@ BOOLEAN PMgorensteinVector(leftv res, leftv args)
     bool ok = true;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      polymake::Vector<polymake::Integer> pgv = p.give("GORENSTEIN_VECTOR");
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      polymake::Vector<polymake::Integer> pgv = p->give("GORENSTEIN_VECTOR");
+      delete p;
       gv = PmVectorInteger2Intvec(&pgv,ok);
     }
     catch (const std::exception& ex) 
@@ -364,8 +370,9 @@ BOOLEAN PMisCanonical(leftv res, leftv args)
     bool b;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      b = p.give("CANONICAL");
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      b = p->give("CANONICAL");
+      delete p;
     }
     catch (const std::exception& ex) 
     {
@@ -390,8 +397,9 @@ BOOLEAN PMisTerminal(leftv res, leftv args)
     bool b;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      b = p.give("TERMINAL");
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      b = p->give("TERMINAL");
+      delete p;
     }
     catch (const std::exception& ex) 
     {
@@ -416,8 +424,9 @@ BOOLEAN PMisLatticeEmpty(leftv res, leftv args)
     bool b;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      b = p.give("LATTICE_EMPTY");
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      b = p->give("LATTICE_EMPTY");
+      delete p;
     }
     catch (const std::exception& ex) 
     {
@@ -440,26 +449,27 @@ BOOLEAN PMlatticeVolume(leftv res, leftv args)
   {
     gfan::ZCone* zp = (gfan::ZCone*)u->Data();
     int lv;
+    bool ok = true;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      polymake::Integer plv = p.give("LATTICE_VOLUME");
-      bool ok = true;
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      polymake::Integer plv = p->give("LATTICE_VOLUME");
+      delete p;
       lv = PmInteger2Int(plv,ok); 
-      if (!ok)
-      {
-        WerrorS("overflow while converting polymake::Integer to int");
-        return TRUE;
-      }
-      res->rtyp = INT_CMD;
-      res->data = (char*) (int) lv;
-      return FALSE;
     }
     catch (const std::exception& ex) 
     {
       WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); 
       return TRUE;
     }
+    if (!ok)
+    {
+      WerrorS("overflow while converting polymake::Integer to int");
+      return TRUE;
+    }
+    res->rtyp = INT_CMD;
+    res->data = (char*) (int) lv;
+    return FALSE;
   }
   WerrorS("latticeVolume: unexpected parameters");
   return TRUE;
@@ -473,23 +483,24 @@ BOOLEAN PMlatticeDegree(leftv res, leftv args)
   {
     gfan::ZCone* zp = (gfan::ZCone*)u->Data();
     int ld;
+    bool ok = true;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      polymake::Integer pld = p.give("LATTICE_DEGREE");
-      bool ok = true;
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      polymake::Integer pld = p->give("LATTICE_DEGREE");
+      delete p;
       ld = PmInteger2Int(pld,ok); 
-      if (!ok)
-      {
-        WerrorS("overflow while converting polymake::Integer to int");
-        return TRUE;
-      }
     }
     catch (const std::exception& ex) 
     {
       WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); 
       return TRUE;
     }
+    if (!ok)
+    {
+      WerrorS("overflow while converting polymake::Integer to int");
+      return TRUE;
+    }
     res->rtyp = INT_CMD;
     res->data = (char*) (int) ld;
     return FALSE;
@@ -506,23 +517,24 @@ BOOLEAN PMlatticeCodegree(leftv res, leftv args)
   {
     gfan::ZCone* zp = (gfan::ZCone*)u->Data();
     int lc;
+    bool ok = true;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      polymake::Integer plc = p.give("LATTICE_CODEGREE");
-      bool ok = true;
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      polymake::Integer plc = p->give("LATTICE_CODEGREE");
+      delete p;
       lc = PmInteger2Int(plc,ok); 
-      if (!ok)
-      {
-        WerrorS("overflow while converting polymake::Integer to int");
-        return TRUE;
-      }
     }
     catch (const std::exception& ex) 
     {
       WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); 
       return TRUE;
     }
+    if (!ok)
+    {
+      WerrorS("overflow while converting polymake::Integer to int");
+      return TRUE;
+    }
     res->rtyp = INT_CMD;
     res->data = (char*) (int) lc;
     return FALSE;
@@ -542,8 +554,9 @@ BOOLEAN PMehrhartPolynomialCoeff(leftv res, leftv args)
     bool ok = true;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      polymake::Vector<polymake::Integer> pec = p.give("EHRHART_POLYNOMIAL_COEFF");
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      polymake::Vector<polymake::Integer> pec = p->give("EHRHART_POLYNOMIAL_COEFF");
+      delete p;
       ec = PmVectorInteger2Intvec(&pec,ok);
     }
     catch (const std::exception& ex) 
@@ -551,7 +564,7 @@ BOOLEAN PMehrhartPolynomialCoeff(leftv res, leftv args)
       WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); 
       return TRUE;
     }
-    if(!ok)
+    if (!ok)
     {
       WerrorS("ehrhartPolynomialCoeff: overflow in PmVectorInteger2Intvec");
       return TRUE;
@@ -575,8 +588,9 @@ BOOLEAN PMhStarVector(leftv res, leftv args)
     bool ok = true;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      polymake::Vector<polymake::Integer> phv = p.give("H_STAR_VECTOR");
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      polymake::Vector<polymake::Integer> phv = p->give("H_STAR_VECTOR");
+      delete p;
       hv = PmVectorInteger2Intvec(&phv,ok);
     }
     catch (const std::exception& ex) 
@@ -584,7 +598,7 @@ BOOLEAN PMhStarVector(leftv res, leftv args)
       WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); 
       return TRUE;
     }
-    if(!ok)
+    if (!ok)
     {
       WerrorS("hStarVector: overflow in PmVectorInteger2Intvec");
       return TRUE;
@@ -607,8 +621,9 @@ BOOLEAN PMisNormal(leftv res, leftv args)
     bool b;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      b = p.give("NORMAL");
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      b = p->give("NORMAL");
+      delete p;
     }
     catch (const std::exception& ex) 
     {
@@ -634,8 +649,9 @@ BOOLEAN PMfacetWidths(leftv res, leftv args)
     bool ok = true;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      polymake::Vector<polymake::Integer> pfw = p.give("FACET_WIDTHS");
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      polymake::Vector<polymake::Integer> pfw = p->give("FACET_WIDTHS");
+      delete p;
       fw = PmVectorInteger2Intvec(&pfw,ok);
     }
     catch (const std::exception& ex) 
@@ -643,7 +659,7 @@ BOOLEAN PMfacetWidths(leftv res, leftv args)
       WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); 
       return TRUE;
     }
-    if(!ok)
+    if (!ok)
     {
       WerrorS("facetWidths: overflow in PmVectorInteger2Intvec");
       return TRUE;
@@ -664,23 +680,24 @@ BOOLEAN PMfacetWidth(leftv res, leftv args)
   {
     gfan::ZCone* zp = (gfan::ZCone*)u->Data();
     int fw;
+    bool ok = true;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      polymake::Integer pfw = p.give("FACET_WIDTH");
-      bool ok = true;
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      polymake::Integer pfw = p->give("FACET_WIDTH");
+      delete p;
       fw = PmInteger2Int(pfw,ok); 
-      if (!ok)
-      { 
-        WerrorS("overflow while converting polymake::Integer to int");
-        return TRUE;
-      }
     }
     catch (const std::exception& ex) 
     {
       WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); 
       return TRUE;
     }
+    if (!ok)
+    { 
+      WerrorS("overflow while converting polymake::Integer to int");
+      return TRUE;
+    }
     res->rtyp = INT_CMD;
     res->data = (char*) (int) fw;
     return FALSE;
@@ -700,20 +717,21 @@ BOOLEAN PMfacetVertexLatticeDistances(leftv res, leftv args)
     bool ok=true;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      polymake::Matrix<polymake::Integer> pld = p.give("FACET_VERTEX_LATTICE_DISTANCES");
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      polymake::Matrix<polymake::Integer> pld = p->give("FACET_VERTEX_LATTICE_DISTANCES");
+      delete p;
       ld = PmMatrixInteger2Intvec(&pld,ok);
-      if (!ok)
-      { 
-        WerrorS("overflow while converting polymake::Integer to int");
-        return TRUE;
-      }
     }
     catch (const std::exception& ex) 
     {
       WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); 
       return TRUE;
     }
+    if (!ok)
+    { 
+      WerrorS("overflow while converting polymake::Integer to int");
+      return TRUE;
+    }
     res->rtyp = INTMAT_CMD;
     res->data = (char*) ld;
     return FALSE;
@@ -732,8 +750,9 @@ BOOLEAN PMisCompressed(leftv res, leftv args)
     bool b;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      b = p.give("COMPRESSED");
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      b = p->give("COMPRESSED");
+      delete p;
     }
     catch (const std::exception& ex) 
     {
@@ -758,8 +777,9 @@ BOOLEAN PMisSmooth(leftv res, leftv args)
     bool b;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      b = p.give("SMOOTH");
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      b = p->give("SMOOTH");
+      delete p;
     }
     catch (const std::exception& ex) 
     {
@@ -784,8 +804,9 @@ BOOLEAN PMisVeryAmple(leftv res, leftv args)
     bool b;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      b = p.give("VERY_AMPLE");
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      b = p->give("VERY_AMPLE");
+      delete p;
     }
     catch (const std::exception& ex) 
     {
@@ -808,23 +829,24 @@ BOOLEAN PMlatticePoints(leftv res, leftv args)
   {
     gfan::ZCone* zp = (gfan::ZCone*)u->Data();
     intvec* iv;
+    bool ok = true;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      polymake::Matrix<polymake::Integer> lp = p.give("LATTICE_POINTS");
-      bool ok = true;
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      polymake::Matrix<polymake::Integer> lp = p->give("LATTICE_POINTS");
+      delete p;
       iv = PmMatrixInteger2Intvec(&lp,ok); 
-      if (!ok)
-      { 
-        WerrorS("overflow while converting polymake::Integer to int");
-        return TRUE;
-      }
     }
     catch (const std::exception& ex) 
     {
       WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); 
       return TRUE;
     }
+    if (!ok)
+    { 
+      WerrorS("overflow while converting polymake::Integer to int");
+      return TRUE;
+    }
     res->rtyp = INTMAT_CMD;
     res->data = (char*) iv;
     return FALSE;
@@ -841,23 +863,24 @@ BOOLEAN PMnLatticePoints(leftv res, leftv args)
   {
     gfan::ZCone* zp = (gfan::ZCone*)u->Data();
     int n;
+    bool ok = true;
     try
     {    
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      polymake::Integer nlp = p.give("N_LATTICE_POINTS");
-      bool ok = true;
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      polymake::Integer nlp = p->give("N_LATTICE_POINTS");
+      delete p;
       n = PmInteger2Int(nlp,ok); 
-      if (!ok)
-      {
-        WerrorS("overflow while converting polymake::Integer to int");
-        return TRUE;
-      }
     }
     catch (const std::exception& ex) 
     {
       WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); 
       return TRUE;
     }
+    if (!ok)
+    {
+      WerrorS("overflow while converting polymake::Integer to int");
+      return TRUE;
+    }
     res->rtyp = INT_CMD;
     res->data = (char*) n;
     return FALSE;
@@ -874,23 +897,24 @@ BOOLEAN PMinteriorLatticePoints(leftv res, leftv args)
   {
     gfan::ZCone* zp = (gfan::ZCone*)u->Data();
     intvec* iv;
+    bool ok = true;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      polymake::Matrix<polymake::Integer> lp = p.give("INTERIOR_LATTICE_POINTS");
-      bool ok = true;
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      polymake::Matrix<polymake::Integer> lp = p->give("INTERIOR_LATTICE_POINTS");
+      delete p;
       iv = PmMatrixInteger2Intvec(&lp,ok); 
-      if (!ok)
-      { 
-        WerrorS("overflow while converting polymake::Integer to int");
-        return TRUE;
-      }
     }
     catch (const std::exception& ex) 
     {
       WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); 
       return TRUE;
     }
+    if (!ok)
+    { 
+      WerrorS("overflow while converting polymake::Integer to int");
+      return TRUE;
+    }
     res->rtyp = INTMAT_CMD;
     res->data = (char*) iv;
     return FALSE;
@@ -907,23 +931,24 @@ BOOLEAN PMnInteriorLatticePoints(leftv res, leftv args)
   {
     gfan::ZCone* zp = (gfan::ZCone*)u->Data();
     int n;
+    bool ok = true;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      polymake::Integer nlp = p.give("N_INTERIOR_LATTICE_POINTS");
-      bool ok = true;
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      polymake::Integer nlp = p->give("N_INTERIOR_LATTICE_POINTS");
+      delete p;
       n = PmInteger2Int(nlp,ok); 
-      if (!ok)
-      {
-        WerrorS("overflow while converting polymake::Integer to int");
-        return TRUE;
-      }
     }
     catch (const std::exception& ex) 
     {
       WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); 
       return TRUE;
     }
+    if (!ok)
+    {
+      WerrorS("overflow while converting polymake::Integer to int");
+      return TRUE;
+    }
     res->rtyp = INT_CMD;
     res->data = (char*) n;
     return FALSE;
@@ -940,23 +965,24 @@ BOOLEAN PMboundaryLatticePoints(leftv res, leftv args)
   {
     gfan::ZCone* zp = (gfan::ZCone*)u->Data();
     intvec* iv;
+    bool ok = true;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      polymake::Matrix<polymake::Integer> lp = p.give("BOUNDARY_LATTICE_POINTS");
-      bool ok = true;
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      polymake::Matrix<polymake::Integer> lp = p->give("BOUNDARY_LATTICE_POINTS");
+      delete p;
       iv = PmMatrixInteger2Intvec(&lp,ok); 
-      if (!ok)
-      { 
-        WerrorS("overflow while converting polymake::Integer to int");
-        return TRUE;
-      }
     }
     catch (const std::exception& ex) 
     {
       WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); 
       return TRUE;
     }
+    if (!ok)
+    { 
+      WerrorS("overflow while converting polymake::Integer to int");
+      return TRUE;
+    }
     res->rtyp = INTMAT_CMD;
     res->data = (char*) iv;
     return FALSE;
@@ -973,23 +999,24 @@ BOOLEAN PMnBoundaryLatticePoints(leftv res, leftv args)
   {
     gfan::ZCone* zp = (gfan::ZCone*)u->Data();
     int n;
+    bool ok = true;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      polymake::Integer nlp = p.give("N_BOUNDARY_LATTICE_POINTS");
-      bool ok = true;
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      polymake::Integer nlp = p->give("N_BOUNDARY_LATTICE_POINTS");
+      delete p;
       n = PmInteger2Int(nlp,ok); 
-      if (!ok)
-      {
-        WerrorS("overflow while converting polymake::Integer to int");
-        return TRUE;
-      }
     }
     catch (const std::exception& ex) 
     {
       WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); 
       return TRUE;
     }
+    if (!ok)
+    {
+      WerrorS("overflow while converting polymake::Integer to int");
+      return TRUE;
+    }
     res->rtyp = INT_CMD;
     res->data = (char*) n;
     return FALSE;
@@ -1006,23 +1033,24 @@ BOOLEAN PMhilbertBasis(leftv res, leftv args)
   {
     gfan::ZCone* zp = (gfan::ZCone*)u->Data();
     intvec* iv;
+    bool ok = true;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      polymake::Matrix<polymake::Integer> lp = p.give("HILBERT_BASIS");
-      bool ok = true;
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      polymake::Matrix<polymake::Integer> lp = p->give("HILBERT_BASIS");
+      delete p;
       iv = PmMatrixInteger2Intvec(&lp,ok); 
-      if (!ok)
-      { 
-        WerrorS("overflow while converting polymake::Integer to int");
-        return TRUE;
-      }
     }
     catch (const std::exception& ex) 
     {
       WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); 
       return TRUE;
     }
+    if (!ok)
+    { 
+      WerrorS("overflow while converting polymake::Integer to int");
+      return TRUE;
+    }
     res->rtyp = INTMAT_CMD;
     res->data = (char*) iv;
     return FALSE;
@@ -1039,23 +1067,24 @@ BOOLEAN PMnHilbertBasis(leftv res, leftv args)
   {
     gfan::ZCone* zp = (gfan::ZCone*)u->Data();
     int n;
+    bool ok = true;
     try
     {
-      polymake::perl::Object p = ZPolytope2PmPolytope(zp);
-      polymake::Integer nlp = p.give("N_HILBERT_BASIS");
-      bool ok = true;
+      polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
+      polymake::Integer nlp = p->give("N_HILBERT_BASIS");
+      delete p;
       n = PmInteger2Int(nlp,ok); 
-      if (!ok)
-      {
-        WerrorS("overflow while converting polymake::Integer to int");
-        return TRUE;
-      }
     }
     catch (const std::exception& ex) 
     {
       WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); 
       return TRUE;
     }
+    if (!ok)
+    {
+      WerrorS("overflow while converting polymake::Integer to int");
+      return TRUE;
+    }
     res->rtyp = INT_CMD;
     res->data = (char*) n;
     return FALSE;
@@ -1078,11 +1107,12 @@ BOOLEAN PMminkowskiSum(leftv res, leftv args)
       gfan::ZCone* ms;
       try
       {
-        polymake::perl::Object pp = ZPolytope2PmPolytope(zp);
-        polymake::perl::Object pq = ZPolytope2PmPolytope(zq);
+        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));
+        CallPolymakeFunction("minkowski_sum", *pp, *pq) >> pms;
+        delete pp, pq;
+        ms = PmPolytope2ZPolytope(&pms);
       }
       catch (const std::exception& ex) 
       {
@@ -1128,27 +1158,28 @@ BOOLEAN PMmaximalFace(leftv res, leftv args)
       gfan::ZCone* zp = (gfan::ZCone*)u->Data();
       intvec* iv = (intvec*) v->Data();
       intvec* maxface;
+      bool ok = true;
       try
       {
-        polymake::perl::Object p = ZPolytope2PmPolytope(zp);
+        polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
         polymake::perl::Object o("LinearProgram<Rational>");
         o.take("LINEAR_OBJECTIVE") << Intvec2PmVectorInteger(iv);
-        p.take("LP") << o;
-        polymake::Set<polymake::Integer> mf = p.give("LP.MAXIMAL_FACE");
-        polymake::Matrix<polymake::Integer> rays = raysOf(&p,&mf);
-        bool ok = true;
+        p->take("LP") << o;
+        polymake::Set<polymake::Integer> mf = p->give("LP.MAXIMAL_FACE");
+        delete p;
+        polymake::Matrix<polymake::Integer> rays = raysOf(p,&mf);
         maxface = new intvec(PmMatrixInteger2Intvec(&rays,ok));
-        if (!ok)
-        { 
-          WerrorS("overflow while converting polymake::Integer to int");
-          return TRUE;
-        }
       }
       catch (const std::exception& ex) 
       {
         WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); 
         return TRUE;
       }
+      if (!ok)
+      { 
+        WerrorS("overflow while converting polymake::Integer to int");
+        return TRUE;
+      }
       res->rtyp = INTVEC_CMD;
       res->data = (char*) maxface;
       return FALSE;
@@ -1170,27 +1201,28 @@ BOOLEAN PMminimalFace(leftv res, leftv args)
       gfan::ZCone* zp = (gfan::ZCone*)u->Data();
       intvec* iv = (intvec*) v->Data();
       intvec* minface;
+      bool ok = true;
       try
       {
-        polymake::perl::Object p = ZPolytope2PmPolytope(zp);
+        polymake::perl::Object* p = ZPolytope2PmPolytope(zp);
         polymake::perl::Object o("LinearProgram<Rational>");
         o.take("LINEAR_OBJECTIVE") << Intvec2PmVectorInteger(iv);
-        p.take("LP") << o;
-        polymake::Set<polymake::Integer> mf = p.give("LP.MINIMAL_FACE");
-        polymake::Matrix<polymake::Integer> rays = raysOf(&p,&mf);
-        bool ok = true;
+        p->take("LP") << o;
+        polymake::Set<polymake::Integer> mf = p->give("LP.MINIMAL_FACE");
+        delete p;
+        polymake::Matrix<polymake::Integer> rays = raysOf(p,&mf);
         minface = new intvec(PmMatrixInteger2Intvec(&rays,ok));
-        if (!ok)
-        { 
-          WerrorS("overflow while converting polymake::Integer to int");
-          return TRUE;
-        }
       }
       catch (const std::exception& ex) 
       {
         WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); 
         return TRUE;
       }
+      if (!ok)
+      { 
+        WerrorS("overflow while converting polymake::Integer to int");
+        return TRUE;
+      }
       res->rtyp = INTVEC_CMD;
       res->data = (char*) minface;
       return FALSE;
@@ -1214,27 +1246,28 @@ BOOLEAN PMmaximalValue(leftv res, leftv args)
       if (iv->rows()==zp->ambientDimension())
       {
         int m;
+        bool ok = true;
         try
         {
-          polymake::perl::Object p = ZPolytope2PmPolytope(zp); 
+          polymake::perl::Object* p = ZPolytope2PmPolytope(zp); 
           polymake::Vector<polymake::Integer> lo = Intvec2PmVectorInteger(iv);
           polymake::perl::Object o("LinearProgram<Rational>");
           o.take("LINEAR_OBJECTIVE") << lo;
-          p.take("LP") << o;
-          polymake::Integer mv = p.give("LP.MAXIMAL_VALUE"); 
-          bool ok = true;
+          p->take("LP") << o;
+          polymake::Integer mv = p->give("LP.MAXIMAL_VALUE"); 
+          delete p;
           m = PmInteger2Int(mv,ok); 
-          if (!ok)
-          {
-            WerrorS("overflow while converting polymake::Integer to int");
-            return TRUE;
-          }
         }
         catch (const std::exception& ex) 
         {
           WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); 
           return TRUE;
         }
+        if (!ok)
+        {
+          WerrorS("overflow while converting polymake::Integer to int");
+          return TRUE;
+        }
         res->rtyp = INT_CMD;
         res->data = (char*) m;
         return FALSE;
@@ -1260,27 +1293,28 @@ BOOLEAN PMminimalValue(leftv res, leftv args)
       if (iv->rows()==zp->ambientDimension())
       {
         int m;
+        bool ok = true;
         try
         {
-          polymake::perl::Object p = ZPolytope2PmPolytope(zp); 
+          polymake::perl::Object* p = ZPolytope2PmPolytope(zp); 
           polymake::Vector<polymake::Integer> lo = Intvec2PmVectorInteger(iv);
           polymake::perl::Object o("LinearProgram<Rational>");
           o.take("LINEAR_OBJECTIVE") << lo;
-          p.take("LP") << o;
-          polymake::Integer mv = p.give("LP.MINIMAL_VALUE"); 
-          bool ok = true;
+          p->take("LP") << o;
+          polymake::Integer mv = p->give("LP.MINIMAL_VALUE"); 
+          delete p;
           m = PmInteger2Int(mv,ok); 
-          if (!ok)
-          {
-            WerrorS("overflow while converting polymake::Integer to int");
-            return TRUE;
-          }
         }
         catch (const std::exception& ex) 
         {
           WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); 
           return TRUE;
         }
+        if (!ok)
+        {
+          WerrorS("overflow while converting polymake::Integer to int");
+          return TRUE;
+        }
         res->rtyp = INT_CMD;
         res->data = (char*) m;
         return FALSE;
@@ -1302,8 +1336,9 @@ BOOLEAN visual(leftv res, leftv args)
     gfan::ZCone* zp = (gfan::ZCone*)u->Data();
     try
     {
-      polymake::perl::Object pp = ZPolytope2PmPolytope(zp);
-      VoidCallPolymakeFunction("jreality",pp.CallPolymakeMethod("VISUAL"));
+      polymake::perl::Object* pp = ZPolytope2PmPolytope(zp);
+      VoidCallPolymakeFunction("jreality",pp->CallPolymakeMethod("VISUAL"));
+      delete pp;
     }
     catch (const std::exception& ex)
     {
@@ -1319,8 +1354,8 @@ BOOLEAN visual(leftv res, leftv args)
     gfan::ZFan* zf = (gfan::ZFan*)u->Data();
     try
     {
-      polymake::perl::Object pf=ZFan2PmFan(zf);
-      VoidCallPolymakeFunction("jreality",pf.CallPolymakeMethod("VISUAL"));
+      polymake::perl::Object* pf=ZFan2PmFan(zf);
+      VoidCallPolymakeFunction("jreality",pf->CallPolymakeMethod("VISUAL"));
     }    
     catch (const std::exception& ex)
     {
@@ -1338,18 +1373,18 @@ BOOLEAN visual(leftv res, leftv args)
 BOOLEAN normalFan(leftv res, leftv args)
 {
   leftv u = args;
-  if ((u != NULL) && (u->Typ() == coneID))
+  if ((u != NULL) && (u->Typ() == polytopeID))
   {
-    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
-    gfan::ZMatrix rays = zc->extremeRays();
-    gfan::ZFan* zf;
+    gfan::ZCone* zp = (gfan::ZCone*)u->Data();
+    gfan::ZFan* zf = new gfan::ZFan();
     try
     {
-      polymake::perl::Object p("Polytope<Rational>");
-      p.take("VERTICES") << GfZMatrix2PmMatrixInteger(&rays);
-      polymake::perl::Object pf;
-      CallPolymakeFunction("normal_fan", p) >> pf;
-      gfan::ZFan* zf = new gfan::ZFan(PmFan2ZFan(&pf));
+      polymake::perl::Object* p=ZPolytope2PmPolytope(zp);
+      polymake::perl::Object* pf;
+      CallPolymakeFunction("normal_fan", p) >> *pf;
+      delete p;
+      zf = PmFan2ZFan(pf);
+      delete pf;
     }
     catch (const std::exception& ex) 
     {
@@ -1567,7 +1602,7 @@ BOOLEAN PMconeViaRays(leftv res, leftv args)
                                            // information provided are exact
       } 
     }
-    gfan::ZCone* zc = new gfan::ZCone(PmCone2ZCone(&pc));
+    gfan::ZCone* zc = PmCone2ZCone(&pc);
     res->rtyp = coneID;
     res->data = (char*) zc;
     return FALSE;
@@ -1600,7 +1635,7 @@ BOOLEAN PMpolytopeViaVertices(leftv res, leftv args)
     else
       pp.take("POINTS") << pmpoints;              // by default, we assume that matrix may contain non-vertices
     
-    gfan::ZCone* zp = new gfan::ZCone(PmPolytope2ZPolytope(&pp));
+    gfan::ZCone* zp = PmPolytope2ZPolytope(&pp);
     res->rtyp = polytopeID;
     res->data = (char*) zp;
     return FALSE;

-- 
an open source computer algebra system



More information about the debian-science-commits mailing list