1 | #include <polymake_conversion.h> |
---|
2 | #include <polymake_documentation.h> |
---|
3 | |
---|
4 | #include <dyn_modules/callgfanlib/bbcone.h> |
---|
5 | #include <dyn_modules/callgfanlib/bbfan.h> |
---|
6 | #include <dyn_modules/callgfanlib/bbpolytope.h> |
---|
7 | |
---|
8 | #include <Singular/blackbox.h> |
---|
9 | #include <Singular/ipshell.h> |
---|
10 | #include <Singular/subexpr.h> |
---|
11 | |
---|
12 | polymake::Main* init_polymake=NULL; |
---|
13 | |
---|
14 | static BOOLEAN bbpolytope_Op2(int op, leftv res, leftv i1, leftv i2) |
---|
15 | { |
---|
16 | gfan::ZCone* zp = (gfan::ZCone*) i1->Data(); |
---|
17 | switch(op) |
---|
18 | { |
---|
19 | case '+': |
---|
20 | { |
---|
21 | if (i2->Typ()==polytopeID || i2->Typ()==coneID) |
---|
22 | { |
---|
23 | gfan::ZCone* zq = (gfan::ZCone*) i2->Data(); |
---|
24 | gfan::ZCone* ms; |
---|
25 | try |
---|
26 | { |
---|
27 | polymake::perl::Object* pp = ZPolytope2PmPolytope(zp); |
---|
28 | polymake::perl::Object* pq = ZPolytope2PmPolytope(zq); |
---|
29 | polymake::perl::Object pms; |
---|
30 | CallPolymakeFunction("minkowski_sum", *pp, *pq) >> pms; |
---|
31 | ms = PmPolytope2ZPolytope(&pms); |
---|
32 | delete pp; |
---|
33 | delete pq; |
---|
34 | } |
---|
35 | catch (const std::exception& ex) |
---|
36 | { |
---|
37 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
38 | return TRUE; |
---|
39 | } |
---|
40 | res->rtyp = polytopeID; |
---|
41 | res->data = (void*) ms; |
---|
42 | return FALSE; |
---|
43 | } |
---|
44 | return blackboxDefaultOp2(op,res,i1,i2); |
---|
45 | } |
---|
46 | case '*': |
---|
47 | { |
---|
48 | if (i2->Typ()==INT_CMD) |
---|
49 | { |
---|
50 | int s = (int)(long) i2->Data(); |
---|
51 | gfan::ZMatrix zm = zp->extremeRays(); |
---|
52 | for (int i=0; i<zm.getHeight(); i++) |
---|
53 | for (int j=1; j<zm.getWidth(); j++) |
---|
54 | zm[i][j] *= s; |
---|
55 | gfan::ZCone* zs = new gfan::ZCone(); |
---|
56 | *zs = gfan::ZCone::givenByRays(zm,gfan::ZMatrix(0, zm.getWidth())); |
---|
57 | res->rtyp = polytopeID; |
---|
58 | res->data = (void*) zs; |
---|
59 | return FALSE; |
---|
60 | } |
---|
61 | return blackboxDefaultOp2(op,res,i1,i2); |
---|
62 | } |
---|
63 | case '&': |
---|
64 | { |
---|
65 | if (i2->Typ()==polytopeID) |
---|
66 | { |
---|
67 | gfan::ZCone* zq = (gfan::ZCone*) i2->Data(); |
---|
68 | int d1 = zp->ambientDimension(); |
---|
69 | int d2 = zq->ambientDimension(); |
---|
70 | if (d1 != d2) |
---|
71 | { |
---|
72 | Werror("mismatching ambient dimensions"); |
---|
73 | return TRUE; |
---|
74 | } |
---|
75 | gfan::ZCone* zs = new gfan::ZCone(); |
---|
76 | *zs = gfan::intersection(*zp, *zq); |
---|
77 | zs->canonicalize(); |
---|
78 | res->rtyp = polytopeID; |
---|
79 | res->data = (void*) zs; |
---|
80 | return FALSE; |
---|
81 | } |
---|
82 | return blackboxDefaultOp2(op,res,i1,i2); |
---|
83 | } |
---|
84 | case '|': |
---|
85 | { |
---|
86 | if(i2->Typ()==polytopeID) |
---|
87 | { |
---|
88 | gfan::ZCone* zq = (gfan::ZCone*) i2->Data(); |
---|
89 | int d1 = zp->ambientDimension(); |
---|
90 | int d2 = zq->ambientDimension(); |
---|
91 | if (d1 != d2) |
---|
92 | { |
---|
93 | Werror("mismatching ambient dimensions"); |
---|
94 | return TRUE; |
---|
95 | } |
---|
96 | gfan::ZMatrix rays = zp->extremeRays(); |
---|
97 | rays.append(zq->extremeRays()); |
---|
98 | gfan::ZMatrix lineality = zp->generatorsOfLinealitySpace(); |
---|
99 | lineality.append(zq->generatorsOfLinealitySpace()); |
---|
100 | gfan::ZCone* zs = new gfan::ZCone(); |
---|
101 | *zs = gfan::ZCone::givenByRays(rays,lineality); |
---|
102 | zs->canonicalize(); |
---|
103 | res->rtyp = polytopeID; |
---|
104 | res->data = (void*) zs; |
---|
105 | return FALSE; |
---|
106 | } |
---|
107 | return blackboxDefaultOp2(op,res,i1,i2); |
---|
108 | } |
---|
109 | case EQUAL_EQUAL: |
---|
110 | { |
---|
111 | if(i2->Typ()==polytopeID) |
---|
112 | { |
---|
113 | gfan::ZCone* zq = (gfan::ZCone*) i2->Data(); |
---|
114 | zp->canonicalize(); |
---|
115 | zq->canonicalize(); |
---|
116 | bool b = !((*zp)!=(*zq)); |
---|
117 | res->rtyp = INT_CMD; |
---|
118 | res->data = (char*) (long) b; |
---|
119 | return FALSE; |
---|
120 | } |
---|
121 | return blackboxDefaultOp2(op,res,i1,i2); |
---|
122 | } |
---|
123 | default: |
---|
124 | return blackboxDefaultOp2(op,res,i1,i2); |
---|
125 | } |
---|
126 | return blackboxDefaultOp2(op,res,i1,i2); |
---|
127 | } |
---|
128 | |
---|
129 | |
---|
130 | /* Functions for using Polymake in Singular */ |
---|
131 | |
---|
132 | // BOOLEAN cube(leftv res, leftv args) |
---|
133 | // { |
---|
134 | // leftv u = args; |
---|
135 | // if ((u !=NULL) && (u->Typ() == INT_CMD)) |
---|
136 | // { |
---|
137 | // int ambientDim = (int)(long)u->Data(); |
---|
138 | // if (ambientDim < 0) |
---|
139 | // { |
---|
140 | // Werror("expected non-negative ambient dim but got %d", ambientDim); |
---|
141 | // return TRUE; |
---|
142 | // } |
---|
143 | // gfan::ZMatrix zm(ambientDim*2,ambientDim+1); |
---|
144 | // int j=1; |
---|
145 | // for (int i=0; i<ambientDim*2; i=i+2) |
---|
146 | // { |
---|
147 | // zm[i][0] = 1; |
---|
148 | // zm[i][j] = 1; |
---|
149 | // zm[i+1][0] = 1; |
---|
150 | // zm[i+1][j] = -1; |
---|
151 | // j = j+1; |
---|
152 | // } |
---|
153 | // gfan::ZCone* zc = new gfan::ZCone(zm, gfan::ZMatrix(0, zm.getWidth())); |
---|
154 | // res->rtyp = coneID; |
---|
155 | // res->data = (char *)zc; |
---|
156 | // return FALSE; |
---|
157 | // } |
---|
158 | // WerrorS("cube: unexpected parameters"); |
---|
159 | // return TRUE; |
---|
160 | // } |
---|
161 | |
---|
162 | // BOOLEAN cross(leftv res, leftv args) |
---|
163 | // { |
---|
164 | // leftv u = args; |
---|
165 | // if ((u !=NULL) && (u->Typ() == INT_CMD)) |
---|
166 | // { |
---|
167 | // int ambientDim = (int)(long)u->Data(); |
---|
168 | // if (ambientDim < 0) |
---|
169 | // { |
---|
170 | // Werror("expected non-negative ambient dim but got %d", ambientDim); |
---|
171 | // return TRUE; |
---|
172 | // } |
---|
173 | // gfan::ZMatrix zm(ambientDim*2,ambientDim+1); |
---|
174 | // int j=1; |
---|
175 | // for (int i=0; i<ambientDim*2; i=i+2) |
---|
176 | // { |
---|
177 | // zm[i][0] = 1; |
---|
178 | // zm[i][j] = 1; |
---|
179 | // zm[i+1][0] = 1; |
---|
180 | // zm[i+1][j] = -1; |
---|
181 | // j = j+1; |
---|
182 | // } |
---|
183 | // gfan::ZCone* zc = new gfan::ZCone(); |
---|
184 | // *zc = gfan::ZCone::givenByRays(zm, gfan::ZMatrix(0, zm.getWidth())); |
---|
185 | // res->rtyp = coneID; |
---|
186 | // res->data = (char *)zc; |
---|
187 | // return FALSE; |
---|
188 | // } |
---|
189 | // WerrorS("cross: unexpected parameters"); |
---|
190 | // return TRUE; |
---|
191 | // } |
---|
192 | |
---|
193 | |
---|
194 | BOOLEAN PMisLatticePolytope(leftv res, leftv args) |
---|
195 | { |
---|
196 | leftv u = args; |
---|
197 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
198 | { |
---|
199 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
200 | bool b; |
---|
201 | try |
---|
202 | { |
---|
203 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
204 | b = p->give("Lattice"); |
---|
205 | delete p; |
---|
206 | } |
---|
207 | catch (const std::exception& ex) |
---|
208 | { |
---|
209 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
210 | return TRUE; |
---|
211 | } |
---|
212 | res->rtyp = INT_CMD; |
---|
213 | res->data = (char*) (long) b; |
---|
214 | return FALSE; |
---|
215 | } |
---|
216 | WerrorS("isLatticePolytope: unexpected parameters"); |
---|
217 | return TRUE; |
---|
218 | } |
---|
219 | |
---|
220 | |
---|
221 | BOOLEAN PMisBounded(leftv res, leftv args) |
---|
222 | { |
---|
223 | leftv u = args; |
---|
224 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
225 | { |
---|
226 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
227 | bool b; |
---|
228 | try |
---|
229 | { |
---|
230 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
231 | b = p->give("BOUNDED"); |
---|
232 | delete p; |
---|
233 | } |
---|
234 | catch (const std::exception& ex) |
---|
235 | { |
---|
236 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
237 | return TRUE; |
---|
238 | } |
---|
239 | res->rtyp = INT_CMD; |
---|
240 | res->data = (char*) (long) b; |
---|
241 | return FALSE; |
---|
242 | } |
---|
243 | WerrorS("isBounded: unexpected parameters"); |
---|
244 | return TRUE; |
---|
245 | } |
---|
246 | |
---|
247 | |
---|
248 | BOOLEAN PMisReflexive(leftv res, leftv args) |
---|
249 | { |
---|
250 | leftv u = args; |
---|
251 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
252 | { |
---|
253 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
254 | bool b; |
---|
255 | try |
---|
256 | { |
---|
257 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
258 | b = p->give("REFLEXIVE"); |
---|
259 | delete p; |
---|
260 | } |
---|
261 | catch (const std::exception& ex) |
---|
262 | { |
---|
263 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
264 | return TRUE; |
---|
265 | } |
---|
266 | res->rtyp = INT_CMD; |
---|
267 | res->data = (char*) (long) b; |
---|
268 | return FALSE; |
---|
269 | } |
---|
270 | WerrorS("isReflexive: unexpected parameters"); |
---|
271 | return TRUE; |
---|
272 | } |
---|
273 | |
---|
274 | |
---|
275 | BOOLEAN PMisGorenstein(leftv res, leftv args) |
---|
276 | { |
---|
277 | leftv u = args; |
---|
278 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
279 | { |
---|
280 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
281 | bool b; |
---|
282 | try |
---|
283 | { |
---|
284 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
285 | b = p->give("GORENSTEIN"); |
---|
286 | delete p; |
---|
287 | } |
---|
288 | catch (const std::exception& ex) |
---|
289 | { |
---|
290 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
291 | return TRUE; |
---|
292 | } |
---|
293 | res->rtyp = INT_CMD; |
---|
294 | res->data = (char*) (long) b; |
---|
295 | return FALSE; |
---|
296 | } |
---|
297 | WerrorS("isGorenstein: unexpected parameters"); |
---|
298 | return TRUE; |
---|
299 | } |
---|
300 | |
---|
301 | |
---|
302 | BOOLEAN PMgorensteinIndex(leftv res, leftv args) |
---|
303 | { |
---|
304 | leftv u = args; |
---|
305 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
306 | { |
---|
307 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
308 | int gi; |
---|
309 | bool ok = true; |
---|
310 | try |
---|
311 | { |
---|
312 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
313 | bool b = p->give("GORENSTEIN"); |
---|
314 | if (b) |
---|
315 | { |
---|
316 | polymake::Integer pgi = p->give("GORENSTEIN_INDEX"); |
---|
317 | gi = PmInteger2Int(pgi,ok); |
---|
318 | delete p; |
---|
319 | } |
---|
320 | else |
---|
321 | { |
---|
322 | delete p; |
---|
323 | WerrorS("gorensteinIndex: input polytope not gorenstein"); |
---|
324 | return TRUE; |
---|
325 | } |
---|
326 | } |
---|
327 | catch (const std::exception& ex) |
---|
328 | { |
---|
329 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
330 | return TRUE; |
---|
331 | } |
---|
332 | if (!ok) |
---|
333 | { |
---|
334 | WerrorS("overflow while converting polymake::Integer to int"); |
---|
335 | return TRUE; |
---|
336 | } |
---|
337 | res->rtyp = INT_CMD; |
---|
338 | res->data = (char*) (long) gi; |
---|
339 | return FALSE; |
---|
340 | } |
---|
341 | WerrorS("gorensteinIndex: unexpected parameters"); |
---|
342 | return TRUE; |
---|
343 | } |
---|
344 | |
---|
345 | |
---|
346 | BOOLEAN PMgorensteinVector(leftv res, leftv args) |
---|
347 | { |
---|
348 | leftv u = args; |
---|
349 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
350 | { |
---|
351 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
352 | intvec* gv; |
---|
353 | bool ok = true; |
---|
354 | try |
---|
355 | { |
---|
356 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
357 | bool b = p->give("GORENSTEIN"); |
---|
358 | if (b) |
---|
359 | { |
---|
360 | polymake::Vector<polymake::Integer> pgv = p->give("GORENSTEIN_VECTOR"); |
---|
361 | gv = PmVectorInteger2Intvec(&pgv,ok); |
---|
362 | delete p; |
---|
363 | } |
---|
364 | else |
---|
365 | { |
---|
366 | delete p; |
---|
367 | WerrorS("gorensteinVector: input polytope not gorenstein"); |
---|
368 | return TRUE; |
---|
369 | } |
---|
370 | } |
---|
371 | catch (const std::exception& ex) |
---|
372 | { |
---|
373 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
374 | return TRUE; |
---|
375 | } |
---|
376 | if (!ok) |
---|
377 | { |
---|
378 | WerrorS("gorensteinVector: overflow in PmVectorInteger2Intvec"); |
---|
379 | return TRUE; |
---|
380 | } |
---|
381 | res->rtyp = INTVEC_CMD; |
---|
382 | res->data = (char*) gv; |
---|
383 | return FALSE; |
---|
384 | } |
---|
385 | WerrorS("gorensteinVector: unexpected parameters"); |
---|
386 | return TRUE; |
---|
387 | } |
---|
388 | |
---|
389 | |
---|
390 | BOOLEAN PMisCanonical(leftv res, leftv args) |
---|
391 | { |
---|
392 | leftv u = args; |
---|
393 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
394 | { |
---|
395 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
396 | bool b; |
---|
397 | try |
---|
398 | { |
---|
399 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
400 | b = p->give("CANONICAL"); |
---|
401 | delete p; |
---|
402 | } |
---|
403 | catch (const std::exception& ex) |
---|
404 | { |
---|
405 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
406 | return TRUE; |
---|
407 | } |
---|
408 | res->rtyp = INT_CMD; |
---|
409 | res->data = (char*) (long) b; |
---|
410 | return FALSE; |
---|
411 | } |
---|
412 | WerrorS("isCanonical: unexpected parameters"); |
---|
413 | return TRUE; |
---|
414 | } |
---|
415 | |
---|
416 | |
---|
417 | BOOLEAN PMisTerminal(leftv res, leftv args) |
---|
418 | { |
---|
419 | leftv u = args; |
---|
420 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
421 | { |
---|
422 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
423 | bool b; |
---|
424 | try |
---|
425 | { |
---|
426 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
427 | b = p->give("TERMINAL"); |
---|
428 | delete p; |
---|
429 | } |
---|
430 | catch (const std::exception& ex) |
---|
431 | { |
---|
432 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
433 | return TRUE; |
---|
434 | } |
---|
435 | res->rtyp = INT_CMD; |
---|
436 | res->data = (char*) (long) b; |
---|
437 | return FALSE; |
---|
438 | } |
---|
439 | WerrorS("isTerminal: unexpected parameters"); |
---|
440 | return TRUE; |
---|
441 | } |
---|
442 | |
---|
443 | |
---|
444 | BOOLEAN PMisLatticeEmpty(leftv res, leftv args) |
---|
445 | { |
---|
446 | leftv u = args; |
---|
447 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
448 | { |
---|
449 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
450 | bool b; |
---|
451 | try |
---|
452 | { |
---|
453 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
454 | b = p->give("LATTICE_EMPTY"); |
---|
455 | delete p; |
---|
456 | } |
---|
457 | catch (const std::exception& ex) |
---|
458 | { |
---|
459 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
460 | return TRUE; |
---|
461 | } |
---|
462 | res->rtyp = INT_CMD; |
---|
463 | res->data = (char*) (long) b; |
---|
464 | return FALSE; |
---|
465 | } |
---|
466 | WerrorS("isLatticeEmpty: unexpected parameters"); |
---|
467 | return TRUE; |
---|
468 | } |
---|
469 | |
---|
470 | |
---|
471 | BOOLEAN PMlatticeVolume(leftv res, leftv args) |
---|
472 | { |
---|
473 | leftv u = args; |
---|
474 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
475 | { |
---|
476 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
477 | int lv; |
---|
478 | bool ok = true; |
---|
479 | try |
---|
480 | { |
---|
481 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
482 | polymake::Integer plv = p->give("LATTICE_VOLUME"); |
---|
483 | delete p; |
---|
484 | lv = PmInteger2Int(plv,ok); |
---|
485 | } |
---|
486 | catch (const std::exception& ex) |
---|
487 | { |
---|
488 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
489 | return TRUE; |
---|
490 | } |
---|
491 | if (!ok) |
---|
492 | { |
---|
493 | WerrorS("overflow while converting polymake::Integer to int"); |
---|
494 | return TRUE; |
---|
495 | } |
---|
496 | res->rtyp = INT_CMD; |
---|
497 | res->data = (char*) (long) lv; |
---|
498 | return FALSE; |
---|
499 | } |
---|
500 | WerrorS("latticeVolume: unexpected parameters"); |
---|
501 | return TRUE; |
---|
502 | } |
---|
503 | |
---|
504 | |
---|
505 | BOOLEAN PMlatticeDegree(leftv res, leftv args) |
---|
506 | { |
---|
507 | leftv u = args; |
---|
508 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
509 | { |
---|
510 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
511 | int ld; |
---|
512 | bool ok = true; |
---|
513 | try |
---|
514 | { |
---|
515 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
516 | polymake::Integer pld = p->give("LATTICE_DEGREE"); |
---|
517 | delete p; |
---|
518 | ld = PmInteger2Int(pld,ok); |
---|
519 | } |
---|
520 | catch (const std::exception& ex) |
---|
521 | { |
---|
522 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
523 | return TRUE; |
---|
524 | } |
---|
525 | if (!ok) |
---|
526 | { |
---|
527 | WerrorS("overflow while converting polymake::Integer to int"); |
---|
528 | return TRUE; |
---|
529 | } |
---|
530 | res->rtyp = INT_CMD; |
---|
531 | res->data = (char*) (long) ld; |
---|
532 | return FALSE; |
---|
533 | } |
---|
534 | WerrorS("latticeDegree: unexpected parameters"); |
---|
535 | return TRUE; |
---|
536 | } |
---|
537 | |
---|
538 | |
---|
539 | BOOLEAN PMlatticeCodegree(leftv res, leftv args) |
---|
540 | { |
---|
541 | leftv u = args; |
---|
542 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
543 | { |
---|
544 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
545 | int lc; |
---|
546 | bool ok = true; |
---|
547 | try |
---|
548 | { |
---|
549 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
550 | polymake::Integer plc = p->give("LATTICE_CODEGREE"); |
---|
551 | delete p; |
---|
552 | lc = PmInteger2Int(plc,ok); |
---|
553 | } |
---|
554 | catch (const std::exception& ex) |
---|
555 | { |
---|
556 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
557 | return TRUE; |
---|
558 | } |
---|
559 | if (!ok) |
---|
560 | { |
---|
561 | WerrorS("overflow while converting polymake::Integer to int"); |
---|
562 | return TRUE; |
---|
563 | } |
---|
564 | res->rtyp = INT_CMD; |
---|
565 | res->data = (char*) (long) lc; |
---|
566 | return FALSE; |
---|
567 | } |
---|
568 | WerrorS("latticeCodegree: unexpected parameters"); |
---|
569 | return TRUE; |
---|
570 | } |
---|
571 | |
---|
572 | |
---|
573 | BOOLEAN PMehrhartPolynomialCoeff(leftv res, leftv args) |
---|
574 | { |
---|
575 | leftv u = args; |
---|
576 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
577 | { |
---|
578 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
579 | intvec* ec; |
---|
580 | bool ok = true; |
---|
581 | try |
---|
582 | { |
---|
583 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
584 | polymake::Vector<polymake::Integer> pec = p->give("EHRHART_POLYNOMIAL_COEFF"); |
---|
585 | delete p; |
---|
586 | ec = PmVectorInteger2Intvec(&pec,ok); |
---|
587 | } |
---|
588 | catch (const std::exception& ex) |
---|
589 | { |
---|
590 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
591 | return TRUE; |
---|
592 | } |
---|
593 | if (!ok) |
---|
594 | { |
---|
595 | WerrorS("ehrhartPolynomialCoeff: overflow in PmVectorInteger2Intvec"); |
---|
596 | return TRUE; |
---|
597 | } |
---|
598 | res->rtyp = INTVEC_CMD; |
---|
599 | res->data = (char*) ec; |
---|
600 | return FALSE; |
---|
601 | } |
---|
602 | WerrorS("ehrhartPolynomialCoeff: unexpected parameters"); |
---|
603 | return TRUE; |
---|
604 | } |
---|
605 | |
---|
606 | |
---|
607 | BOOLEAN PMfVector(leftv res, leftv args) |
---|
608 | { |
---|
609 | leftv u = args; |
---|
610 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
611 | { |
---|
612 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
613 | intvec* hv; |
---|
614 | bool ok = true; |
---|
615 | try |
---|
616 | { |
---|
617 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
618 | polymake::Vector<polymake::Integer> phv = p->give("F_VECTOR"); |
---|
619 | delete p; |
---|
620 | hv = PmVectorInteger2Intvec(&phv,ok); |
---|
621 | } |
---|
622 | catch (const std::exception& ex) |
---|
623 | { |
---|
624 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
625 | return TRUE; |
---|
626 | } |
---|
627 | if (!ok) |
---|
628 | { |
---|
629 | WerrorS("fVector: overflow in PmVectorInteger2Intvec"); |
---|
630 | return TRUE; |
---|
631 | } |
---|
632 | res->rtyp = INTVEC_CMD; |
---|
633 | res->data = (char*) hv; |
---|
634 | return FALSE; |
---|
635 | } |
---|
636 | WerrorS("fVector: unexpected parameters"); |
---|
637 | return TRUE; |
---|
638 | } |
---|
639 | |
---|
640 | |
---|
641 | BOOLEAN PMhVector(leftv res, leftv args) |
---|
642 | { |
---|
643 | leftv u = args; |
---|
644 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
645 | { |
---|
646 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
647 | intvec* hv; |
---|
648 | bool ok = true; |
---|
649 | try |
---|
650 | { |
---|
651 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
652 | polymake::Vector<polymake::Integer> phv = p->give("H_VECTOR"); |
---|
653 | delete p; |
---|
654 | hv = PmVectorInteger2Intvec(&phv,ok); |
---|
655 | } |
---|
656 | catch (const std::exception& ex) |
---|
657 | { |
---|
658 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
659 | return TRUE; |
---|
660 | } |
---|
661 | if (!ok) |
---|
662 | { |
---|
663 | WerrorS("hVector: overflow in PmVectorInteger2Intvec"); |
---|
664 | return TRUE; |
---|
665 | } |
---|
666 | res->rtyp = INTVEC_CMD; |
---|
667 | res->data = (char*) hv; |
---|
668 | return FALSE; |
---|
669 | } |
---|
670 | WerrorS("hVector: unexpected parameters"); |
---|
671 | return TRUE; |
---|
672 | } |
---|
673 | |
---|
674 | |
---|
675 | BOOLEAN PMhStarVector(leftv res, leftv args) |
---|
676 | { |
---|
677 | leftv u = args; |
---|
678 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
679 | { |
---|
680 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
681 | intvec* hv; |
---|
682 | bool ok = true; |
---|
683 | try |
---|
684 | { |
---|
685 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
686 | polymake::Vector<polymake::Integer> phv = p->give("H_STAR_VECTOR"); |
---|
687 | delete p; |
---|
688 | hv = PmVectorInteger2Intvec(&phv,ok); |
---|
689 | } |
---|
690 | catch (const std::exception& ex) |
---|
691 | { |
---|
692 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
693 | return TRUE; |
---|
694 | } |
---|
695 | if (!ok) |
---|
696 | { |
---|
697 | WerrorS("hStarVector: overflow in PmVectorInteger2Intvec"); |
---|
698 | return TRUE; |
---|
699 | } |
---|
700 | res->rtyp = INTVEC_CMD; |
---|
701 | res->data = (char*) hv; |
---|
702 | return FALSE; |
---|
703 | } |
---|
704 | WerrorS("hStarVector: unexpected parameters"); |
---|
705 | return TRUE; |
---|
706 | } |
---|
707 | |
---|
708 | |
---|
709 | BOOLEAN PMisNormal(leftv res, leftv args) |
---|
710 | { |
---|
711 | leftv u = args; |
---|
712 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
713 | { |
---|
714 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
715 | bool b; |
---|
716 | try |
---|
717 | { |
---|
718 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
719 | b = p->give("NORMAL"); |
---|
720 | delete p; |
---|
721 | } |
---|
722 | catch (const std::exception& ex) |
---|
723 | { |
---|
724 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
725 | return TRUE; |
---|
726 | } |
---|
727 | res->rtyp = INT_CMD; |
---|
728 | res->data = (char*) (long) b; |
---|
729 | return FALSE; |
---|
730 | } |
---|
731 | WerrorS("isNormal: unexpected parameters"); |
---|
732 | return TRUE; |
---|
733 | } |
---|
734 | |
---|
735 | |
---|
736 | BOOLEAN PMfacetWidths(leftv res, leftv args) |
---|
737 | { |
---|
738 | leftv u = args; |
---|
739 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
740 | { |
---|
741 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
742 | intvec* fw; |
---|
743 | bool ok = true; |
---|
744 | try |
---|
745 | { |
---|
746 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
747 | polymake::Vector<polymake::Integer> pfw = p->give("FACET_WIDTHS"); |
---|
748 | delete p; |
---|
749 | fw = PmVectorInteger2Intvec(&pfw,ok); |
---|
750 | } |
---|
751 | catch (const std::exception& ex) |
---|
752 | { |
---|
753 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
754 | return TRUE; |
---|
755 | } |
---|
756 | if (!ok) |
---|
757 | { |
---|
758 | WerrorS("facetWidths: overflow in PmVectorInteger2Intvec"); |
---|
759 | return TRUE; |
---|
760 | } |
---|
761 | res->rtyp = INTVEC_CMD; |
---|
762 | res->data = (char*) fw; |
---|
763 | return FALSE; |
---|
764 | } |
---|
765 | WerrorS("facetWidths: unexpected parameters"); |
---|
766 | return TRUE; |
---|
767 | } |
---|
768 | |
---|
769 | |
---|
770 | BOOLEAN PMfacetWidth(leftv res, leftv args) |
---|
771 | { |
---|
772 | leftv u = args; |
---|
773 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
774 | { |
---|
775 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
776 | int fw; |
---|
777 | bool ok = true; |
---|
778 | try |
---|
779 | { |
---|
780 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
781 | polymake::Integer pfw = p->give("FACET_WIDTH"); |
---|
782 | delete p; |
---|
783 | fw = PmInteger2Int(pfw,ok); |
---|
784 | } |
---|
785 | catch (const std::exception& ex) |
---|
786 | { |
---|
787 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
788 | return TRUE; |
---|
789 | } |
---|
790 | if (!ok) |
---|
791 | { |
---|
792 | WerrorS("overflow while converting polymake::Integer to int"); |
---|
793 | return TRUE; |
---|
794 | } |
---|
795 | res->rtyp = INT_CMD; |
---|
796 | res->data = (char*) (long) fw; |
---|
797 | return FALSE; |
---|
798 | } |
---|
799 | WerrorS("facetWidth: unexpected parameters"); |
---|
800 | return TRUE; |
---|
801 | } |
---|
802 | |
---|
803 | |
---|
804 | BOOLEAN PMfacetVertexLatticeDistances(leftv res, leftv args) |
---|
805 | { |
---|
806 | leftv u = args; |
---|
807 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
808 | { |
---|
809 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
810 | intvec* ld; |
---|
811 | bool ok=true; |
---|
812 | try |
---|
813 | { |
---|
814 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
815 | polymake::Matrix<polymake::Integer> pld = p->give("FACET_VERTEX_LATTICE_DISTANCES"); |
---|
816 | delete p; |
---|
817 | ld = PmMatrixInteger2Intvec(&pld,ok); |
---|
818 | } |
---|
819 | catch (const std::exception& ex) |
---|
820 | { |
---|
821 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
822 | return TRUE; |
---|
823 | } |
---|
824 | if (!ok) |
---|
825 | { |
---|
826 | WerrorS("overflow while converting polymake::Integer to int"); |
---|
827 | return TRUE; |
---|
828 | } |
---|
829 | res->rtyp = INTMAT_CMD; |
---|
830 | res->data = (char*) ld; |
---|
831 | return FALSE; |
---|
832 | } |
---|
833 | WerrorS("facetVertexLatticeDistances: unexpected parameters"); |
---|
834 | return TRUE; |
---|
835 | } |
---|
836 | |
---|
837 | |
---|
838 | BOOLEAN PMisCompressed(leftv res, leftv args) |
---|
839 | { |
---|
840 | leftv u = args; |
---|
841 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
842 | { |
---|
843 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
844 | bool b; |
---|
845 | try |
---|
846 | { |
---|
847 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
848 | b = p->give("COMPRESSED"); |
---|
849 | delete p; |
---|
850 | } |
---|
851 | catch (const std::exception& ex) |
---|
852 | { |
---|
853 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
854 | return TRUE; |
---|
855 | } |
---|
856 | res->rtyp = INT_CMD; |
---|
857 | res->data = (char*) (long) b; |
---|
858 | return FALSE; |
---|
859 | } |
---|
860 | WerrorS("isCompressed: unexpected parameters"); |
---|
861 | return TRUE; |
---|
862 | } |
---|
863 | |
---|
864 | |
---|
865 | BOOLEAN PMisSmooth(leftv res, leftv args) |
---|
866 | { |
---|
867 | leftv u = args; |
---|
868 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
869 | { |
---|
870 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
871 | bool b; |
---|
872 | try |
---|
873 | { |
---|
874 | polymake::perl::Object* p = ZCone2PmCone(zc); |
---|
875 | b = p->give("SMOOTH_CONE"); |
---|
876 | delete p; |
---|
877 | } |
---|
878 | catch (const std::exception& ex) |
---|
879 | { |
---|
880 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
881 | return TRUE; |
---|
882 | } |
---|
883 | res->rtyp = INT_CMD; |
---|
884 | res->data = (char*) (long) b; |
---|
885 | return FALSE; |
---|
886 | } |
---|
887 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
888 | { |
---|
889 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
890 | bool b; |
---|
891 | try |
---|
892 | { |
---|
893 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
894 | b = p->give("SMOOTH"); |
---|
895 | delete p; |
---|
896 | } |
---|
897 | catch (const std::exception& ex) |
---|
898 | { |
---|
899 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
900 | return TRUE; |
---|
901 | } |
---|
902 | res->rtyp = INT_CMD; |
---|
903 | res->data = (char*) (long) b; |
---|
904 | return FALSE; |
---|
905 | } |
---|
906 | if ((u != NULL) && (u->Typ() == fanID)) |
---|
907 | { |
---|
908 | gfan::ZFan* zf = (gfan::ZFan*)u->Data(); |
---|
909 | bool b; |
---|
910 | try |
---|
911 | { |
---|
912 | polymake::perl::Object* p = ZFan2PmFan(zf); |
---|
913 | b = p->give("SMOOTH_FAN"); |
---|
914 | delete p; |
---|
915 | } |
---|
916 | catch (const std::exception& ex) |
---|
917 | { |
---|
918 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
919 | return TRUE; |
---|
920 | } |
---|
921 | res->rtyp = INT_CMD; |
---|
922 | res->data = (char*) (long) b; |
---|
923 | return FALSE; |
---|
924 | } |
---|
925 | WerrorS("isSmooth: unexpected parameters"); |
---|
926 | return TRUE; |
---|
927 | } |
---|
928 | |
---|
929 | |
---|
930 | BOOLEAN PMisVeryAmple(leftv res, leftv args) |
---|
931 | { |
---|
932 | leftv u = args; |
---|
933 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
934 | { |
---|
935 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
936 | bool b; |
---|
937 | try |
---|
938 | { |
---|
939 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
940 | b = p->give("VERY_AMPLE"); |
---|
941 | delete p; |
---|
942 | } |
---|
943 | catch (const std::exception& ex) |
---|
944 | { |
---|
945 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
946 | return TRUE; |
---|
947 | } |
---|
948 | res->rtyp = INT_CMD; |
---|
949 | res->data = (char*) (long) b; |
---|
950 | return FALSE; |
---|
951 | } |
---|
952 | WerrorS("isVeryAmple: unexpected parameters"); |
---|
953 | return TRUE; |
---|
954 | } |
---|
955 | |
---|
956 | |
---|
957 | BOOLEAN PMlatticePoints(leftv res, leftv args) |
---|
958 | { |
---|
959 | leftv u = args; |
---|
960 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
961 | { |
---|
962 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
963 | intvec* iv; |
---|
964 | bool ok = true; |
---|
965 | try |
---|
966 | { |
---|
967 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
968 | polymake::Matrix<polymake::Integer> lp = p->give("LATTICE_POINTS"); |
---|
969 | delete p; |
---|
970 | iv = PmMatrixInteger2Intvec(&lp,ok); |
---|
971 | } |
---|
972 | catch (const std::exception& ex) |
---|
973 | { |
---|
974 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
975 | return TRUE; |
---|
976 | } |
---|
977 | if (!ok) |
---|
978 | { |
---|
979 | WerrorS("overflow while converting polymake::Integer to int"); |
---|
980 | return TRUE; |
---|
981 | } |
---|
982 | res->rtyp = INTMAT_CMD; |
---|
983 | res->data = (char*) iv; |
---|
984 | return FALSE; |
---|
985 | } |
---|
986 | WerrorS("LatticePoints: unexpected parameters"); |
---|
987 | return TRUE; |
---|
988 | } |
---|
989 | |
---|
990 | |
---|
991 | BOOLEAN PMnLatticePoints(leftv res, leftv args) |
---|
992 | { |
---|
993 | leftv u = args; |
---|
994 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
995 | { |
---|
996 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
997 | int n; |
---|
998 | bool ok = true; |
---|
999 | try |
---|
1000 | { |
---|
1001 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
1002 | polymake::Integer nlp = p->give("N_LATTICE_POINTS"); |
---|
1003 | delete p; |
---|
1004 | n = PmInteger2Int(nlp,ok); |
---|
1005 | } |
---|
1006 | catch (const std::exception& ex) |
---|
1007 | { |
---|
1008 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
1009 | return TRUE; |
---|
1010 | } |
---|
1011 | if (!ok) |
---|
1012 | { |
---|
1013 | WerrorS("overflow while converting polymake::Integer to int"); |
---|
1014 | return TRUE; |
---|
1015 | } |
---|
1016 | res->rtyp = INT_CMD; |
---|
1017 | res->data = (char*) (long) n; |
---|
1018 | return FALSE; |
---|
1019 | } |
---|
1020 | WerrorS("nLatticePoints: unexpected parameters"); |
---|
1021 | return TRUE; |
---|
1022 | } |
---|
1023 | |
---|
1024 | |
---|
1025 | BOOLEAN PMinteriorLatticePoints(leftv res, leftv args) |
---|
1026 | { |
---|
1027 | leftv u = args; |
---|
1028 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
1029 | { |
---|
1030 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
1031 | intvec* iv; |
---|
1032 | bool ok = true; |
---|
1033 | try |
---|
1034 | { |
---|
1035 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
1036 | polymake::Matrix<polymake::Integer> lp = p->give("INTERIOR_LATTICE_POINTS"); |
---|
1037 | delete p; |
---|
1038 | iv = PmMatrixInteger2Intvec(&lp,ok); |
---|
1039 | } |
---|
1040 | catch (const std::exception& ex) |
---|
1041 | { |
---|
1042 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
1043 | return TRUE; |
---|
1044 | } |
---|
1045 | if (!ok) |
---|
1046 | { |
---|
1047 | WerrorS("overflow while converting polymake::Integer to int"); |
---|
1048 | return TRUE; |
---|
1049 | } |
---|
1050 | res->rtyp = INTMAT_CMD; |
---|
1051 | res->data = (char*) iv; |
---|
1052 | return FALSE; |
---|
1053 | } |
---|
1054 | WerrorS("interiorLatticePoints: unexpected parameters"); |
---|
1055 | return TRUE; |
---|
1056 | } |
---|
1057 | |
---|
1058 | |
---|
1059 | BOOLEAN PMnInteriorLatticePoints(leftv res, leftv args) |
---|
1060 | { |
---|
1061 | leftv u = args; |
---|
1062 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
1063 | { |
---|
1064 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
1065 | int n; |
---|
1066 | bool ok = true; |
---|
1067 | try |
---|
1068 | { |
---|
1069 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
1070 | polymake::Integer nlp = p->give("N_INTERIOR_LATTICE_POINTS"); |
---|
1071 | delete p; |
---|
1072 | n = PmInteger2Int(nlp,ok); |
---|
1073 | } |
---|
1074 | catch (const std::exception& ex) |
---|
1075 | { |
---|
1076 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
1077 | return TRUE; |
---|
1078 | } |
---|
1079 | if (!ok) |
---|
1080 | { |
---|
1081 | WerrorS("overflow while converting polymake::Integer to int"); |
---|
1082 | return TRUE; |
---|
1083 | } |
---|
1084 | res->rtyp = INT_CMD; |
---|
1085 | res->data = (char*) (long) n; |
---|
1086 | return FALSE; |
---|
1087 | } |
---|
1088 | WerrorS("nInteriorLatticePoints: unexpected parameters"); |
---|
1089 | return TRUE; |
---|
1090 | } |
---|
1091 | |
---|
1092 | |
---|
1093 | BOOLEAN PMboundaryLatticePoints(leftv res, leftv args) |
---|
1094 | { |
---|
1095 | leftv u = args; |
---|
1096 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
1097 | { |
---|
1098 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
1099 | intvec* iv; |
---|
1100 | bool ok = true; |
---|
1101 | try |
---|
1102 | { |
---|
1103 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
1104 | polymake::Matrix<polymake::Integer> lp = p->give("BOUNDARY_LATTICE_POINTS"); |
---|
1105 | delete p; |
---|
1106 | iv = PmMatrixInteger2Intvec(&lp,ok); |
---|
1107 | } |
---|
1108 | catch (const std::exception& ex) |
---|
1109 | { |
---|
1110 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
1111 | return TRUE; |
---|
1112 | } |
---|
1113 | if (!ok) |
---|
1114 | { |
---|
1115 | WerrorS("overflow while converting polymake::Integer to int"); |
---|
1116 | return TRUE; |
---|
1117 | } |
---|
1118 | res->rtyp = INTMAT_CMD; |
---|
1119 | res->data = (char*) iv; |
---|
1120 | return FALSE; |
---|
1121 | } |
---|
1122 | WerrorS("boundaryLatticePoints: unexpected parameters"); |
---|
1123 | return TRUE; |
---|
1124 | } |
---|
1125 | |
---|
1126 | |
---|
1127 | BOOLEAN PMnBoundaryLatticePoints(leftv res, leftv args) |
---|
1128 | { |
---|
1129 | leftv u = args; |
---|
1130 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
1131 | { |
---|
1132 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
1133 | int n; |
---|
1134 | bool ok = true; |
---|
1135 | try |
---|
1136 | { |
---|
1137 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
1138 | polymake::Integer nlp = p->give("N_BOUNDARY_LATTICE_POINTS"); |
---|
1139 | delete p; |
---|
1140 | n = PmInteger2Int(nlp,ok); |
---|
1141 | } |
---|
1142 | catch (const std::exception& ex) |
---|
1143 | { |
---|
1144 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
1145 | return TRUE; |
---|
1146 | } |
---|
1147 | if (!ok) |
---|
1148 | { |
---|
1149 | WerrorS("overflow while converting polymake::Integer to int"); |
---|
1150 | return TRUE; |
---|
1151 | } |
---|
1152 | res->rtyp = INT_CMD; |
---|
1153 | res->data = (char*) (long) n; |
---|
1154 | return FALSE; |
---|
1155 | } |
---|
1156 | WerrorS("nBoundaryLatticePoints: unexpected parameters"); |
---|
1157 | return TRUE; |
---|
1158 | } |
---|
1159 | |
---|
1160 | |
---|
1161 | BOOLEAN PMhilbertBasis(leftv res, leftv args) |
---|
1162 | { |
---|
1163 | leftv u = args; |
---|
1164 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
1165 | { |
---|
1166 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
1167 | intvec* iv; |
---|
1168 | bool ok = true; |
---|
1169 | try |
---|
1170 | { |
---|
1171 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
1172 | polymake::Matrix<polymake::Integer> lp = p->give("HILBERT_BASIS"); |
---|
1173 | delete p; |
---|
1174 | iv = PmMatrixInteger2Intvec(&lp,ok); |
---|
1175 | } |
---|
1176 | catch (const std::exception& ex) |
---|
1177 | { |
---|
1178 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
1179 | return TRUE; |
---|
1180 | } |
---|
1181 | if (!ok) |
---|
1182 | { |
---|
1183 | WerrorS("overflow while converting polymake::Integer to int"); |
---|
1184 | return TRUE; |
---|
1185 | } |
---|
1186 | res->rtyp = INTMAT_CMD; |
---|
1187 | res->data = (char*) iv; |
---|
1188 | return FALSE; |
---|
1189 | } |
---|
1190 | WerrorS("hilbertBasis: unexpected parameters"); |
---|
1191 | return TRUE; |
---|
1192 | } |
---|
1193 | |
---|
1194 | |
---|
1195 | BOOLEAN PMnHilbertBasis(leftv res, leftv args) |
---|
1196 | { |
---|
1197 | leftv u = args; |
---|
1198 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
1199 | { |
---|
1200 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
1201 | int n; |
---|
1202 | bool ok = true; |
---|
1203 | try |
---|
1204 | { |
---|
1205 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
1206 | polymake::Integer nlp = p->give("N_HILBERT_BASIS"); |
---|
1207 | delete p; |
---|
1208 | n = PmInteger2Int(nlp,ok); |
---|
1209 | } |
---|
1210 | catch (const std::exception& ex) |
---|
1211 | { |
---|
1212 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
1213 | return TRUE; |
---|
1214 | } |
---|
1215 | if (!ok) |
---|
1216 | { |
---|
1217 | WerrorS("overflow while converting polymake::Integer to int"); |
---|
1218 | return TRUE; |
---|
1219 | } |
---|
1220 | res->rtyp = INT_CMD; |
---|
1221 | res->data = (char*) (long) n; |
---|
1222 | return FALSE; |
---|
1223 | } |
---|
1224 | WerrorS("nHilbertBasis: unexpected parameters"); |
---|
1225 | return TRUE; |
---|
1226 | } |
---|
1227 | |
---|
1228 | |
---|
1229 | BOOLEAN PMminkowskiSum(leftv res, leftv args) |
---|
1230 | { |
---|
1231 | leftv u = args; |
---|
1232 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
1233 | { |
---|
1234 | leftv v = u->next; |
---|
1235 | if ((v != NULL) && (v->Typ() == polytopeID)) |
---|
1236 | { |
---|
1237 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
1238 | gfan::ZCone* zq = (gfan::ZCone*)v->Data(); |
---|
1239 | gfan::ZCone* ms; |
---|
1240 | try |
---|
1241 | { |
---|
1242 | polymake::perl::Object* pp = ZPolytope2PmPolytope(zp); |
---|
1243 | polymake::perl::Object* pq = ZPolytope2PmPolytope(zq); |
---|
1244 | polymake::perl::Object pms; |
---|
1245 | CallPolymakeFunction("minkowski_sum", *pp, *pq) >> pms; |
---|
1246 | delete pp; |
---|
1247 | delete pq; |
---|
1248 | ms = PmPolytope2ZPolytope(&pms); |
---|
1249 | } |
---|
1250 | catch (const std::exception& ex) |
---|
1251 | { |
---|
1252 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
1253 | return TRUE; |
---|
1254 | } |
---|
1255 | res->rtyp = polytopeID; |
---|
1256 | res->data = (char*) ms; |
---|
1257 | return FALSE; |
---|
1258 | } |
---|
1259 | if ((v != NULL) && (v->Typ() == coneID)) |
---|
1260 | { |
---|
1261 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
1262 | gfan::ZCone* zc = (gfan::ZCone*)v->Data(); |
---|
1263 | gfan::ZCone* zq = new gfan::ZCone(liftUp(*zc)); |
---|
1264 | gfan::ZCone* ms; |
---|
1265 | try |
---|
1266 | { |
---|
1267 | polymake::perl::Object* pp = ZPolytope2PmPolytope(zp); |
---|
1268 | polymake::perl::Object* pq = ZPolytope2PmPolytope(zq); |
---|
1269 | polymake::perl::Object pms; |
---|
1270 | CallPolymakeFunction("minkowski_sum", *pp, *pq) >> pms; |
---|
1271 | delete pp; |
---|
1272 | delete pq; |
---|
1273 | ms = PmPolytope2ZPolytope(&pms); |
---|
1274 | } |
---|
1275 | catch (const std::exception& ex) |
---|
1276 | { |
---|
1277 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
1278 | delete zq; |
---|
1279 | return TRUE; |
---|
1280 | } |
---|
1281 | res->rtyp = polytopeID; |
---|
1282 | res->data = (char*) ms; |
---|
1283 | delete zq; |
---|
1284 | return FALSE; |
---|
1285 | } |
---|
1286 | } |
---|
1287 | if ((u != NULL) && (u->Typ() == coneID)) |
---|
1288 | { |
---|
1289 | leftv v = u->next; |
---|
1290 | if ((v != NULL) && (v->Typ() == polytopeID)) |
---|
1291 | { |
---|
1292 | gfan::ZCone* zc = (gfan::ZCone*)u->Data(); |
---|
1293 | gfan::ZCone* zp = new gfan::ZCone(liftUp(*zc)); |
---|
1294 | gfan::ZCone* zq = (gfan::ZCone*)v->Data(); |
---|
1295 | gfan::ZCone* ms; |
---|
1296 | try |
---|
1297 | { |
---|
1298 | polymake::perl::Object* pp = ZPolytope2PmPolytope(zp); |
---|
1299 | polymake::perl::Object* pq = ZPolytope2PmPolytope(zq); |
---|
1300 | polymake::perl::Object pms; |
---|
1301 | CallPolymakeFunction("minkowski_sum", *pp, *pq) >> pms; |
---|
1302 | delete pp; |
---|
1303 | delete pq; |
---|
1304 | ms = PmPolytope2ZPolytope(&pms); |
---|
1305 | } |
---|
1306 | catch (const std::exception& ex) |
---|
1307 | { |
---|
1308 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
1309 | delete zp; |
---|
1310 | return TRUE; |
---|
1311 | } |
---|
1312 | res->rtyp = polytopeID; |
---|
1313 | res->data = (char*) ms; |
---|
1314 | delete zp; |
---|
1315 | return FALSE; |
---|
1316 | } |
---|
1317 | if ((v != NULL) && (v->Typ() == coneID)) |
---|
1318 | { |
---|
1319 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
1320 | gfan::ZCone* zq = (gfan::ZCone*)v->Data(); |
---|
1321 | gfan::ZCone* ms; |
---|
1322 | try |
---|
1323 | { |
---|
1324 | polymake::perl::Object* pp = ZPolytope2PmPolytope(zp); |
---|
1325 | polymake::perl::Object* pq = ZPolytope2PmPolytope(zq); |
---|
1326 | polymake::perl::Object pms; |
---|
1327 | CallPolymakeFunction("minkowski_sum", *pp, *pq) >> pms; |
---|
1328 | delete pp; |
---|
1329 | delete pq; |
---|
1330 | ms = PmPolytope2ZPolytope(&pms); |
---|
1331 | } |
---|
1332 | catch (const std::exception& ex) |
---|
1333 | { |
---|
1334 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
1335 | return TRUE; |
---|
1336 | } |
---|
1337 | res->rtyp = coneID; |
---|
1338 | res->data = (char*) ms; |
---|
1339 | return FALSE; |
---|
1340 | } |
---|
1341 | } |
---|
1342 | WerrorS("minkowskiSum: unexpected parameters"); |
---|
1343 | return TRUE; |
---|
1344 | } |
---|
1345 | |
---|
1346 | |
---|
1347 | polymake::Matrix<polymake::Integer> verticesOf(const polymake::perl::Object* p, |
---|
1348 | const polymake::Set<polymake::Integer>* s) |
---|
1349 | { |
---|
1350 | polymake::Matrix<polymake::Integer> allrays = p->give("VERTICES"); |
---|
1351 | polymake::Matrix<polymake::Integer> wantedrays; |
---|
1352 | bool ok = true; |
---|
1353 | for(polymake::Entire<polymake::Set<polymake::Integer> >::const_iterator i=polymake::entire(*s); !i.at_end(); i++) |
---|
1354 | { |
---|
1355 | wantedrays = wantedrays / allrays.row(PmInteger2Int(*i,ok)); |
---|
1356 | } |
---|
1357 | if (!ok) |
---|
1358 | { |
---|
1359 | WerrorS("overflow while converting polymake::Integer to int in raysOf"); |
---|
1360 | } |
---|
1361 | return wantedrays; |
---|
1362 | } |
---|
1363 | |
---|
1364 | |
---|
1365 | BOOLEAN PMmaximalFace(leftv res, leftv args) |
---|
1366 | { |
---|
1367 | leftv u = args; |
---|
1368 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
1369 | { |
---|
1370 | leftv v = u->next; |
---|
1371 | if ((v != NULL) && (v->Typ() == INTVEC_CMD)) |
---|
1372 | { |
---|
1373 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
1374 | intvec* iv = (intvec*) v->Data(); |
---|
1375 | intvec* maxface; |
---|
1376 | bool ok = true; |
---|
1377 | try |
---|
1378 | { |
---|
1379 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
1380 | polymake::perl::Object o("LinearProgram<Rational>"); |
---|
1381 | o.take("LINEAR_OBJECTIVE") << Intvec2PmVectorInteger(iv); |
---|
1382 | p->take("LP") << o; |
---|
1383 | polymake::Set<polymake::Integer> mf = p->give("LP.MAXIMAL_FACE"); |
---|
1384 | polymake::Matrix<polymake::Integer> vertices = verticesOf(p,&mf); |
---|
1385 | delete p; |
---|
1386 | maxface = new intvec(PmMatrixInteger2Intvec(&vertices,ok)); |
---|
1387 | } |
---|
1388 | catch (const std::exception& ex) |
---|
1389 | { |
---|
1390 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
1391 | return TRUE; |
---|
1392 | } |
---|
1393 | if (!ok) |
---|
1394 | { |
---|
1395 | WerrorS("overflow while converting polymake::Integer to int"); |
---|
1396 | return TRUE; |
---|
1397 | } |
---|
1398 | res->rtyp = INTVEC_CMD; |
---|
1399 | res->data = (char*) maxface; |
---|
1400 | return FALSE; |
---|
1401 | } |
---|
1402 | } |
---|
1403 | WerrorS("maximalFace: unexpected parameters"); |
---|
1404 | return TRUE; |
---|
1405 | } |
---|
1406 | |
---|
1407 | |
---|
1408 | BOOLEAN PMminimalFace(leftv res, leftv args) |
---|
1409 | { |
---|
1410 | leftv u = args; |
---|
1411 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
1412 | { |
---|
1413 | leftv v = u->next; |
---|
1414 | if ((v != NULL) && (v->Typ() == INTVEC_CMD)) |
---|
1415 | { |
---|
1416 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
1417 | intvec* iv = (intvec*) v->Data(); |
---|
1418 | intvec* minface; |
---|
1419 | bool ok = true; |
---|
1420 | try |
---|
1421 | { |
---|
1422 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
1423 | polymake::perl::Object o("LinearProgram<Rational>"); |
---|
1424 | o.take("LINEAR_OBJECTIVE") << Intvec2PmVectorInteger(iv); |
---|
1425 | p->take("LP") << o; |
---|
1426 | polymake::Set<polymake::Integer> mf = p->give("LP.MINIMAL_FACE"); |
---|
1427 | polymake::Matrix<polymake::Integer> vertices = verticesOf(p,&mf); |
---|
1428 | delete p; |
---|
1429 | minface = new intvec(PmMatrixInteger2Intvec(&vertices,ok)); |
---|
1430 | } |
---|
1431 | catch (const std::exception& ex) |
---|
1432 | { |
---|
1433 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
1434 | return TRUE; |
---|
1435 | } |
---|
1436 | if (!ok) |
---|
1437 | { |
---|
1438 | WerrorS("overflow while converting polymake::Integer to int"); |
---|
1439 | return TRUE; |
---|
1440 | } |
---|
1441 | res->rtyp = INTVEC_CMD; |
---|
1442 | res->data = (char*) minface; |
---|
1443 | return FALSE; |
---|
1444 | } |
---|
1445 | } |
---|
1446 | WerrorS("minimalFace: unexpected parameters"); |
---|
1447 | return TRUE; |
---|
1448 | } |
---|
1449 | |
---|
1450 | |
---|
1451 | BOOLEAN PMmaximalValue(leftv res, leftv args) |
---|
1452 | { |
---|
1453 | leftv u = args; |
---|
1454 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
1455 | { |
---|
1456 | leftv v = u->next; |
---|
1457 | if ((v != NULL) && (v->Typ() == INTVEC_CMD)) |
---|
1458 | { |
---|
1459 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
1460 | intvec* iv = (intvec*) v->Data(); |
---|
1461 | if (iv->rows()==zp->ambientDimension()) |
---|
1462 | { |
---|
1463 | int m; |
---|
1464 | bool ok = true; |
---|
1465 | try |
---|
1466 | { |
---|
1467 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
1468 | polymake::Vector<polymake::Integer> lo = Intvec2PmVectorInteger(iv); |
---|
1469 | polymake::perl::Object o("LinearProgram<Rational>"); |
---|
1470 | o.take("LINEAR_OBJECTIVE") << lo; |
---|
1471 | p->take("LP") << o; |
---|
1472 | polymake::Integer mv = p->give("LP.MAXIMAL_VALUE"); |
---|
1473 | delete p; |
---|
1474 | m = PmInteger2Int(mv,ok); |
---|
1475 | } |
---|
1476 | catch (const std::exception& ex) |
---|
1477 | { |
---|
1478 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
1479 | return TRUE; |
---|
1480 | } |
---|
1481 | if (!ok) |
---|
1482 | { |
---|
1483 | WerrorS("overflow while converting polymake::Integer to int"); |
---|
1484 | return TRUE; |
---|
1485 | } |
---|
1486 | res->rtyp = INT_CMD; |
---|
1487 | res->data = (char*) (long) m; |
---|
1488 | return FALSE; |
---|
1489 | } |
---|
1490 | } |
---|
1491 | WerrorS("maximalValue: vector is of wrong size"); |
---|
1492 | return TRUE; |
---|
1493 | } |
---|
1494 | WerrorS("maximalValue: unexpected parameters"); |
---|
1495 | return TRUE; |
---|
1496 | } |
---|
1497 | |
---|
1498 | BOOLEAN PMminimalValue(leftv res, leftv args) |
---|
1499 | { |
---|
1500 | leftv u = args; |
---|
1501 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
1502 | { |
---|
1503 | leftv v = u->next; |
---|
1504 | if ((v != NULL) && (v->Typ() == INTVEC_CMD)) |
---|
1505 | { |
---|
1506 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
1507 | intvec* iv = (intvec*) v->Data(); |
---|
1508 | if (iv->rows()==zp->ambientDimension()) |
---|
1509 | { |
---|
1510 | int m; |
---|
1511 | bool ok = true; |
---|
1512 | try |
---|
1513 | { |
---|
1514 | polymake::perl::Object* p = ZPolytope2PmPolytope(zp); |
---|
1515 | polymake::Vector<polymake::Integer> lo = Intvec2PmVectorInteger(iv); |
---|
1516 | polymake::perl::Object o("LinearProgram<Rational>"); |
---|
1517 | o.take("LINEAR_OBJECTIVE") << lo; |
---|
1518 | p->take("LP") << o; |
---|
1519 | polymake::Integer mv = p->give("LP.MINIMAL_VALUE"); |
---|
1520 | delete p; |
---|
1521 | m = PmInteger2Int(mv,ok); |
---|
1522 | } |
---|
1523 | catch (const std::exception& ex) |
---|
1524 | { |
---|
1525 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
1526 | return TRUE; |
---|
1527 | } |
---|
1528 | if (!ok) |
---|
1529 | { |
---|
1530 | WerrorS("overflow while converting polymake::Integer to int"); |
---|
1531 | return TRUE; |
---|
1532 | } |
---|
1533 | res->rtyp = INT_CMD; |
---|
1534 | res->data = (char*) (long) m; |
---|
1535 | return FALSE; |
---|
1536 | } |
---|
1537 | } |
---|
1538 | WerrorS("minimalValue: vector is of wrong size"); |
---|
1539 | return TRUE; |
---|
1540 | } |
---|
1541 | WerrorS("minimalValue: unexpected parameters"); |
---|
1542 | return TRUE; |
---|
1543 | } |
---|
1544 | |
---|
1545 | |
---|
1546 | BOOLEAN visual(leftv res, leftv args) |
---|
1547 | { |
---|
1548 | leftv u = args; |
---|
1549 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
1550 | { |
---|
1551 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
1552 | try |
---|
1553 | { |
---|
1554 | polymake::perl::Object* pp = ZPolytope2PmPolytope(zp); |
---|
1555 | VoidCallPolymakeFunction("jreality",pp->CallPolymakeMethod("VISUAL")); |
---|
1556 | delete pp; |
---|
1557 | } |
---|
1558 | catch (const std::exception& ex) |
---|
1559 | { |
---|
1560 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
1561 | return TRUE; |
---|
1562 | } |
---|
1563 | res->rtyp = NONE; |
---|
1564 | res->data = NULL; |
---|
1565 | return FALSE; |
---|
1566 | } |
---|
1567 | if ((u != NULL) && (u->Typ() == fanID)) |
---|
1568 | { |
---|
1569 | gfan::ZFan* zf = (gfan::ZFan*)u->Data(); |
---|
1570 | try |
---|
1571 | { |
---|
1572 | polymake::perl::Object* pf=ZFan2PmFan(zf); |
---|
1573 | VoidCallPolymakeFunction("jreality",pf->CallPolymakeMethod("VISUAL")); |
---|
1574 | } |
---|
1575 | catch (const std::exception& ex) |
---|
1576 | { |
---|
1577 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
1578 | return TRUE; |
---|
1579 | } |
---|
1580 | res->rtyp = NONE; |
---|
1581 | res->data = NULL; |
---|
1582 | return FALSE; |
---|
1583 | } |
---|
1584 | WerrorS("visual: unexpected parameters"); |
---|
1585 | return TRUE; |
---|
1586 | } |
---|
1587 | |
---|
1588 | BOOLEAN normalFan(leftv res, leftv args) |
---|
1589 | { |
---|
1590 | leftv u = args; |
---|
1591 | if ((u != NULL) && (u->Typ() == polytopeID)) |
---|
1592 | { |
---|
1593 | gfan::ZCone* zp = (gfan::ZCone*)u->Data(); |
---|
1594 | gfan::ZFan* zf = new gfan::ZFan(0); |
---|
1595 | try |
---|
1596 | { |
---|
1597 | polymake::perl::Object* p=ZPolytope2PmPolytope(zp); |
---|
1598 | polymake::perl::Object pf; |
---|
1599 | CallPolymakeFunction("normal_fan", *p) >> pf; |
---|
1600 | delete p; |
---|
1601 | zf = PmFan2ZFan(&pf); |
---|
1602 | } |
---|
1603 | catch (const std::exception& ex) |
---|
1604 | { |
---|
1605 | WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n"); |
---|
1606 | return TRUE; |
---|
1607 | } |
---|
1608 | res->rtyp = fanID; |
---|
1609 | res->data = (char*) zf; |
---|
1610 | return FALSE; |
---|
1611 | } |
---|
1612 | WerrorS("normalFan: unexpected parameters"); |
---|
1613 | return TRUE; |
---|
1614 | } |
---|
1615 | |
---|
1616 | BOOLEAN PMconeViaRays(leftv res, leftv args) |
---|
1617 | { |
---|
1618 | leftv u = args; |
---|
1619 | if ((u != NULL) && (u->Typ() == INTMAT_CMD)) |
---|
1620 | { |
---|
1621 | polymake::perl::Object pc("Cone<Rational>"); |
---|
1622 | intvec* hlines = (intvec*) u->Data(); // these will are half lines in the cone |
---|
1623 | polymake::Matrix<polymake::Integer> pmhlines = Intvec2PmMatrixInteger(hlines); |
---|
1624 | pc.take("INPUT_RAYS") << pmhlines; |
---|
1625 | |
---|
1626 | leftv v = u->next; |
---|
1627 | if ((v != NULL) && (v->Typ() == INTMAT_CMD)) |
---|
1628 | { |
---|
1629 | intvec* lines = (intvec*) v->Data(); // these will be lines in the cone |
---|
1630 | polymake::Matrix<polymake::Integer> pmlines = Intvec2PmMatrixInteger(lines); |
---|
1631 | pc.take("INPUT_LINEALITY") << pmlines; |
---|
1632 | |
---|
1633 | // leftv w = v->next; |
---|
1634 | // if ((w != NULL) && (w->Typ() == INT_CMD)) |
---|
1635 | // { |
---|
1636 | // int flag = (int) (long) w->Data(); // TODO: this will indicate whether the |
---|
1637 | // // information provided are exact |
---|
1638 | // } |
---|
1639 | } |
---|
1640 | gfan::ZCone* zc = PmCone2ZCone(&pc); |
---|
1641 | res->rtyp = coneID; |
---|
1642 | res->data = (char*) zc; |
---|
1643 | return FALSE; |
---|
1644 | } |
---|
1645 | WerrorS("coneViaRays: unexpected parameters"); |
---|
1646 | return TRUE; |
---|
1647 | } |
---|
1648 | |
---|
1649 | |
---|
1650 | BOOLEAN PMpolytopeViaVertices(leftv res, leftv args) |
---|
1651 | { |
---|
1652 | leftv u = args; |
---|
1653 | if ((u != NULL) && (u->Typ() == INTMAT_CMD)) |
---|
1654 | { |
---|
1655 | polymake::perl::Object pp("Polytope<Rational>"); |
---|
1656 | intvec* points = (intvec*) u->Data(); // these will be vertices of or points in the polytope |
---|
1657 | polymake::Matrix<polymake::Integer> pmpoints = Intvec2PmMatrixInteger(points); |
---|
1658 | |
---|
1659 | leftv v = u->next; |
---|
1660 | if ((v != NULL) && (v->Typ() == INT_CMD)) |
---|
1661 | { |
---|
1662 | int flag = (int) (long) v->Data(); |
---|
1663 | switch(flag) |
---|
1664 | { |
---|
1665 | case 0: pp.take("POINTS") << pmpoints; // case means the matrix may contain points inside the polytope |
---|
1666 | case 1: pp.take("VERTICES") << pmpoints; // case means the matrix only contains vertices of the polytope |
---|
1667 | default: WerrorS("polytopeViaVertices: invalid flag"); |
---|
1668 | } |
---|
1669 | } |
---|
1670 | else |
---|
1671 | pp.take("POINTS") << pmpoints; // by default, we assume that matrix may contain non-vertices |
---|
1672 | |
---|
1673 | gfan::ZCone* zp = PmPolytope2ZPolytope(&pp); |
---|
1674 | res->rtyp = polytopeID; |
---|
1675 | res->data = (char*) zp; |
---|
1676 | return FALSE; |
---|
1677 | } |
---|
1678 | WerrorS("polytopeViaVertices: unexpected parameters"); |
---|
1679 | return TRUE; |
---|
1680 | } |
---|
1681 | |
---|
1682 | extern "C" int mod_init(SModulFunctions* p) |
---|
1683 | { |
---|
1684 | if (init_polymake==NULL) |
---|
1685 | {init_polymake = new polymake::Main();} |
---|
1686 | init_polymake->set_application("fan"); |
---|
1687 | // iiAddCproc("","cube",FALSE,cube); |
---|
1688 | // iiAddCproc("","cross",FALSE,cross); |
---|
1689 | //p->iiAddCproc("polymake.so","coneViaPoints",FALSE,PMconeViaRays); |
---|
1690 | p->iiAddCproc("polymake.so","polytopeViaVertices",FALSE,PMpolytopeViaVertices); |
---|
1691 | p->iiAddCproc("polymake.so","isLatticePolytope",FALSE,PMisLatticePolytope); |
---|
1692 | p->iiAddCproc("polymake.so","isBounded",FALSE,PMisBounded); |
---|
1693 | p->iiAddCproc("polymake.so","isReflexive",FALSE,PMisReflexive); |
---|
1694 | p->iiAddCproc("polymake.so","isGorenstein",FALSE,PMisGorenstein); |
---|
1695 | p->iiAddCproc("polymake.so","gorensteinIndex",FALSE,PMgorensteinIndex); |
---|
1696 | p->iiAddCproc("polymake.so","gorensteinVector",FALSE,PMgorensteinVector); |
---|
1697 | p->iiAddCproc("polymake.so","isCanonical",FALSE,PMisCanonical); |
---|
1698 | p->iiAddCproc("polymake.so","isTerminal",FALSE,PMisTerminal); |
---|
1699 | p->iiAddCproc("polymake.so","isLatticeEmpty",FALSE,PMisLatticeEmpty); |
---|
1700 | p->iiAddCproc("polymake.so","latticeVolume",FALSE,PMlatticeVolume); |
---|
1701 | p->iiAddCproc("polymake.so","latticeDegree",FALSE,PMlatticeDegree); |
---|
1702 | p->iiAddCproc("polymake.so","latticeCodegree",FALSE,PMlatticeCodegree); |
---|
1703 | p->iiAddCproc("polymake.so","ehrhartPolynomialCoeff",FALSE,PMehrhartPolynomialCoeff); |
---|
1704 | //p->iiAddCproc("polymake.so","fVector",FALSE,PMfVector); |
---|
1705 | p->iiAddCproc("polymake.so","hVector",FALSE,PMhVector); |
---|
1706 | p->iiAddCproc("polymake.so","hStarVector",FALSE,PMhStarVector); |
---|
1707 | p->iiAddCproc("polymake.so","isNormal",FALSE,PMisNormal); |
---|
1708 | p->iiAddCproc("polymake.so","facetWidths",FALSE,PMfacetWidths); |
---|
1709 | p->iiAddCproc("polymake.so","facetWidth",FALSE,PMfacetWidth); |
---|
1710 | p->iiAddCproc("polymake.so","facetVertexLatticeDistances",FALSE,PMfacetVertexLatticeDistances); |
---|
1711 | p->iiAddCproc("polymake.so","isCompressed",FALSE,PMisCompressed); |
---|
1712 | p->iiAddCproc("polymake.so","isSmooth",FALSE,PMisSmooth); |
---|
1713 | p->iiAddCproc("polymake.so","isVeryAmple",FALSE,PMisVeryAmple); |
---|
1714 | p->iiAddCproc("polymake.so","latticePoints",FALSE,PMlatticePoints); |
---|
1715 | p->iiAddCproc("polymake.so","nLatticePoints",FALSE,PMnLatticePoints); |
---|
1716 | p->iiAddCproc("polymake.so","interiorLatticePoints",FALSE,PMinteriorLatticePoints); |
---|
1717 | p->iiAddCproc("polymake.so","nInteriorLatticePoints",FALSE,PMnInteriorLatticePoints); |
---|
1718 | p->iiAddCproc("polymake.so","boundaryLatticePoints",FALSE,PMboundaryLatticePoints); |
---|
1719 | p->iiAddCproc("polymake.so","nBoundaryLatticePoints",FALSE,PMnBoundaryLatticePoints); |
---|
1720 | p->iiAddCproc("polymake.so","hilbertBasis",FALSE,PMhilbertBasis); |
---|
1721 | p->iiAddCproc("polymake.so","nHilbertBasis",FALSE,PMnHilbertBasis); |
---|
1722 | p->iiAddCproc("polymake.so","minkowskiSum",FALSE,PMminkowskiSum); |
---|
1723 | p->iiAddCproc("polymake.so","maximalFace",FALSE,PMmaximalFace); |
---|
1724 | p->iiAddCproc("polymake.so","minimalFace",FALSE,PMminimalFace); |
---|
1725 | p->iiAddCproc("polymake.so","maximalValue",FALSE,PMmaximalValue); |
---|
1726 | p->iiAddCproc("polymake.so","minimalValue",FALSE,PMminimalValue); |
---|
1727 | p->iiAddCproc("polymake.so","visual",FALSE,visual); |
---|
1728 | p->iiAddCproc("polymake.so","normalFan",FALSE,normalFan); |
---|
1729 | // iiAddCproc("","testingtypes",FALSE,testingtypes); |
---|
1730 | // iiAddCproc("","testingintvec",FALSE,testingintvec); |
---|
1731 | // iiAddCproc("","testingcones",FALSE,testingcones); |
---|
1732 | // iiAddCproc("","testingpolytopes",FALSE,testingpolytopes); |
---|
1733 | // iiAddCproc("","testingfans",FALSE,testingfans); |
---|
1734 | // iiAddCproc("","testingvisuals",FALSE,testingvisuals); |
---|
1735 | // iiAddCproc("","testingstrings",FALSE,testingstrings); |
---|
1736 | // iiAddCproc("","testingmatrices",FALSE,testingmatrices); |
---|
1737 | // iiAddCproc("","loadPolymakeDocumentation",FALSE,loadPolymakeDocumentation); |
---|
1738 | |
---|
1739 | blackbox* b=getBlackboxStuff(polytopeID); |
---|
1740 | b->blackbox_Op2=bbpolytope_Op2; |
---|
1741 | |
---|
1742 | init_polymake_help(); |
---|
1743 | return 0; |
---|
1744 | } |
---|