MCPcopy Create free account
hub / github.com/Singular/Singular / bbpolytope_Op2

Function bbpolytope_Op2

Singular/dyn_modules/polymake/polymake_wrapper.cc:24–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22polymake::Main* init_polymake=NULL;
23
24static BOOLEAN bbpolytope_Op2(int op, leftv res, leftv i1, leftv i2)
25{
26 gfan::ZCone* zp = (gfan::ZCone*) i1->Data();
27 switch(op)
28 {
29 case '+':
30 {
31 if (i2->Typ()==polytopeID || i2->Typ()==coneID)
32 {
33 gfan::initializeCddlibIfRequired();
34 gfan::ZCone* zq = (gfan::ZCone*) i2->Data();
35 gfan::ZCone* ms;
36 try
37 {
38 polymake::perl::Object* pp = ZPolytope2PmPolytope(zp);
39 polymake::perl::Object* pq = ZPolytope2PmPolytope(zq);
40 polymake::perl::Object pms;
41 #if (POLYMAKE_VERSION >= 305)
42 polymake::call_function("minkowski_sum", *pp, *pq) >> pms;
43 #else
44 CallPolymakeFunction("minkowski_sum", *pp, *pq) >> pms;
45 #endif
46 ms = PmPolytope2ZPolytope(&pms);
47 delete pp;
48 delete pq;
49 }
50 catch (const std::exception& ex)
51 {
52 gfan::deinitializeCddlibIfRequired();
53 WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n");
54 return TRUE;
55 }
56 gfan::deinitializeCddlibIfRequired();
57 res->rtyp = polytopeID;
58 res->data = (void*) ms;
59 return FALSE;
60 }
61 return blackboxDefaultOp2(op,res,i1,i2);
62 }
63 case '*':
64 {
65 if (i2->Typ()==INT_CMD)
66 {
67 gfan::initializeCddlibIfRequired();
68 int s = (int)(long) i2->Data();
69 gfan::ZMatrix zm = zp->extremeRays();
70 for (int i=0; i<zm.getHeight(); i++)
71 for (int j=1; j<zm.getWidth(); j++)
72 zm[i][j] *= s;
73 gfan::ZCone* zs = new gfan::ZCone();
74 *zs = gfan::ZCone::givenByRays(zm,gfan::ZMatrix(0, zm.getWidth()));
75 gfan::deinitializeCddlibIfRequired();
76 res->rtyp = polytopeID;
77 res->data = (void*) zs;
78 return FALSE;
79 }
80 return blackboxDefaultOp2(op,res,i1,i2);
81 }

Callers

nothing calls this directly

Calls 15

ZPolytope2PmPolytopeFunction · 0.85
PmPolytope2ZPolytopeFunction · 0.85
WerrorSFunction · 0.85
blackboxDefaultOp2Function · 0.85
intersectionFunction · 0.85
extremeRaysMethod · 0.80
getHeightMethod · 0.80
getWidthMethod · 0.80
ambientDimensionMethod · 0.80

Tested by

no test coverage detected