passagemath-polyhedra 10.6.31rc3__cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of passagemath-polyhedra might be problematic. Click here for more details.
- passagemath_polyhedra-10.6.31rc3.dist-info/METADATA +367 -0
- passagemath_polyhedra-10.6.31rc3.dist-info/METADATA.bak +369 -0
- passagemath_polyhedra-10.6.31rc3.dist-info/RECORD +206 -0
- passagemath_polyhedra-10.6.31rc3.dist-info/WHEEL +6 -0
- passagemath_polyhedra-10.6.31rc3.dist-info/top_level.txt +2 -0
- passagemath_polyhedra.libs/libgmp-6e109695.so.10.5.0 +0 -0
- passagemath_polyhedra.libs/libgomp-e985bcbb.so.1.0.0 +0 -0
- sage/all__sagemath_polyhedra.py +50 -0
- sage/game_theory/all.py +8 -0
- sage/game_theory/catalog.py +6 -0
- sage/game_theory/catalog_normal_form_games.py +923 -0
- sage/game_theory/cooperative_game.py +844 -0
- sage/game_theory/matching_game.py +1181 -0
- sage/game_theory/normal_form_game.py +2697 -0
- sage/game_theory/parser.py +275 -0
- sage/geometry/all__sagemath_polyhedra.py +22 -0
- sage/geometry/cone.py +6940 -0
- sage/geometry/cone_catalog.py +847 -0
- sage/geometry/cone_critical_angles.py +1027 -0
- sage/geometry/convex_set.py +1119 -0
- sage/geometry/fan.py +3743 -0
- sage/geometry/fan_isomorphism.py +389 -0
- sage/geometry/fan_morphism.py +1884 -0
- sage/geometry/hasse_diagram.py +202 -0
- sage/geometry/hyperplane_arrangement/affine_subspace.py +390 -0
- sage/geometry/hyperplane_arrangement/all.py +1 -0
- sage/geometry/hyperplane_arrangement/arrangement.py +3895 -0
- sage/geometry/hyperplane_arrangement/check_freeness.py +145 -0
- sage/geometry/hyperplane_arrangement/hyperplane.py +773 -0
- sage/geometry/hyperplane_arrangement/library.py +825 -0
- sage/geometry/hyperplane_arrangement/ordered_arrangement.py +642 -0
- sage/geometry/hyperplane_arrangement/plot.py +520 -0
- sage/geometry/integral_points.py +35 -0
- sage/geometry/integral_points_generic_dense.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/geometry/integral_points_generic_dense.pyx +7 -0
- sage/geometry/lattice_polytope.py +5894 -0
- sage/geometry/linear_expression.py +773 -0
- sage/geometry/newton_polygon.py +767 -0
- sage/geometry/point_collection.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/geometry/point_collection.pyx +1008 -0
- sage/geometry/polyhedral_complex.py +2616 -0
- sage/geometry/polyhedron/all.py +8 -0
- sage/geometry/polyhedron/backend_cdd.py +460 -0
- sage/geometry/polyhedron/backend_cdd_rdf.py +231 -0
- sage/geometry/polyhedron/backend_field.py +347 -0
- sage/geometry/polyhedron/backend_normaliz.py +2503 -0
- sage/geometry/polyhedron/backend_number_field.py +168 -0
- sage/geometry/polyhedron/backend_polymake.py +765 -0
- sage/geometry/polyhedron/backend_ppl.py +582 -0
- sage/geometry/polyhedron/base.py +1206 -0
- sage/geometry/polyhedron/base0.py +1444 -0
- sage/geometry/polyhedron/base1.py +886 -0
- sage/geometry/polyhedron/base2.py +812 -0
- sage/geometry/polyhedron/base3.py +1845 -0
- sage/geometry/polyhedron/base4.py +1262 -0
- sage/geometry/polyhedron/base5.py +2700 -0
- sage/geometry/polyhedron/base6.py +1741 -0
- sage/geometry/polyhedron/base7.py +997 -0
- sage/geometry/polyhedron/base_QQ.py +1258 -0
- sage/geometry/polyhedron/base_RDF.py +98 -0
- sage/geometry/polyhedron/base_ZZ.py +934 -0
- sage/geometry/polyhedron/base_mutable.py +215 -0
- sage/geometry/polyhedron/base_number_field.py +122 -0
- sage/geometry/polyhedron/cdd_file_format.py +155 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/all.py +1 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/base.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd +76 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx +3859 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd +39 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx +1038 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/conversions.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pxd +9 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pyx +501 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_data_structure.pxd +207 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd +102 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx +2274 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd +370 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pyx +84 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pxd +31 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx +587 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd +52 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx +560 -0
- sage/geometry/polyhedron/constructor.py +773 -0
- sage/geometry/polyhedron/double_description.py +753 -0
- sage/geometry/polyhedron/double_description_inhomogeneous.py +564 -0
- sage/geometry/polyhedron/face.py +1060 -0
- sage/geometry/polyhedron/generating_function.py +1810 -0
- sage/geometry/polyhedron/lattice_euclidean_group_element.py +178 -0
- sage/geometry/polyhedron/library.py +3502 -0
- sage/geometry/polyhedron/misc.py +121 -0
- sage/geometry/polyhedron/modules/all.py +1 -0
- sage/geometry/polyhedron/modules/formal_polyhedra_module.py +155 -0
- sage/geometry/polyhedron/palp_database.py +447 -0
- sage/geometry/polyhedron/parent.py +1279 -0
- sage/geometry/polyhedron/plot.py +1986 -0
- sage/geometry/polyhedron/ppl_lattice_polygon.py +556 -0
- sage/geometry/polyhedron/ppl_lattice_polytope.py +1257 -0
- sage/geometry/polyhedron/representation.py +1723 -0
- sage/geometry/pseudolines.py +515 -0
- sage/geometry/relative_interior.py +445 -0
- sage/geometry/toric_plotter.py +1103 -0
- sage/geometry/triangulation/all.py +2 -0
- sage/geometry/triangulation/base.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/geometry/triangulation/base.pyx +963 -0
- sage/geometry/triangulation/data.h +147 -0
- sage/geometry/triangulation/data.pxd +4 -0
- sage/geometry/triangulation/element.py +914 -0
- sage/geometry/triangulation/functions.h +10 -0
- sage/geometry/triangulation/functions.pxd +4 -0
- sage/geometry/triangulation/point_configuration.py +2256 -0
- sage/geometry/triangulation/triangulations.h +49 -0
- sage/geometry/triangulation/triangulations.pxd +7 -0
- sage/geometry/voronoi_diagram.py +319 -0
- sage/interfaces/all__sagemath_polyhedra.py +1 -0
- sage/interfaces/polymake.py +2028 -0
- sage/numerical/all.py +13 -0
- sage/numerical/all__sagemath_polyhedra.py +11 -0
- sage/numerical/backends/all.py +1 -0
- sage/numerical/backends/all__sagemath_polyhedra.py +1 -0
- sage/numerical/backends/cvxopt_backend.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/numerical/backends/cvxopt_backend.pyx +1006 -0
- sage/numerical/backends/cvxopt_backend_test.py +19 -0
- sage/numerical/backends/cvxopt_sdp_backend.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/numerical/backends/cvxopt_sdp_backend.pyx +382 -0
- sage/numerical/backends/cvxpy_backend.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/numerical/backends/cvxpy_backend.pxd +41 -0
- sage/numerical/backends/cvxpy_backend.pyx +934 -0
- sage/numerical/backends/cvxpy_backend_test.py +13 -0
- sage/numerical/backends/generic_backend_test.py +24 -0
- sage/numerical/backends/interactivelp_backend.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/numerical/backends/interactivelp_backend.pxd +36 -0
- sage/numerical/backends/interactivelp_backend.pyx +1231 -0
- sage/numerical/backends/interactivelp_backend_test.py +12 -0
- sage/numerical/backends/logging_backend.py +391 -0
- sage/numerical/backends/matrix_sdp_backend.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/numerical/backends/matrix_sdp_backend.pxd +15 -0
- sage/numerical/backends/matrix_sdp_backend.pyx +478 -0
- sage/numerical/backends/ppl_backend.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/numerical/backends/ppl_backend.pyx +1126 -0
- sage/numerical/backends/ppl_backend_test.py +13 -0
- sage/numerical/backends/scip_backend.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/numerical/backends/scip_backend.pxd +22 -0
- sage/numerical/backends/scip_backend.pyx +1289 -0
- sage/numerical/backends/scip_backend_test.py +13 -0
- sage/numerical/interactive_simplex_method.py +5338 -0
- sage/numerical/knapsack.py +665 -0
- sage/numerical/linear_functions.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/numerical/linear_functions.pxd +31 -0
- sage/numerical/linear_functions.pyx +1648 -0
- sage/numerical/linear_tensor.py +470 -0
- sage/numerical/linear_tensor_constraints.py +448 -0
- sage/numerical/linear_tensor_element.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/numerical/linear_tensor_element.pxd +6 -0
- sage/numerical/linear_tensor_element.pyx +459 -0
- sage/numerical/mip.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/numerical/mip.pxd +40 -0
- sage/numerical/mip.pyx +3667 -0
- sage/numerical/sdp.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/numerical/sdp.pxd +39 -0
- sage/numerical/sdp.pyx +1433 -0
- sage/rings/all__sagemath_polyhedra.py +3 -0
- sage/rings/polynomial/all__sagemath_polyhedra.py +10 -0
- sage/rings/polynomial/omega.py +982 -0
- sage/schemes/all__sagemath_polyhedra.py +2 -0
- sage/schemes/toric/all.py +10 -0
- sage/schemes/toric/chow_group.py +1248 -0
- sage/schemes/toric/divisor.py +2082 -0
- sage/schemes/toric/divisor_class.cpython-314-x86_64-linux-gnu.so +0 -0
- sage/schemes/toric/divisor_class.pyx +322 -0
- sage/schemes/toric/fano_variety.py +1606 -0
- sage/schemes/toric/homset.py +650 -0
- sage/schemes/toric/ideal.py +451 -0
- sage/schemes/toric/library.py +1322 -0
- sage/schemes/toric/morphism.py +1958 -0
- sage/schemes/toric/points.py +1032 -0
- sage/schemes/toric/sheaf/all.py +1 -0
- sage/schemes/toric/sheaf/constructor.py +302 -0
- sage/schemes/toric/sheaf/klyachko.py +921 -0
- sage/schemes/toric/toric_subscheme.py +905 -0
- sage/schemes/toric/variety.py +3460 -0
- sage/schemes/toric/weierstrass.py +1078 -0
- sage/schemes/toric/weierstrass_covering.py +457 -0
- sage/schemes/toric/weierstrass_higher.py +288 -0
- sage_wheels/share/reflexive_polytopes/Full2d/zzdb.info +10 -0
- sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v03 +0 -0
- sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v04 +0 -0
- sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v05 +1 -0
- sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v06 +1 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.info +22 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v04 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v05 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v06 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v07 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v08 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v09 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v10 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v11 +1 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v12 +1 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v13 +1 -0
- sage_wheels/share/reflexive_polytopes/reflexive_polytopes_2d +80 -0
- sage_wheels/share/reflexive_polytopes/reflexive_polytopes_3d +37977 -0
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-polyhedra
|
|
2
|
+
# sage.doctest: optional - polytopes_db palp
|
|
3
|
+
"""
|
|
4
|
+
Access the PALP database(s) of reflexive lattice polytopes
|
|
5
|
+
|
|
6
|
+
EXAMPLES::
|
|
7
|
+
|
|
8
|
+
sage: from sage.geometry.polyhedron.palp_database import PALPreader
|
|
9
|
+
sage: for lp in PALPreader(2): # needs fpylll sage.graphs sage.libs.singular
|
|
10
|
+
....: cone = Cone([(1,r[0],r[1]) for r in lp.vertices()])
|
|
11
|
+
....: fan = Fan([cone])
|
|
12
|
+
....: X = ToricVariety(fan)
|
|
13
|
+
....: ideal = X.affine_algebraic_patch(cone).defining_ideal()
|
|
14
|
+
....: print("{} {}".format(lp.n_vertices(), ideal.hilbert_series()))
|
|
15
|
+
3 (t^2 + 7*t + 1)/(-t^3 + 3*t^2 - 3*t + 1)
|
|
16
|
+
3 (t^2 + t + 1)/(-t^3 + 3*t^2 - 3*t + 1)
|
|
17
|
+
3 (t^2 + 6*t + 1)/(-t^3 + 3*t^2 - 3*t + 1)
|
|
18
|
+
3 (t^2 + 2*t + 1)/(-t^3 + 3*t^2 - 3*t + 1)
|
|
19
|
+
3 (t^2 + 4*t + 1)/(-t^3 + 3*t^2 - 3*t + 1)
|
|
20
|
+
4 (t^2 + 5*t + 1)/(-t^3 + 3*t^2 - 3*t + 1)
|
|
21
|
+
4 (t^2 + 3*t + 1)/(-t^3 + 3*t^2 - 3*t + 1)
|
|
22
|
+
4 (t^2 + 2*t + 1)/(-t^3 + 3*t^2 - 3*t + 1)
|
|
23
|
+
4 (t^2 + 6*t + 1)/(-t^3 + 3*t^2 - 3*t + 1)
|
|
24
|
+
4 (t^2 + 6*t + 1)/(-t^3 + 3*t^2 - 3*t + 1)
|
|
25
|
+
4 (t^2 + 2*t + 1)/(-t^3 + 3*t^2 - 3*t + 1)
|
|
26
|
+
4 (t^2 + 4*t + 1)/(-t^3 + 3*t^2 - 3*t + 1)
|
|
27
|
+
5 (t^2 + 3*t + 1)/(-t^3 + 3*t^2 - 3*t + 1)
|
|
28
|
+
5 (t^2 + 5*t + 1)/(-t^3 + 3*t^2 - 3*t + 1)
|
|
29
|
+
5 (t^2 + 4*t + 1)/(-t^3 + 3*t^2 - 3*t + 1)
|
|
30
|
+
6 (t^2 + 4*t + 1)/(-t^3 + 3*t^2 - 3*t + 1)
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
import os
|
|
34
|
+
|
|
35
|
+
from subprocess import Popen, PIPE
|
|
36
|
+
|
|
37
|
+
from sage.structure.sage_object import SageObject
|
|
38
|
+
from sage.rings.integer_ring import ZZ
|
|
39
|
+
from sage.features.palp import PalpExecutable
|
|
40
|
+
from sage.features.databases import DatabaseReflexivePolytopes
|
|
41
|
+
|
|
42
|
+
from sage.interfaces.process import terminate
|
|
43
|
+
|
|
44
|
+
from sage.geometry.polyhedron.ppl_lattice_polytope import LatticePolytope_PPL
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
#########################################################################
|
|
48
|
+
class PALPreader(SageObject):
|
|
49
|
+
"""
|
|
50
|
+
Read PALP database of polytopes.
|
|
51
|
+
|
|
52
|
+
INPUT:
|
|
53
|
+
|
|
54
|
+
- ``dim`` -- integer; the dimension of the polyhedra
|
|
55
|
+
|
|
56
|
+
- ``data_basename`` -- string or ``None`` (default). The directory
|
|
57
|
+
and database base filename (PALP usually uses ``'zzdb'``) name
|
|
58
|
+
containing the PALP database to read. Defaults to the built-in
|
|
59
|
+
database location.
|
|
60
|
+
|
|
61
|
+
- ``output`` -- string. How to return the reflexive polyhedron
|
|
62
|
+
data. Allowed values = ``'list'``, ``'Polyhedron'`` (default),
|
|
63
|
+
``'pointcollection'``, and ``'PPL'``. Case is ignored.
|
|
64
|
+
|
|
65
|
+
EXAMPLES::
|
|
66
|
+
|
|
67
|
+
sage: from sage.geometry.polyhedron.palp_database import PALPreader
|
|
68
|
+
sage: polygons = PALPreader(2)
|
|
69
|
+
sage: [ (p.n_Vrepresentation(), len(p.integral_points())) for p in polygons ]
|
|
70
|
+
[(3, 4), (3, 10), (3, 5), (3, 9), (3, 7), (4, 6), (4, 8), (4, 9),
|
|
71
|
+
(4, 5), (4, 5), (4, 9), (4, 7), (5, 8), (5, 6), (5, 7), (6, 7)]
|
|
72
|
+
|
|
73
|
+
sage: next(iter(PALPreader(2, output='list')))
|
|
74
|
+
[[1, 0], [0, 1], [-1, -1]]
|
|
75
|
+
sage: type(_)
|
|
76
|
+
<... 'list'>
|
|
77
|
+
|
|
78
|
+
sage: next(iter(PALPreader(2, output='Polyhedron')))
|
|
79
|
+
A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices
|
|
80
|
+
sage: type(_)
|
|
81
|
+
<class 'sage.geometry.polyhedron.parent.Polyhedra_ZZ_ppl_with_category.element_class'>
|
|
82
|
+
|
|
83
|
+
sage: next(iter(PALPreader(2, output='PPL')))
|
|
84
|
+
A 2-dimensional lattice polytope in ZZ^2 with 3 vertices
|
|
85
|
+
sage: type(_)
|
|
86
|
+
<class 'sage.geometry.polyhedron.ppl_lattice_polygon.LatticePolygon_PPL_class'>
|
|
87
|
+
|
|
88
|
+
sage: next(iter(PALPreader(2, output='PointCollection')))
|
|
89
|
+
[ 1, 0],
|
|
90
|
+
[ 0, 1],
|
|
91
|
+
[-1, -1]
|
|
92
|
+
in Ambient free module of rank 2 over the principal ideal domain Integer Ring
|
|
93
|
+
sage: type(_)
|
|
94
|
+
<class 'sage.geometry.point_collection.PointCollection'>
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
def __init__(self, dim, data_basename=None, output='Polyhedron'):
|
|
98
|
+
"""
|
|
99
|
+
The Python constructor.
|
|
100
|
+
|
|
101
|
+
See :class:`PALPreader` for documentation.
|
|
102
|
+
|
|
103
|
+
TESTS::
|
|
104
|
+
|
|
105
|
+
sage: from sage.geometry.polyhedron.palp_database import PALPreader
|
|
106
|
+
sage: polygons = PALPreader(2)
|
|
107
|
+
"""
|
|
108
|
+
self._dim = dim
|
|
109
|
+
if data_basename is not None:
|
|
110
|
+
self._data_basename = data_basename
|
|
111
|
+
else:
|
|
112
|
+
db = DatabaseReflexivePolytopes()
|
|
113
|
+
self._data_basename = os.path.join(
|
|
114
|
+
os.path.dirname(db.absolute_filename()),
|
|
115
|
+
f'Full{dim}d', 'zzdb')
|
|
116
|
+
info = self._data_basename + '.info'
|
|
117
|
+
if not os.path.exists(info):
|
|
118
|
+
raise ValueError('Cannot find PALP database: {}'.format(info))
|
|
119
|
+
|
|
120
|
+
from sage.geometry.polyhedron.parent import Polyhedra
|
|
121
|
+
self._polyhedron_parent = Polyhedra(ZZ, dim)
|
|
122
|
+
self._output = output.lower()
|
|
123
|
+
|
|
124
|
+
def _palp_Popen(self):
|
|
125
|
+
"""
|
|
126
|
+
Open PALP.
|
|
127
|
+
|
|
128
|
+
OUTPUT: a PALP subprocess
|
|
129
|
+
|
|
130
|
+
EXAMPLES::
|
|
131
|
+
|
|
132
|
+
sage: from sage.geometry.polyhedron.palp_database import PALPreader
|
|
133
|
+
sage: polygons = PALPreader(2)
|
|
134
|
+
sage: polygons._palp_Popen()
|
|
135
|
+
<...Popen...>
|
|
136
|
+
"""
|
|
137
|
+
|
|
138
|
+
return Popen([PalpExecutable("class").absolute_filename(), "-b2a", "-di", self._data_basename],
|
|
139
|
+
stdout=PIPE, encoding='utf-8', errors='surrogateescape')
|
|
140
|
+
|
|
141
|
+
def _read_vertices(self, stdout, rows, cols):
|
|
142
|
+
r"""
|
|
143
|
+
Read vertex data from the PALP output pipe.
|
|
144
|
+
|
|
145
|
+
OUTPUT: list of lists
|
|
146
|
+
|
|
147
|
+
EXAMPLES::
|
|
148
|
+
|
|
149
|
+
sage: from sage.geometry.polyhedron.palp_database import PALPreader
|
|
150
|
+
sage: polygons = PALPreader(2)
|
|
151
|
+
sage: palp = polygons._palp_Popen()
|
|
152
|
+
sage: palp.stdout.readline()
|
|
153
|
+
'2 3 \n'
|
|
154
|
+
sage: polygons._read_vertices(palp.stdout, 2, 3)
|
|
155
|
+
[[1, 0], [0, 1], [-1, -1]]
|
|
156
|
+
"""
|
|
157
|
+
m = [[] for col in range(cols)]
|
|
158
|
+
for row in range(rows):
|
|
159
|
+
for col, x in enumerate(stdout.readline().split()):
|
|
160
|
+
m[col].append(ZZ(x))
|
|
161
|
+
return m
|
|
162
|
+
|
|
163
|
+
def _read_vertices_transposed(self, stdout, rows, cols):
|
|
164
|
+
r"""
|
|
165
|
+
Read vertex data from the PALP output pipe.
|
|
166
|
+
|
|
167
|
+
OUTPUT: list of lists
|
|
168
|
+
|
|
169
|
+
EXAMPLES::
|
|
170
|
+
|
|
171
|
+
sage: from sage.geometry.polyhedron.palp_database import PALPreader
|
|
172
|
+
sage: polygons = PALPreader(2)
|
|
173
|
+
sage: palp = polygons._palp_Popen()
|
|
174
|
+
sage: palp.stdout.readline()
|
|
175
|
+
'2 3 \n'
|
|
176
|
+
sage: polygons._read_vertices_transposed(palp.stdout, 2, 3)
|
|
177
|
+
[[1, 0, -1], [0, 1, -1]]
|
|
178
|
+
"""
|
|
179
|
+
m = []
|
|
180
|
+
for row in range(rows):
|
|
181
|
+
m.append([ZZ(x) for x in stdout.readline().split()])
|
|
182
|
+
return m
|
|
183
|
+
|
|
184
|
+
def _iterate_list(self, start, stop, step):
|
|
185
|
+
"""
|
|
186
|
+
Iterate over the reflexive polytopes.
|
|
187
|
+
|
|
188
|
+
INPUT:
|
|
189
|
+
|
|
190
|
+
- ``start``, ``stop``, ``step`` -- integers specifying the
|
|
191
|
+
range to iterate over
|
|
192
|
+
|
|
193
|
+
OUTPUT: a generator for vertex data as a list of lists
|
|
194
|
+
|
|
195
|
+
EXAMPLES::
|
|
196
|
+
|
|
197
|
+
sage: from sage.geometry.polyhedron.palp_database import PALPreader
|
|
198
|
+
sage: polygons = PALPreader(2)
|
|
199
|
+
sage: iter = polygons._iterate_list(0,4,2)
|
|
200
|
+
sage: next(iter)
|
|
201
|
+
[[1, 0], [0, 1], [-1, -1]]
|
|
202
|
+
"""
|
|
203
|
+
if start is None:
|
|
204
|
+
start = 0
|
|
205
|
+
if step is None:
|
|
206
|
+
step = 1
|
|
207
|
+
palp = self._palp_Popen()
|
|
208
|
+
with terminate(palp):
|
|
209
|
+
palp_out = palp.stdout
|
|
210
|
+
i = 0
|
|
211
|
+
while True:
|
|
212
|
+
l = palp_out.readline().strip()
|
|
213
|
+
if l == '' or l.startswith('#'):
|
|
214
|
+
return # EOF
|
|
215
|
+
l = l.split()
|
|
216
|
+
dim = ZZ(l[0]) # dimension
|
|
217
|
+
n = ZZ(l[1]) # number of vertices
|
|
218
|
+
if i >= start and (i - start) % step == 0:
|
|
219
|
+
if dim == self._dim:
|
|
220
|
+
vertices = self._read_vertices(palp_out, dim, n)
|
|
221
|
+
elif n == self._dim:
|
|
222
|
+
# PALP sometimes returns transposed data #@!#@
|
|
223
|
+
vertices = self._read_vertices_transposed(palp_out, dim, n)
|
|
224
|
+
else:
|
|
225
|
+
raise ValueError('PALP output dimension mismatch.')
|
|
226
|
+
yield vertices
|
|
227
|
+
else:
|
|
228
|
+
for row in range(dim):
|
|
229
|
+
palp_out.readline()
|
|
230
|
+
i += 1
|
|
231
|
+
if stop is not None and i >= stop:
|
|
232
|
+
return
|
|
233
|
+
|
|
234
|
+
def _iterate_Polyhedron(self, start, stop, step):
|
|
235
|
+
"""
|
|
236
|
+
Iterate over the reflexive polytopes.
|
|
237
|
+
|
|
238
|
+
INPUT:
|
|
239
|
+
|
|
240
|
+
- ``start``, ``stop``, ``step`` -- integers specifying the
|
|
241
|
+
range to iterate over
|
|
242
|
+
|
|
243
|
+
OUTPUT: a generator for lattice polyhedra
|
|
244
|
+
|
|
245
|
+
EXAMPLES::
|
|
246
|
+
|
|
247
|
+
sage: from sage.geometry.polyhedron.palp_database import PALPreader
|
|
248
|
+
sage: polygons = PALPreader(2)
|
|
249
|
+
sage: iter = polygons._iterate_Polyhedron(0,4,2)
|
|
250
|
+
sage: next(iter)
|
|
251
|
+
A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices
|
|
252
|
+
"""
|
|
253
|
+
parent = self._polyhedron_parent
|
|
254
|
+
for vertices in self._iterate_list(start, stop, step):
|
|
255
|
+
p = parent.element_class(parent, [vertices, [], []], None)
|
|
256
|
+
yield p
|
|
257
|
+
|
|
258
|
+
def _iterate_PPL(self, start, stop, step):
|
|
259
|
+
"""
|
|
260
|
+
Iterate over the reflexive polytopes.
|
|
261
|
+
|
|
262
|
+
INPUT:
|
|
263
|
+
|
|
264
|
+
- ``start``, ``stop``, ``step`` -- integers specifying the
|
|
265
|
+
range to iterate over
|
|
266
|
+
|
|
267
|
+
OUTPUT: a generator for PPL-based lattice polyhedra
|
|
268
|
+
|
|
269
|
+
EXAMPLES::
|
|
270
|
+
|
|
271
|
+
sage: from sage.geometry.polyhedron.palp_database import PALPreader
|
|
272
|
+
sage: polygons = PALPreader(2)
|
|
273
|
+
sage: iter = polygons._iterate_PPL(0,4,2)
|
|
274
|
+
sage: next(iter)
|
|
275
|
+
A 2-dimensional lattice polytope in ZZ^2 with 3 vertices
|
|
276
|
+
"""
|
|
277
|
+
for vertices in self._iterate_list(start, stop, step):
|
|
278
|
+
yield LatticePolytope_PPL(*vertices)
|
|
279
|
+
|
|
280
|
+
def _iterate_PointCollection(self, start, stop, step):
|
|
281
|
+
"""
|
|
282
|
+
Iterate over the reflexive polytopes.
|
|
283
|
+
|
|
284
|
+
INPUT:
|
|
285
|
+
|
|
286
|
+
- ``start``, ``stop``, ``step`` -- integers specifying the
|
|
287
|
+
range to iterate over
|
|
288
|
+
|
|
289
|
+
OUTPUT: a generator for PPL-based lattice polyhedra
|
|
290
|
+
|
|
291
|
+
EXAMPLES::
|
|
292
|
+
|
|
293
|
+
sage: from sage.geometry.polyhedron.palp_database import PALPreader
|
|
294
|
+
sage: polygons = PALPreader(2)
|
|
295
|
+
sage: iter = polygons._iterate_PointCollection(0,4,2)
|
|
296
|
+
sage: next(iter)
|
|
297
|
+
[ 1, 0],
|
|
298
|
+
[ 0, 1],
|
|
299
|
+
[-1, -1]
|
|
300
|
+
in Ambient free module of rank 2 over the principal ideal domain Integer Ring
|
|
301
|
+
"""
|
|
302
|
+
from sage.modules.free_module import FreeModule
|
|
303
|
+
from sage.geometry.point_collection import PointCollection
|
|
304
|
+
|
|
305
|
+
N = FreeModule(ZZ, self._dim)
|
|
306
|
+
for vertices in self._iterate_list(start, stop, step):
|
|
307
|
+
yield PointCollection(vertices, module=N)
|
|
308
|
+
|
|
309
|
+
def _iterate(self, output=None):
|
|
310
|
+
"""
|
|
311
|
+
Iterate over the reflexive polytopes.
|
|
312
|
+
|
|
313
|
+
INPUT:
|
|
314
|
+
|
|
315
|
+
- ``output`` -- as in the :class:`PALPreader` constructor
|
|
316
|
+
|
|
317
|
+
OUTPUT: a function generating lattice polytopes in the specified output format
|
|
318
|
+
|
|
319
|
+
EXAMPLES::
|
|
320
|
+
|
|
321
|
+
sage: from sage.geometry.polyhedron.palp_database import PALPreader
|
|
322
|
+
sage: polygons = PALPreader(2)
|
|
323
|
+
sage: func = polygons._iterate(output='list')
|
|
324
|
+
sage: func
|
|
325
|
+
<bound method PALPreader._iterate_list of <sage.geometry.polyhedron.palp_database.PALPreader object at ...>>
|
|
326
|
+
sage: iter = func(0,1,1)
|
|
327
|
+
sage: next(iter)
|
|
328
|
+
[[1, 0], [0, 1], [-1, -1]]
|
|
329
|
+
"""
|
|
330
|
+
if output is None:
|
|
331
|
+
output = self._output
|
|
332
|
+
if output == 'polyhedron':
|
|
333
|
+
return self._iterate_Polyhedron
|
|
334
|
+
elif output == 'ppl':
|
|
335
|
+
return self._iterate_PPL
|
|
336
|
+
elif output == 'pointcollection':
|
|
337
|
+
return self._iterate_PointCollection
|
|
338
|
+
elif output == 'list':
|
|
339
|
+
return self._iterate_list
|
|
340
|
+
else:
|
|
341
|
+
raise TypeError('Unknown output format (={}).'.format(self._output))
|
|
342
|
+
|
|
343
|
+
def __iter__(self):
|
|
344
|
+
"""
|
|
345
|
+
Iterate over all polytopes.
|
|
346
|
+
|
|
347
|
+
OUTPUT: an iterator for all polytopes
|
|
348
|
+
|
|
349
|
+
TESTS::
|
|
350
|
+
|
|
351
|
+
sage: from sage.geometry.polyhedron.palp_database import PALPreader
|
|
352
|
+
sage: polygons = PALPreader(2)
|
|
353
|
+
sage: polygons.__iter__()
|
|
354
|
+
<generator object ..._iterate_Polyhedron at 0x...>
|
|
355
|
+
"""
|
|
356
|
+
iterator = self._iterate()
|
|
357
|
+
return iterator(None, None, None)
|
|
358
|
+
|
|
359
|
+
def __getitem__(self, item):
|
|
360
|
+
"""
|
|
361
|
+
Return the polytopes(s) indexed by ``item``.
|
|
362
|
+
|
|
363
|
+
EXAMPLES::
|
|
364
|
+
|
|
365
|
+
sage: from sage.geometry.polyhedron.palp_database import PALPreader
|
|
366
|
+
sage: palp = PALPreader(3)
|
|
367
|
+
sage: list(palp[10:30:10])
|
|
368
|
+
[A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 4 vertices,
|
|
369
|
+
A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 4 vertices]
|
|
370
|
+
"""
|
|
371
|
+
iterator = self._iterate()
|
|
372
|
+
if isinstance(item, slice):
|
|
373
|
+
return iterator(item.start, item.stop, item.step)
|
|
374
|
+
else:
|
|
375
|
+
try:
|
|
376
|
+
return next(iterator(item, item + 1, 1))
|
|
377
|
+
except StopIteration:
|
|
378
|
+
raise IndexError('Index out of range.')
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
class Reflexive4dHodge(PALPreader):
|
|
382
|
+
"""
|
|
383
|
+
Read the PALP database for Hodge numbers of 4d polytopes.
|
|
384
|
+
|
|
385
|
+
The database is very large and not installed by default. You can
|
|
386
|
+
install it with the shell command ``sage -i polytopes_db_4d``.
|
|
387
|
+
|
|
388
|
+
INPUT:
|
|
389
|
+
|
|
390
|
+
- ``h11``, ``h21`` -- integer; the Hodge numbers of the reflexive
|
|
391
|
+
polytopes to list
|
|
392
|
+
|
|
393
|
+
Any additional keyword arguments are passed to
|
|
394
|
+
:class:`PALPreader`.
|
|
395
|
+
|
|
396
|
+
EXAMPLES::
|
|
397
|
+
|
|
398
|
+
sage: from sage.geometry.polyhedron.palp_database import Reflexive4dHodge
|
|
399
|
+
sage: ref = Reflexive4dHodge(1,101) # optional - polytopes_db_4d
|
|
400
|
+
sage: next(iter(ref)).Vrepresentation() # optional - polytopes_db_4d
|
|
401
|
+
(A vertex at (-1, -1, -1, -1), A vertex at (0, 0, 0, 1),
|
|
402
|
+
A vertex at (0, 0, 1, 0), A vertex at (0, 1, 0, 0), A vertex at (1, 0, 0, 0))
|
|
403
|
+
"""
|
|
404
|
+
def __init__(self, h11, h21, data_basename=None, **kwds):
|
|
405
|
+
"""
|
|
406
|
+
The Python constructor.
|
|
407
|
+
|
|
408
|
+
See :class:`Reflexive4dHodge` for documentation.
|
|
409
|
+
|
|
410
|
+
TESTS::
|
|
411
|
+
|
|
412
|
+
sage: from sage.geometry.polyhedron.palp_database import Reflexive4dHodge
|
|
413
|
+
sage: Reflexive4dHodge(1,101) # optional - polytopes_db_4d
|
|
414
|
+
<sage.geometry.polyhedron.palp_database.Reflexive4dHodge object at ...>
|
|
415
|
+
"""
|
|
416
|
+
dim = 4
|
|
417
|
+
if data_basename is None:
|
|
418
|
+
db = DatabaseReflexivePolytopes('polytopes_db_4d')
|
|
419
|
+
data_basename = os.path.join(db.absolute_filename(), 'all')
|
|
420
|
+
info = data_basename + '.vinfo'
|
|
421
|
+
if not os.path.exists(info):
|
|
422
|
+
raise ValueError(
|
|
423
|
+
'Cannot find PALP database: {}. Did you install the '
|
|
424
|
+
'polytopes_db_4d optional spkg?'.format(info))
|
|
425
|
+
|
|
426
|
+
PALPreader.__init__(self, dim, data_basename=data_basename, **kwds)
|
|
427
|
+
self._h11 = h11
|
|
428
|
+
self._h21 = h21
|
|
429
|
+
|
|
430
|
+
def _palp_Popen(self):
|
|
431
|
+
"""
|
|
432
|
+
Open PALP.
|
|
433
|
+
|
|
434
|
+
OUTPUT: a PALP subprocess
|
|
435
|
+
|
|
436
|
+
EXAMPLES::
|
|
437
|
+
|
|
438
|
+
sage: from sage.geometry.polyhedron.palp_database import Reflexive4dHodge
|
|
439
|
+
sage: polygons = Reflexive4dHodge(1, 101) # optional - polytopes_db_4d
|
|
440
|
+
sage: polygons._palp_Popen() # optional - polytopes_db_4d
|
|
441
|
+
<...Popen...>
|
|
442
|
+
"""
|
|
443
|
+
|
|
444
|
+
return Popen([PalpExecutable('class-4d').absolute_filename(), '-He',
|
|
445
|
+
'H{}:{}L100000000'.format(self._h21, self._h11),
|
|
446
|
+
'-di', self._data_basename], stdout=PIPE,
|
|
447
|
+
encoding='utf-8', errors='surrogateescape')
|