1 | /////////////////////////////////////////////////////////////////////////////// |
---|
2 | version="version polymakeInterface.lib 4.0.3.3 Oct_2016 "; |
---|
3 | category = "Convex Geometry"; |
---|
4 | info=" |
---|
5 | LIBRARY: polymakeInterface.lib low level interface to polymake |
---|
6 | AUTHORS: Yue Ren, email: ren@mathematik.uni-kl.de |
---|
7 | |
---|
8 | PROCEDURES: |
---|
9 | boundaryLatticePoints(); |
---|
10 | ehrhartPolynomialCoeff(); |
---|
11 | fVectorP(); |
---|
12 | facetVertexLatticeDistances(); |
---|
13 | facetWidth(); |
---|
14 | facetWidths(); |
---|
15 | gorensteinIndex(); |
---|
16 | gorensteinVector(); |
---|
17 | hStarVector(); |
---|
18 | hVector(); |
---|
19 | hilbertBasis(); |
---|
20 | interiorLatticePoints(); |
---|
21 | isBounded(); |
---|
22 | isCanonical(); |
---|
23 | isCompressed(); |
---|
24 | isGorenstein(); |
---|
25 | isLatticeEmpty(); |
---|
26 | isNormal(); |
---|
27 | isReflexive(); |
---|
28 | isSmooth(); |
---|
29 | isTerminal(); |
---|
30 | isVeryAmple(); |
---|
31 | latticeCodegree(); |
---|
32 | latticeDegree(); |
---|
33 | latticePoints(); |
---|
34 | latticeVolume(); |
---|
35 | maximalFace(); |
---|
36 | maximalValue(); |
---|
37 | minimalFace(); |
---|
38 | minimalValue(); |
---|
39 | minkowskiSum(); |
---|
40 | nBoundaryLatticePoints(); |
---|
41 | nHilbertBasis(); |
---|
42 | nInteriorLatticePoints(); |
---|
43 | nLatticePoints(); |
---|
44 | normalFan(); |
---|
45 | vertexAdjacencyGraph(); |
---|
46 | vertexEdgeGraph(); |
---|
47 | visual(); |
---|
48 | "; |
---|
49 | |
---|
50 | /////////////////////////////////////////////////////////////////////////////// |
---|
51 | |
---|
52 | proc boundaryLatticePoints() |
---|
53 | "USAGE: boundaryLatticePoints(p); p polytope |
---|
54 | ASSUME: isBounded(p)==1 |
---|
55 | RETURN: intmat, all lattice points on the relative boundary of p |
---|
56 | EXAMPLE: example boundaryLatticePoints; shows an example |
---|
57 | " |
---|
58 | { |
---|
59 | |
---|
60 | } |
---|
61 | example |
---|
62 | { |
---|
63 | "EXAMPLE:"; echo = 2; |
---|
64 | intmat M[3][3]= |
---|
65 | 1,2,-1, |
---|
66 | 1,-1,2, |
---|
67 | 1,-1,-1; |
---|
68 | polytope p = polytopeViaPoints(M); |
---|
69 | boundaryLatticePoints(p); |
---|
70 | intmat N[2][3]= |
---|
71 | 1,2,0, |
---|
72 | 1,0,2; |
---|
73 | polytope q = polytopeViaPoints(N); |
---|
74 | boundaryLatticePoints(q); |
---|
75 | } |
---|
76 | |
---|
77 | proc ehrhartPolynomialCoeff() |
---|
78 | "USAGE: ehrhartPolynomialCoeff(p); p polytope |
---|
79 | ASSUME: isBounded(p)==1 |
---|
80 | RETURN: intvec, all lattice points on the relative boundary of p |
---|
81 | EXAMPLE: example ehrhartPolynomialCoeff; shows an example |
---|
82 | " |
---|
83 | { |
---|
84 | |
---|
85 | } |
---|
86 | example |
---|
87 | { |
---|
88 | "EXAMPLE:"; echo = 2; |
---|
89 | intmat M[6][4]= |
---|
90 | 1,1,1,2, |
---|
91 | 1,-1,-1,-2, |
---|
92 | 1,1,0,0, |
---|
93 | 1,-1,0,0, |
---|
94 | 1,0,1,0, |
---|
95 | 1,0,-1,0; |
---|
96 | polytope p = polytopeViaPoints(M); |
---|
97 | ehrhartPolynomialCoeff(p); |
---|
98 | } |
---|
99 | |
---|
100 | proc fVectorP() |
---|
101 | "USAGE: fVectorP(p); p polytope |
---|
102 | RETURN: intvec, the f-vector or p |
---|
103 | EXAMPLE: example fVectorP; shows an example |
---|
104 | " |
---|
105 | { |
---|
106 | |
---|
107 | } |
---|
108 | example |
---|
109 | { |
---|
110 | "EXAMPLE:"; echo = 2; |
---|
111 | intmat M[6][4]= |
---|
112 | 1,1,1,2, |
---|
113 | 1,-1,-1,-2, |
---|
114 | 1,1,0,0, |
---|
115 | 1,-1,0,0, |
---|
116 | 1,0,1,0, |
---|
117 | 1,0,-1,0; |
---|
118 | polytope p = polytopeViaPoints(M); |
---|
119 | fVectorP(p); |
---|
120 | } |
---|
121 | |
---|
122 | proc facetVertexLatticeDistances() |
---|
123 | "USAGE: facetVertexLatticeDistances(p); p polytope |
---|
124 | RETURN: intmat, encodes the lattice distances between vertices (columns) and facets (rows) of p. |
---|
125 | EXAMPLE: example facetVertexLatticeDistances; shows an example |
---|
126 | " |
---|
127 | { |
---|
128 | |
---|
129 | } |
---|
130 | example |
---|
131 | { |
---|
132 | "EXAMPLE:"; echo = 2; |
---|
133 | intmat M[4][3]= |
---|
134 | 1,2,0, |
---|
135 | 1,0,1, |
---|
136 | 1,2,1, |
---|
137 | 1,0,0; |
---|
138 | polytope p = polytopeViaPoints(M); |
---|
139 | facetVertexLatticeDistances(p); |
---|
140 | } |
---|
141 | |
---|
142 | proc facetWidth() |
---|
143 | "USAGE: facetWidth(p); p polytope |
---|
144 | ASSUME: isBounded(p)==1 |
---|
145 | RETURN: int, maximal integral width going over all facet normals |
---|
146 | EXAMPLE: example facetWidth; shows an example |
---|
147 | " |
---|
148 | { |
---|
149 | |
---|
150 | } |
---|
151 | example |
---|
152 | { |
---|
153 | "EXAMPLE:"; echo = 2; |
---|
154 | intmat M[4][3]= |
---|
155 | 1,2,0, |
---|
156 | 1,0,1, |
---|
157 | 1,2,1, |
---|
158 | 1,0,0; |
---|
159 | polytope p = polytopeViaPoints(M); |
---|
160 | facetWidth(p); |
---|
161 | } |
---|
162 | |
---|
163 | proc facetWidths() |
---|
164 | "USAGE: facetWidths(p); p polytope |
---|
165 | ASSUME: isBounded(p)==1 |
---|
166 | RETURN: intvec, vector with the integral widths of all facet normals |
---|
167 | EXAMPLE: example facetWidths; shows an example |
---|
168 | " |
---|
169 | { |
---|
170 | |
---|
171 | } |
---|
172 | example |
---|
173 | { |
---|
174 | "EXAMPLE:"; echo = 2; |
---|
175 | intmat M[4][3]= |
---|
176 | 1,2,0, |
---|
177 | 1,0,1, |
---|
178 | 1,2,1, |
---|
179 | 1,0,0; |
---|
180 | polytope p = polytopeViaPoints(M); |
---|
181 | facetWidths(p); |
---|
182 | } |
---|
183 | |
---|
184 | proc gorensteinIndex() |
---|
185 | "USAGE: gorensteinIndex(p); p polytope |
---|
186 | ASSUME: isGorenstein(p)==1 |
---|
187 | RETURN: int, a factor n such that n*p+v is reflexive for some translation v |
---|
188 | NOTE: the translation v can be computed via gorensteinVector(p) |
---|
189 | EXAMPLE: example gorensteinIndex; shows an example |
---|
190 | " |
---|
191 | { |
---|
192 | |
---|
193 | } |
---|
194 | example |
---|
195 | { |
---|
196 | "EXAMPLE:"; echo = 2; |
---|
197 | intmat M[4][3]=1,1,0, 1,0,1, 1,0,0, 1,1,1; |
---|
198 | polytope p = polytopeViaPoints(M); |
---|
199 | gorensteinIndex(p); |
---|
200 | } |
---|
201 | |
---|
202 | proc gorensteinVector() |
---|
203 | "USAGE: gorensteinVector(p); p polytope |
---|
204 | ASSUME: isGorenstein(p)==1 |
---|
205 | RETURN: intvec, a vector v such that n*p+v is reflexive for some factor n |
---|
206 | NOTE: the factor n can be computed via gorensteinIndex(p) |
---|
207 | EXAMPLE: example gorensteinVector; shows an example |
---|
208 | " |
---|
209 | { |
---|
210 | |
---|
211 | } |
---|
212 | example |
---|
213 | { |
---|
214 | "EXAMPLE:"; echo = 2; |
---|
215 | intmat M[4][3]=1,1,0, 1,0,1, 1,0,0, 1,1,1; |
---|
216 | polytope p = polytopeViaPoints(M); |
---|
217 | gorensteinVector(p); |
---|
218 | } |
---|
219 | |
---|
220 | proc hStarVector() |
---|
221 | "USAGE: hStarVector(p); p polytope |
---|
222 | RETURN: intvec, the h* vector of p |
---|
223 | EXAMPLE: example hStarVector; shows an example |
---|
224 | " |
---|
225 | { |
---|
226 | |
---|
227 | } |
---|
228 | example |
---|
229 | { |
---|
230 | "EXAMPLE:"; echo = 2; |
---|
231 | intmat |
---|
232 | M[6][4]= |
---|
233 | 1,1,1,2, |
---|
234 | 1,-1,-1,-2, |
---|
235 | 1,1,0,0, |
---|
236 | 1,-1,0,0, |
---|
237 | 1,0,1,0, |
---|
238 | 1,0,-1,0; |
---|
239 | polytope p = polytopeViaPoints(M); |
---|
240 | hStarVector(p); |
---|
241 | } |
---|
242 | |
---|
243 | proc hVector() |
---|
244 | "USAGE: hVector(p); p polytope |
---|
245 | RETURN: intvec, the h vector of p |
---|
246 | EXAMPLE: example hVector; shows an example |
---|
247 | " |
---|
248 | { |
---|
249 | |
---|
250 | } |
---|
251 | example |
---|
252 | { |
---|
253 | "EXAMPLE:"; echo = 2; |
---|
254 | intmat |
---|
255 | M[6][4]= |
---|
256 | 1,1,1,2, |
---|
257 | 1,-1,-1,-2, |
---|
258 | 1,1,0,0, |
---|
259 | 1,-1,0,0, |
---|
260 | 1,0,1,0, |
---|
261 | 1,0,-1,0; |
---|
262 | polytope p = polytopeViaPoints(M); |
---|
263 | hVector(p); |
---|
264 | } |
---|
265 | |
---|
266 | proc hilbertBasis() |
---|
267 | "USAGE: hilbertBasis(c); c cone |
---|
268 | RETURN: intmat, the Hilbert basis of c intersected with Z^n |
---|
269 | EXAMPLE: example hilbertBasis; shows an example |
---|
270 | " |
---|
271 | { |
---|
272 | |
---|
273 | } |
---|
274 | example |
---|
275 | { |
---|
276 | "EXAMPLE:"; echo = 2; |
---|
277 | intmat M[3][3]= |
---|
278 | 1,2,-1, |
---|
279 | 1,-1,2, |
---|
280 | 1,-1,-1; |
---|
281 | cone c = coneViaPoints(M); |
---|
282 | hilbertBasis(c); |
---|
283 | } |
---|
284 | |
---|
285 | proc interiorLatticePoints() |
---|
286 | "USAGE: interiorLatticePoints(p); p polytope |
---|
287 | ASSUME: isBounded(p)==1 |
---|
288 | RETURN: intmat, all lattice points in the relative interior of p |
---|
289 | EXAMPLE: example interiorLatticePoints; shows an example |
---|
290 | " |
---|
291 | { |
---|
292 | |
---|
293 | } |
---|
294 | example |
---|
295 | { |
---|
296 | "EXAMPLE:"; echo = 2; |
---|
297 | intmat M[3][3]= |
---|
298 | 1,2,-1, |
---|
299 | 1,-1,2, |
---|
300 | 1,-1,-1; |
---|
301 | polytope p = polytopeViaPoints(M); |
---|
302 | interiorLatticePoints(p); |
---|
303 | intmat N[2][3]= |
---|
304 | 1,2,0, |
---|
305 | 1,0,2; |
---|
306 | polytope q = polytopeViaPoints(N); |
---|
307 | interiorLatticePoints(q); |
---|
308 | } |
---|
309 | |
---|
310 | proc isBounded() |
---|
311 | "USAGE: isBounded(p); p polytope |
---|
312 | RETURN: 1, if p is bounded; 0 otherwise |
---|
313 | EXAMPLE: example isBounded; shows an example |
---|
314 | " |
---|
315 | { |
---|
316 | |
---|
317 | } |
---|
318 | example |
---|
319 | { |
---|
320 | "EXAMPLE:"; echo = 2; |
---|
321 | intmat M[4][4]= |
---|
322 | 1,1,0,0, |
---|
323 | 1,0,1,0, |
---|
324 | 1,0,0,1, |
---|
325 | 1,-1,-1,-1; |
---|
326 | polytope p = polytopeViaPoints(M); |
---|
327 | isBounded(p); |
---|
328 | M= |
---|
329 | 1,1,0,0, |
---|
330 | 1,0,1,0, |
---|
331 | 0,0,0,1, |
---|
332 | 1,-1,-1,-1; |
---|
333 | p = polytopeViaPoints(M); |
---|
334 | isBounded(p); |
---|
335 | } |
---|
336 | |
---|
337 | proc isCanonical() |
---|
338 | "USAGE: isCanonical(p); p polytope |
---|
339 | RETURN: 1, if p has exactly one interior lattice point; 0 otherwise |
---|
340 | EXAMPLE: example isCanonical; shows an example |
---|
341 | " |
---|
342 | { |
---|
343 | |
---|
344 | } |
---|
345 | example |
---|
346 | { |
---|
347 | "EXAMPLE:"; echo = 2; |
---|
348 | intmat M[6][4]= |
---|
349 | 1,1,1,2, |
---|
350 | 1,-1,-1,-2, |
---|
351 | 1,1,0,0, |
---|
352 | 1,-1,0,0, |
---|
353 | 1,0,1,0, |
---|
354 | 1,0,-1,0; |
---|
355 | polytope p = polytopeViaPoints(M); |
---|
356 | isCanonical(p); |
---|
357 | isReflexive(p); |
---|
358 | intmat N[3][3]= |
---|
359 | 1,2,0, |
---|
360 | 1,0,2, |
---|
361 | 1,-2,-2; |
---|
362 | polytope q = polytopeViaPoints(N); |
---|
363 | isCanonical(q); |
---|
364 | } |
---|
365 | |
---|
366 | proc isCompressed() |
---|
367 | "USAGE: isCompressed(p); p polytope |
---|
368 | RETURN: 1, if p has maximal facet width 1; 0 otherwise |
---|
369 | EXAMPLE: example isCompressed; shows an example |
---|
370 | " |
---|
371 | { |
---|
372 | |
---|
373 | } |
---|
374 | example |
---|
375 | { |
---|
376 | "EXAMPLE:"; echo = 2; |
---|
377 | intmat M[4][3]= |
---|
378 | 1,2,0, |
---|
379 | 1,0,1, |
---|
380 | 1,2,1, |
---|
381 | 1,0,0; |
---|
382 | polytope p = polytopeViaPoints(M); |
---|
383 | isCompressed(p); |
---|
384 | intmat N[4][3]= |
---|
385 | 1,1,0, |
---|
386 | 1,0,1, |
---|
387 | 1,1,1, |
---|
388 | 1,0,0; |
---|
389 | polytope q = polytopeViaPoints(N); |
---|
390 | isCompressed(q); |
---|
391 | } |
---|
392 | |
---|
393 | proc isGorenstein() |
---|
394 | "USAGE: isGorenstein(p); p polytope |
---|
395 | RETURN: 1, if p is Gorenstein, i.e. reflexive modulo dilatation and translation; 0 otherwise |
---|
396 | EXAMPLE: example isGorenstein; shows an example |
---|
397 | " |
---|
398 | { |
---|
399 | |
---|
400 | } |
---|
401 | example |
---|
402 | { |
---|
403 | "EXAMPLE:"; echo = 2; |
---|
404 | intmat M[4][3]= |
---|
405 | 1,1,0, |
---|
406 | 1,0,1, |
---|
407 | 1,0,0, |
---|
408 | 1,1,1; |
---|
409 | polytope p = polytopeViaPoints(M); |
---|
410 | isGorenstein(p); |
---|
411 | intmat N[3][3]= |
---|
412 | 1,2,0, |
---|
413 | 1,0,2, |
---|
414 | 1,-2,-2; |
---|
415 | polytope q = polytopeViaPoints(N); |
---|
416 | isGorenstein(q); |
---|
417 | } |
---|
418 | |
---|
419 | proc isLatticeEmpty() |
---|
420 | "USAGE: isLatticeEmpty(p); p polytope |
---|
421 | RETURN: 1, if p contains no lattice points other than the vertices; 0 otherwise |
---|
422 | EXAMPLE: example isLatticeEmpty; shows an example |
---|
423 | " |
---|
424 | { |
---|
425 | |
---|
426 | } |
---|
427 | example |
---|
428 | { |
---|
429 | "EXAMPLE:"; echo = 2; |
---|
430 | intmat M[4][3]= |
---|
431 | 1,1,0, |
---|
432 | 1,1,1, |
---|
433 | 1,0,1, |
---|
434 | 1,0,0; |
---|
435 | polytope p = polytopeViaPoints(M); |
---|
436 | isLatticeEmpty(p); |
---|
437 | intmat N[4][3]= |
---|
438 | 1,1,0, |
---|
439 | 1,2,1, |
---|
440 | 1,0,1, |
---|
441 | 1,0,0; |
---|
442 | polytope q = polytopeViaPoints(N); |
---|
443 | isLatticeEmpty(q); |
---|
444 | } |
---|
445 | |
---|
446 | proc isNormal() |
---|
447 | "USAGE: isNormal(p); p polytope |
---|
448 | RETURN: 1, if the projective toric variety defined by p is projectively normal; 0 otherwise |
---|
449 | EXAMPLE: example isNormal; shows an example |
---|
450 | " |
---|
451 | { |
---|
452 | |
---|
453 | } |
---|
454 | example |
---|
455 | { |
---|
456 | "EXAMPLE:"; echo = 2; |
---|
457 | intmat M[6][4]= |
---|
458 | 1,1,1,2, |
---|
459 | 1,-1,-1,-2, |
---|
460 | 1,1,0,0, |
---|
461 | 1,-1,0,0, |
---|
462 | 1,0,1,0, |
---|
463 | 1,0,-1,0; |
---|
464 | polytope p = polytopeViaPoints(M); |
---|
465 | isNormal(p); |
---|
466 | } |
---|
467 | |
---|
468 | proc isReflexive() |
---|
469 | "USAGE: isReflexive(p); p polytope |
---|
470 | RETURN: 1, if p is reflexive; 0 otherwise |
---|
471 | EXAMPLE: example isReflexive; shows an example |
---|
472 | " |
---|
473 | { |
---|
474 | |
---|
475 | } |
---|
476 | example |
---|
477 | { |
---|
478 | "EXAMPLE:"; echo = 2; |
---|
479 | intmat M[4][4]= |
---|
480 | 1,1,0,0, |
---|
481 | 1,0,1,0, |
---|
482 | 1,0,0,1, |
---|
483 | 1,-1,-1,-1; |
---|
484 | polytope p = polytopeViaPoints(M); |
---|
485 | isReflexive(p); |
---|
486 | intmat N[4][4]= |
---|
487 | 1,2,0,0, |
---|
488 | 1,0,2,0, |
---|
489 | 1,0,0,2, |
---|
490 | 1,-2,-2,-2; |
---|
491 | polytope q = polytopeViaPoints(M); |
---|
492 | isReflexive(q); |
---|
493 | } |
---|
494 | |
---|
495 | proc isSmooth() |
---|
496 | "USAGE: isSmooth(c); c cone |
---|
497 | isSmooth(f); f fan |
---|
498 | isSmooth(p); p polytope |
---|
499 | RETURN: 1, if the input is smooth; 0 otherwise |
---|
500 | EXAMPLE: example isSmooth; shows an example |
---|
501 | " |
---|
502 | { |
---|
503 | |
---|
504 | } |
---|
505 | example |
---|
506 | { |
---|
507 | "EXAMPLE:"; echo = 2; |
---|
508 | intmat M1[2][2]= |
---|
509 | 1,0, |
---|
510 | 0,1; |
---|
511 | cone c1 = coneViaPoints(M1); |
---|
512 | isSmooth(c1); |
---|
513 | intmat M2[3][3]= |
---|
514 | 1,0, |
---|
515 | 1,2; |
---|
516 | cone c2 = coneViaPoints(M2); |
---|
517 | fan F1 = emptyFan(2); |
---|
518 | insertCone(F1,c1); |
---|
519 | isSmooth(F1); |
---|
520 | fan F2 = emptyFan(3); |
---|
521 | insertCone(F2,c2); |
---|
522 | isSmooth(F2); |
---|
523 | intmat Mp[3][3]= |
---|
524 | 1,-2,-3, |
---|
525 | 1,1,0, |
---|
526 | 1,0,1; |
---|
527 | polytope p = polytopeViaPoints(Mp); |
---|
528 | isSmooth(p); |
---|
529 | fan F = normalFan(p); |
---|
530 | isSmooth(F); |
---|
531 | intmat Mq[4][3]= |
---|
532 | 1,2,0, |
---|
533 | 1,0,1, |
---|
534 | 1,2,1, |
---|
535 | 1,0,0; |
---|
536 | polytope q = polytopeViaPoints(Mq); |
---|
537 | isSmooth(q); |
---|
538 | } |
---|
539 | |
---|
540 | proc isTerminal() |
---|
541 | "USAGE: isTerminal(p); p polytope |
---|
542 | RETURN: 1, if p has exactly one interior lattice point and all other lattice points are vertices; 0 otherwise |
---|
543 | EXAMPLE: example isTerminal; shows an example |
---|
544 | " |
---|
545 | { |
---|
546 | |
---|
547 | } |
---|
548 | example |
---|
549 | { |
---|
550 | "EXAMPLE:"; echo = 2; |
---|
551 | intmat M[6][4]= |
---|
552 | 1,1,1,2, |
---|
553 | 1,-1,-1,-2, |
---|
554 | 1,1,0,0, |
---|
555 | 1,-1,0,0, |
---|
556 | 1,0,1,0, |
---|
557 | 1,0,-1,0; |
---|
558 | polytope p = polytopeViaPoints(M); |
---|
559 | isTerminal(p); |
---|
560 | isReflexive(p); |
---|
561 | intmat N[6][4]= |
---|
562 | 1,1,1,2, |
---|
563 | 1,-1,-1,-2, |
---|
564 | 1,1,1,0, |
---|
565 | 1,-1,-1,0, |
---|
566 | 1,-1,1,0, |
---|
567 | 1,1,-1,0; |
---|
568 | polytope q = polytopeViaPoints(N); |
---|
569 | isTerminal(q); |
---|
570 | isCanonical(q); |
---|
571 | } |
---|
572 | |
---|
573 | proc isVeryAmple() |
---|
574 | "USAGE: isVeryAmple(p); p polytope |
---|
575 | RETURN: 1, if p is very ample; 0 otherwise |
---|
576 | EXAMPLE: example isVeryAmple; shows an example |
---|
577 | " |
---|
578 | { |
---|
579 | |
---|
580 | } |
---|
581 | example |
---|
582 | { |
---|
583 | "EXAMPLE:"; echo = 2; |
---|
584 | intmat M[3][3]= |
---|
585 | 1,1,0, |
---|
586 | 1,0,1, |
---|
587 | 1,-1,-1; |
---|
588 | polytope p = polytopeViaPoints(M); |
---|
589 | isVeryAmple(p); |
---|
590 | intmat N[3][4]= |
---|
591 | 1,1,0,0, |
---|
592 | 1,0,1,0, |
---|
593 | 1,1,1,2; |
---|
594 | polytope q = polytopeViaPoints(N); |
---|
595 | isVeryAmple(q); |
---|
596 | } |
---|
597 | |
---|
598 | proc latticeCodegree() |
---|
599 | "USAGE: latticeCodegree(p); p polytope |
---|
600 | RETURN: int, the smalles number n such that n*p has a relative interior lattice point |
---|
601 | NOTE: dimension(p)+1==latticeDegree(p)+latticeCodegree(p) |
---|
602 | EXAMPLE: example latticeCodegree; shows an example |
---|
603 | " |
---|
604 | { |
---|
605 | |
---|
606 | } |
---|
607 | example |
---|
608 | { |
---|
609 | "EXAMPLE:"; echo = 2; |
---|
610 | intmat M[4][3]= |
---|
611 | 1,1,0, |
---|
612 | 1,1,1, |
---|
613 | 1,0,1, |
---|
614 | 1,0,0; |
---|
615 | polytope p = polytopeViaPoints(M); |
---|
616 | latticeCodegree(p); |
---|
617 | intmat N[4][4]= |
---|
618 | 1,1,0,0, |
---|
619 | 1,0,1,0, |
---|
620 | 1,0,0,1, |
---|
621 | 1,0,0,0; |
---|
622 | polytope q = polytopeViaPoints(N); |
---|
623 | latticeCodegree(q); |
---|
624 | } |
---|
625 | |
---|
626 | proc latticeDegree() |
---|
627 | "USAGE: latticeDegree(p); p polytope |
---|
628 | RETURN: int, the degree of the Ehrhart polynomial of p |
---|
629 | NOTE: dimension(p)+1==latticeDegree(p)+latticeCodegree(p) |
---|
630 | EXAMPLE: example latticeDegree; shows an example |
---|
631 | " |
---|
632 | { |
---|
633 | |
---|
634 | } |
---|
635 | example |
---|
636 | { |
---|
637 | "EXAMPLE:"; echo = 2; |
---|
638 | intmat M[4][3]= |
---|
639 | 1,1,0, |
---|
640 | 1,1,1, |
---|
641 | 1,0,1, |
---|
642 | 1,0,0; |
---|
643 | polytope p = polytopeViaPoints(M); |
---|
644 | latticeDegree(p); |
---|
645 | intmat N[4][4]= |
---|
646 | 1,1,0,0, |
---|
647 | 1,0,1,0, |
---|
648 | 1,0,0,1, |
---|
649 | 1,0,0,0; |
---|
650 | polytope q = polytopeViaPoints(N); |
---|
651 | latticeDegree(q); |
---|
652 | } |
---|
653 | |
---|
654 | proc latticePoints() |
---|
655 | "USAGE: latticePoints(p); p polytope |
---|
656 | ASSUME: isBounded(p)==1 |
---|
657 | RETURN: intmat, all lattice points in p |
---|
658 | EXAMPLE: example latticePoints; shows an example |
---|
659 | " |
---|
660 | { |
---|
661 | |
---|
662 | } |
---|
663 | example |
---|
664 | { |
---|
665 | "EXAMPLE:"; echo = 2; |
---|
666 | intmat M[3][3]= |
---|
667 | 1,2,-1, |
---|
668 | 1,-1,2, |
---|
669 | 1,-1,-1; |
---|
670 | polytope p = polytopeViaPoints(M); |
---|
671 | latticePoints(p); |
---|
672 | intmat N[2][3]= |
---|
673 | 1,2,0, |
---|
674 | 1,0,2; |
---|
675 | polytope q = polytopeViaPoints(N); |
---|
676 | latticePoints(q); |
---|
677 | } |
---|
678 | |
---|
679 | proc latticeVolume() |
---|
680 | "USAGE: latticeVolume(p); p polytope |
---|
681 | ASSUME: isBounded(p)==1 |
---|
682 | RETURN: int, the lattice volume of p |
---|
683 | EXAMPLE: example latticeVolume; shows an example |
---|
684 | " |
---|
685 | { |
---|
686 | |
---|
687 | } |
---|
688 | example |
---|
689 | { |
---|
690 | "EXAMPLE:"; echo = 2; |
---|
691 | intmat M[4][3]= |
---|
692 | 1,1,0, |
---|
693 | 1,1,1, |
---|
694 | 1,0,1, |
---|
695 | 1,0,0; |
---|
696 | polytope p = polytopeViaPoints(M); |
---|
697 | latticeVolume(p); |
---|
698 | intmat N[4][3]= |
---|
699 | 1,1,0, |
---|
700 | 1,2,1, |
---|
701 | 1,0,1, |
---|
702 | 1,0,0; |
---|
703 | polytope q = polytopeViaPoints(N); |
---|
704 | latticeVolume(q); |
---|
705 | intmat W[4][4]= |
---|
706 | 1,1,0,0, |
---|
707 | 1,0,1,0, |
---|
708 | 1,0,0,1, |
---|
709 | 1,0,0,0; |
---|
710 | polytope r = polytopeViaPoints(W); |
---|
711 | latticeVolume(r); |
---|
712 | } |
---|
713 | |
---|
714 | proc maximalFace() |
---|
715 | "USAGE: maximalFace(p,v); p polytope, v intvec |
---|
716 | ASSUME: v lies in the negative dual tail cone of p |
---|
717 | RETURN: intmat, vertices of the face of p on which the linear form v is maximal |
---|
718 | NOTE: the maximal face is independent of the first coordinate of v |
---|
719 | since p is considered as a polytope in the plane (first coordinate) = 1. |
---|
720 | EXAMPLE: example maximalFace; shows an example |
---|
721 | " |
---|
722 | { |
---|
723 | |
---|
724 | } |
---|
725 | example |
---|
726 | { |
---|
727 | "EXAMPLE:"; echo = 2; |
---|
728 | intmat M[3][3]= |
---|
729 | 1,1,0, |
---|
730 | 1,0,1, |
---|
731 | 1,-1,-1; |
---|
732 | intvec v = 0,1,1; |
---|
733 | polytope p = polytopeViaPoints(M); |
---|
734 | maximalFace(p,v); |
---|
735 | intvec w = -5,1,1; |
---|
736 | maximalFace(p,w); |
---|
737 | } |
---|
738 | |
---|
739 | proc maximalValue() |
---|
740 | "USAGE: maximalValue(p,v); p polytope, v intvec |
---|
741 | ASSUME: v lies in the negative dual tail cone of p |
---|
742 | RETURN: intmat, vertices of the face of p on which the linear form v is maximal |
---|
743 | NOTE: first coordinate of v corresponds to a shift of the maximal value |
---|
744 | since p is considered as a polytope in the plane (first coordinate) = 1. |
---|
745 | EXAMPLE: example maximalValue; shows an example |
---|
746 | " |
---|
747 | { |
---|
748 | |
---|
749 | } |
---|
750 | example |
---|
751 | { |
---|
752 | "EXAMPLE:"; echo = 2; |
---|
753 | intmat M[3][3]= |
---|
754 | 1,1,0, |
---|
755 | 1,0,1, |
---|
756 | 1,-1,-1; |
---|
757 | intvec v = 0,1,1; |
---|
758 | polytope p = polytopeViaPoints(M); |
---|
759 | maximalValue(p,v); |
---|
760 | intvec w = -5,1,1; |
---|
761 | maximalValue(p,w); |
---|
762 | } |
---|
763 | |
---|
764 | proc minimalFace() |
---|
765 | "USAGE: minimalFace(p,v); p polytope, v intvec |
---|
766 | ASSUME: v lies in the dual tail cone of p |
---|
767 | RETURN: intmat, vertices of the face of p on which the linear form v is minimal |
---|
768 | NOTE: the minimal face is independent of the first coordinate of v |
---|
769 | since p is considered as a polytope in the plane (first coordinate) = 1. |
---|
770 | EXAMPLE: example minimalFace; shows an example |
---|
771 | " |
---|
772 | { |
---|
773 | |
---|
774 | } |
---|
775 | example |
---|
776 | { |
---|
777 | "EXAMPLE:"; echo = 2; |
---|
778 | intmat M[3][3]= |
---|
779 | 1,1,0, |
---|
780 | 1,0,1, |
---|
781 | 1,-1,-1; |
---|
782 | intvec v = 0,-1,-1; |
---|
783 | polytope p = polytopeViaPoints(M); |
---|
784 | minimalFace(p,v); |
---|
785 | intvec w = 5,-1,-1; |
---|
786 | minimalFace(p,w); |
---|
787 | } |
---|
788 | |
---|
789 | proc minimalValue() |
---|
790 | "USAGE: minimalValue(p,v); p polytope, v intvec |
---|
791 | ASSUME: v lies in the negative dual tail cone of p |
---|
792 | RETURN: intmat, vertices of the face of p on which the linear form v is minimal |
---|
793 | NOTE: first coordinate of v corresponds to a shift of the minimal value |
---|
794 | since p is considered as a polytope in the plane (first coordinate) = 1. |
---|
795 | EXAMPLE: example minimalValue; shows an example |
---|
796 | " |
---|
797 | { |
---|
798 | |
---|
799 | } |
---|
800 | example |
---|
801 | { |
---|
802 | "EXAMPLE:"; echo = 2; |
---|
803 | intmat M[3][3]= |
---|
804 | 1,1,0, |
---|
805 | 1,0,1, |
---|
806 | 1,-1,-1; |
---|
807 | intvec v = 0,-1,-1; |
---|
808 | polytope p = polytopeViaPoints(M); |
---|
809 | minimalValue(p,v); |
---|
810 | intvec w = 5,-1,-1; |
---|
811 | minimalValue(p,w); |
---|
812 | } |
---|
813 | |
---|
814 | proc minkowskiSum() |
---|
815 | "USAGE: minkowskiSum(c,d); c cone, d cone |
---|
816 | minkowskiSum(c,q); c cone, q polytope |
---|
817 | minkowskiSum(p,d); p polytope, d cone |
---|
818 | minkowskiSum(p,q); p polytope, q polytope |
---|
819 | ASSUME: input arguments have the same ambient dimension |
---|
820 | RETURN: cone, if both inputs are cones; polytope, otherwise |
---|
821 | the minkowski sum of the two input arguments |
---|
822 | EXAMPLE: example minkowskiSum; shows an example |
---|
823 | " |
---|
824 | { |
---|
825 | |
---|
826 | } |
---|
827 | example |
---|
828 | { |
---|
829 | "EXAMPLE:"; echo = 2; |
---|
830 | intmat M[3][4]= |
---|
831 | 1,1,0,0, |
---|
832 | 1,0,1,0, |
---|
833 | 1,0,0,0; |
---|
834 | intmat N[3][4]= |
---|
835 | 1,0,0,1, |
---|
836 | 1,-1,-1,-1, |
---|
837 | 1,0,0,0; |
---|
838 | polytope p = polytopeViaPoints(M); |
---|
839 | polytope q = polytopeViaPoints(N); |
---|
840 | vertices(minkowskiSum(p,q)); |
---|
841 | } |
---|
842 | |
---|
843 | proc nBoundaryLatticePoints() |
---|
844 | "USAGE: nBoundaryLatticePoints(p); p polytope |
---|
845 | ASSUME: isBounded(p)==1 |
---|
846 | RETURN: int, the number of lattice points in the relative boundary of p |
---|
847 | EXAMPLE: example nBoundaryLatticePoints; shows an example |
---|
848 | " |
---|
849 | { |
---|
850 | |
---|
851 | } |
---|
852 | example |
---|
853 | { |
---|
854 | "EXAMPLE:"; echo = 2; |
---|
855 | intmat M[3][3]= |
---|
856 | 1,2,-1, |
---|
857 | 1,-1,2, |
---|
858 | 1,-1,-1; |
---|
859 | polytope p = polytopeViaPoints(M); |
---|
860 | nBoundaryLatticePoints(p); |
---|
861 | intmat N[2][3]= |
---|
862 | 1,2,0, |
---|
863 | 1,0,2; |
---|
864 | polytope q = polytopeViaPoints(N); |
---|
865 | nBoundaryLatticePoints(q); |
---|
866 | } |
---|
867 | |
---|
868 | proc nHilbertBasis() |
---|
869 | "USAGE: nHilbertBasis(c); c cone |
---|
870 | RETURN: int, the number of elements in the Hilbert basis of c intersected with Z^n |
---|
871 | EXAMPLE: example nHilbertBasis; shows an example |
---|
872 | " |
---|
873 | { |
---|
874 | |
---|
875 | } |
---|
876 | example |
---|
877 | { |
---|
878 | "EXAMPLE:"; echo = 2; |
---|
879 | intmat M[3][3]= |
---|
880 | 1,2,-1, |
---|
881 | 1,-1,2, |
---|
882 | 1,-1,-1; |
---|
883 | cone c = coneViaPoints(M); |
---|
884 | nHilbertBasis(c); |
---|
885 | } |
---|
886 | |
---|
887 | proc nInteriorLatticePoints() |
---|
888 | "USAGE: nInteriorLatticePoints(p); p polytope |
---|
889 | ASSUME: isBounded(p)==1 |
---|
890 | RETURN: int, the number of lattice points in the relative interior of p |
---|
891 | EXAMPLE: example nInteriorLatticePoints; shows an example |
---|
892 | " |
---|
893 | { |
---|
894 | |
---|
895 | } |
---|
896 | example |
---|
897 | { |
---|
898 | "EXAMPLE:"; echo = 2; |
---|
899 | intmat M[3][3]= |
---|
900 | 1,2,-1, |
---|
901 | 1,-1,2, |
---|
902 | 1,-1,-1; |
---|
903 | polytope p = polytopeViaPoints(M); |
---|
904 | nInteriorLatticePoints(p); |
---|
905 | intmat N[2][3]= |
---|
906 | 1,2,0, |
---|
907 | 1,0,2; |
---|
908 | polytope q = polytopeViaPoints(N); |
---|
909 | nInteriorLatticePoints(q); |
---|
910 | } |
---|
911 | |
---|
912 | proc nLatticePoints() |
---|
913 | "USAGE: nLatticePoints(p); p polytope |
---|
914 | ASSUME: isBounded(p)==1 |
---|
915 | RETURN: intmat, the number of lattice points in p |
---|
916 | EXAMPLE: example nLatticePoints; shows an example |
---|
917 | " |
---|
918 | { |
---|
919 | |
---|
920 | } |
---|
921 | example |
---|
922 | { |
---|
923 | "EXAMPLE:"; echo = 2; |
---|
924 | intmat M[3][3]= |
---|
925 | 1,2,-1, |
---|
926 | 1,-1,2, |
---|
927 | 1,-1,-1; |
---|
928 | polytope p = polytopeViaPoints(M); |
---|
929 | nLatticePoints(p); |
---|
930 | intmat N[2][3]= |
---|
931 | 1,2,0, |
---|
932 | 1,0,2; |
---|
933 | polytope q = polytopeViaPoints(N); |
---|
934 | nLatticePoints(q); |
---|
935 | } |
---|
936 | |
---|
937 | proc normalFan() |
---|
938 | "USAGE: normalFan(p); p polytope |
---|
939 | RETURN: fan, the normal fan of p |
---|
940 | EXAMPLE: example normalFan; shows an example |
---|
941 | " |
---|
942 | { |
---|
943 | |
---|
944 | } |
---|
945 | example |
---|
946 | { |
---|
947 | "EXAMPLE:"; echo = 2; |
---|
948 | intmat M[6][4] = |
---|
949 | 1,1,0,0, |
---|
950 | 1,0,1,0, |
---|
951 | 1,0,-1,0, |
---|
952 | 1,0,0,1, |
---|
953 | 1,0,0,-1, |
---|
954 | 1,-1,0,0; |
---|
955 | polytope p = polytopeViaPoints(M); |
---|
956 | normalFan(p); |
---|
957 | } |
---|
958 | |
---|
959 | proc vertexAdjacencyGraph() |
---|
960 | "USAGE: vertexAdjacencyGraph(p); p polytope |
---|
961 | RETURN: list, the first entry is a bigintmat containing all vertices as row vectors, and therefore assigning all vertices an integer. |
---|
962 | the second entry is a list of intvecs representing the adjacency graph of the vertices of p, |
---|
963 | the intvec in position i contains all vertices j which are connected to vertex i via an edge of p. |
---|
964 | EXAMPLE: example vertexAdjacencyGraph; shows an example |
---|
965 | " |
---|
966 | { |
---|
967 | |
---|
968 | } |
---|
969 | example |
---|
970 | { |
---|
971 | "EXAMPLE:"; echo = 2; |
---|
972 | intmat M[6][4] = |
---|
973 | 1,1,0,0, |
---|
974 | 1,0,1,0, |
---|
975 | 1,0,-1,0, |
---|
976 | 1,0,0,1, |
---|
977 | 1,0,0,-1, |
---|
978 | 1,-1,0,0; |
---|
979 | polytope p = polytopeViaPoints(M); |
---|
980 | vertexAdjacencyGraph(p); |
---|
981 | } |
---|
982 | |
---|
983 | proc vertexEdgeGraph() |
---|
984 | "USAGE: vertexEdgeGraph(p); p polytope |
---|
985 | RETURN: list, the first entry is a bigintmat containing all vertices as row vectors, and therefore assigning all vertices an integer. |
---|
986 | the second entry is a list of intvecs representing the edge graph of the vertices of p, |
---|
987 | each intvec represents an edge of p connecting vertex i with vertex j. |
---|
988 | EXAMPLE: example vertexEdgeGraph; shows an example |
---|
989 | " |
---|
990 | { |
---|
991 | |
---|
992 | } |
---|
993 | example |
---|
994 | { |
---|
995 | "EXAMPLE:"; echo = 2; |
---|
996 | intmat M[6][4] = |
---|
997 | 1,1,0,0, |
---|
998 | 1,0,1,0, |
---|
999 | 1,0,-1,0, |
---|
1000 | 1,0,0,1, |
---|
1001 | 1,0,0,-1, |
---|
1002 | 1,-1,0,0; |
---|
1003 | polytope p = polytopeViaPoints(M); |
---|
1004 | vertexEdgeGraph(p); |
---|
1005 | } |
---|
1006 | |
---|
1007 | |
---|
1008 | proc visual() |
---|
1009 | "USAGE: visual(f); f fan |
---|
1010 | visual(p); p polytope |
---|
1011 | ASSUME: ambientDimension(f) resp ambientDimension(p) less or equal 3 |
---|
1012 | RETURN: none |
---|
1013 | EXAMPLE: example visual; shows an example |
---|
1014 | " |
---|
1015 | { |
---|
1016 | |
---|
1017 | } |
---|
1018 | example |
---|
1019 | { |
---|
1020 | "EXAMPLE:"; echo = 2; |
---|
1021 | intmat M[6][4] = |
---|
1022 | 1,1,0,0, |
---|
1023 | 1,0,1,0, |
---|
1024 | 1,0,-1,0, |
---|
1025 | 1,0,0,1, |
---|
1026 | 1,0,0,-1, |
---|
1027 | 1,-1,0,0; |
---|
1028 | polytope p = polytopeViaPoints(M); |
---|
1029 | // visual(p); |
---|
1030 | fan f = normalFan(p); |
---|
1031 | // visual(f); |
---|
1032 | } |
---|
1033 | |
---|
1034 | |
---|
1035 | static proc mod_init() |
---|
1036 | { |
---|
1037 | intvec save=option(get); |
---|
1038 | option(noredefine); |
---|
1039 | LIB "customstd.so"; |
---|
1040 | LIB "gfanlib.so"; |
---|
1041 | LIB "polymake.so"; |
---|
1042 | option(set,save); |
---|
1043 | } |
---|