Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Access the PALP database(s) of reflexive lattice polytopes
EXAMPLES::
sage: from sage.geometry.polyhedron.palp_database import PALPreader sage: for lp in PALPreader(2): ....: cone = Cone([(1,r[0],r[1]) for r in lp.vertices()]) ....: fan = Fan([cone]) ....: X = ToricVariety(fan) ....: ideal = X.affine_algebraic_patch(cone).defining_ideal() ....: print("{} {}".format(lp.n_vertices(), ideal.hilbert_series())) 3 (-t^2 - 7*t - 1)/(t^3 - 3*t^2 + 3*t - 1) 3 (-t^2 - t - 1)/(t^3 - 3*t^2 + 3*t - 1) 3 (t^2 + 6*t + 1)/(-t^3 + 3*t^2 - 3*t + 1) 3 (t^2 + 2*t + 1)/(-t^3 + 3*t^2 - 3*t + 1) 3 (t^2 + 4*t + 1)/(-t^3 + 3*t^2 - 3*t + 1) 4 (-t^2 - 5*t - 1)/(t^3 - 3*t^2 + 3*t - 1) 4 (-t^2 - 3*t - 1)/(t^3 - 3*t^2 + 3*t - 1) 4 (t^2 + 2*t + 1)/(-t^3 + 3*t^2 - 3*t + 1) 4 (t^2 + 6*t + 1)/(-t^3 + 3*t^2 - 3*t + 1) 4 (t^2 + 6*t + 1)/(-t^3 + 3*t^2 - 3*t + 1) 4 (t^2 + 2*t + 1)/(-t^3 + 3*t^2 - 3*t + 1) 4 (t^2 + 4*t + 1)/(-t^3 + 3*t^2 - 3*t + 1) 5 (-t^2 - 3*t - 1)/(t^3 - 3*t^2 + 3*t - 1) 5 (-t^2 - 5*t - 1)/(t^3 - 3*t^2 + 3*t - 1) 5 (t^2 + 4*t + 1)/(-t^3 + 3*t^2 - 3*t + 1) 6 (t^2 + 4*t + 1)/(-t^3 + 3*t^2 - 3*t + 1) """
######################################################################### """ Read PALP database of polytopes.
INPUT:
- ``dim`` -- integer. The dimension of the poylhedra
- ``data_basename`` -- string or ``None`` (default). The directory and database base filename (PALP usually uses ``'zzdb'``) name containing the PALP database to read. Defaults to the built-in database location.
- ``output`` -- string. How to return the reflexive polyhedron data. Allowed values = ``'list'``, ``'Polyhedron'`` (default), ``'pointcollection'``, and ``'PPL'``. Case is ignored.
EXAMPLES::
sage: from sage.geometry.polyhedron.palp_database import PALPreader sage: polygons = PALPreader(2) sage: [ (p.n_Vrepresentation(), len(p.integral_points())) for p in polygons ] [(3, 4), (3, 10), (3, 5), (3, 9), (3, 7), (4, 6), (4, 8), (4, 9), (4, 5), (4, 5), (4, 9), (4, 7), (5, 8), (5, 6), (5, 7), (6, 7)]
sage: next(iter(PALPreader(2, output='list'))) [[1, 0], [0, 1], [-1, -1]] sage: type(_) <... 'list'>
sage: next(iter(PALPreader(2, output='Polyhedron'))) A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices sage: type(_) <class 'sage.geometry.polyhedron.parent.Polyhedra_ZZ_ppl_with_category.element_class'>
sage: next(iter(PALPreader(2, output='PPL'))) A 2-dimensional lattice polytope in ZZ^2 with 3 vertices sage: type(_) <class 'sage.geometry.polyhedron.ppl_lattice_polygon.LatticePolygon_PPL_class'>
sage: next(iter(PALPreader(2, output='PointCollection'))) [ 1, 0], [ 0, 1], [-1, -1] in Ambient free module of rank 2 over the principal ideal domain Integer Ring sage: type(_) <type 'sage.geometry.point_collection.PointCollection'> """
""" The Python constructor
See :class:`PALPreader` for documentation.
TESTS::
sage: from sage.geometry.polyhedron.palp_database import PALPreader sage: polygons = PALPreader(2) """ self._data_basename = data_basename else: 'Full'+str(dim)+'d', 'zzdb') raise ValueError('Cannot find PALP database: '+info)
""" Open PALP.
OUTPUT:
A PALP subprocess.
EXAMPLES::
sage: from sage.geometry.polyhedron.palp_database import PALPreader sage: polygons = PALPreader(2) sage: polygons._palp_Popen() <subprocess.Popen object at 0x...> """
r""" Read vertex data from the PALP output pipe.
OUTPUT:
A list of lists.
EXAMPLES::
sage: from sage.geometry.polyhedron.palp_database import PALPreader sage: polygons = PALPreader(2) sage: palp = polygons._palp_Popen() sage: palp.stdout.readline() '2 3 \n' sage: polygons._read_vertices(palp.stdout, 2, 3) [[1, 0], [0, 1], [-1, -1]] """
r""" Read vertex data from the PALP output pipe.
OUTPUT:
A list of lists.
EXAMPLES::
sage: from sage.geometry.polyhedron.palp_database import PALPreader sage: polygons = PALPreader(2) sage: palp = polygons._palp_Popen() sage: palp.stdout.readline() '2 3 \n' sage: polygons._read_vertices_transposed(palp.stdout, 2, 3) [[1, 0, -1], [0, 1, -1]] """
""" Iterate over the reflexive polytopes.
INPUT:
- ``start``, ``stop``, ``step`` -- integers specifying the range to iterate over.
OUTPUT:
A generator for vertex data as a list of lists.
EXAMPLES::
sage: from sage.geometry.polyhedron.palp_database import PALPreader sage: polygons = PALPreader(2) sage: iter = polygons._iterate_list(0,4,2) sage: next(iter) [[1, 0], [0, 1], [-1, -1]] """
elif n == self._dim: # PALP sometimes returns transposed data #@!#@ vertices = self._read_vertices_transposed(palp_out, dim, n) else: raise ValueError('PALP output dimension mismatch.') else:
""" Iterate over the reflexive polytopes.
INPUT:
- ``start``, ``stop``, ``step`` -- integers specifying the range to iterate over.
OUTPUT:
A generator for lattice polyhedra.
EXAMPLES::
sage: from sage.geometry.polyhedron.palp_database import PALPreader sage: polygons = PALPreader(2) sage: iter = polygons._iterate_Polyhedron(0,4,2) sage: next(iter) A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices """
""" Iterate over the reflexive polytopes.
INPUT:
- ``start``, ``stop``, ``step`` -- integers specifying the range to iterate over.
OUTPUT:
A generator for PPL-based lattice polyhedra.
EXAMPLES::
sage: from sage.geometry.polyhedron.palp_database import PALPreader sage: polygons = PALPreader(2) sage: iter = polygons._iterate_PPL(0,4,2) sage: next(iter) A 2-dimensional lattice polytope in ZZ^2 with 3 vertices """
""" Iterate over the reflexive polytopes.
INPUT:
- ``start``, ``stop``, ``step`` -- integers specifying the range to iterate over.
OUTPUT:
A generator for PPL-based lattice polyhedra.
EXAMPLES::
sage: from sage.geometry.polyhedron.palp_database import PALPreader sage: polygons = PALPreader(2) sage: iter = polygons._iterate_PointCollection(0,4,2) sage: next(iter) [ 1, 0], [ 0, 1], [-1, -1] in Ambient free module of rank 2 over the principal ideal domain Integer Ring """
""" Iterate over the reflexive polytopes.
INPUT:
- ``output`` -- as in the :class:`PALPreader` constructor.
OUTPUT:
A function generating lattice polytopes in the specified output format.
EXAMPLES::
sage: from sage.geometry.polyhedron.palp_database import PALPreader sage: polygons = PALPreader(2) sage: func = polygons._iterate(output='list') sage: func <bound method PALPreader._iterate_list of <sage.geometry.polyhedron.palp_database.PALPreader object at ...>> sage: iter = func(0,1,1) sage: next(iter) [[1, 0], [0, 1], [-1, -1]] """ else: raise TypeError('Unknown output format (='+str(self._output)+').')
""" Iterate over all polytopes.
OUTPUT:
An iterator for all polytopes.
TESTS::
sage: from sage.geometry.polyhedron.palp_database import PALPreader sage: polygons = PALPreader(2) sage: polygons.__iter__() <generator object _iterate_Polyhedron at 0x...> """
""" Return the polytopes(s) indexed by ``item``.
EXAMPLES::
sage: from sage.geometry.polyhedron.palp_database import PALPreader sage: palp = PALPreader(3) sage: list(palp[10:30:10]) [A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 4 vertices, A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 4 vertices] """ else: try: return next(iterator(item, item+1, 1)) except StopIteration: raise IndexError('Index out of range.')
######################################################################### """ Read the PALP database for Hodge numbers of 4d polytopes.
The database is very large and not installed by default. You can install it with the shell command ``sage -i polytopes_db_4d``.
INPUT:
- ``h11``, ``h21`` -- Integers. The Hodge numbers of the reflexive polytopes to list.
Any additional keyword arguments are passed to :class:`PALPreader`.
EXAMPLES::
sage: from sage.geometry.polyhedron.palp_database import Reflexive4dHodge sage: ref = Reflexive4dHodge(1,101) # optional - polytopes_db_4d sage: next(iter(ref)).Vrepresentation() # optional - polytopes_db_4d (A vertex at (-1, -1, -1, -1), A vertex at (0, 0, 0, 1), A vertex at (0, 0, 1, 0), A vertex at (0, 1, 0, 0), A vertex at (1, 0, 0, 0)) """ """ The Python constructor.
See :class:`Reflexive4dHodge` for documentation.
TESTS::
sage: from sage.geometry.polyhedron.palp_database import Reflexive4dHodge sage: Reflexive4dHodge(1,101) # optional - polytopes_db_4d <class 'sage.geometry.polyhedron.palp_database.Reflexive4dHodge'> """ dim = 4 if data_basename is None: import os from sage.env import POLYTOPE_DATA_DIR data_basename = os.path.join(POLYTOPE_DATA_DIR, 'Hodge4d', 'all') info = data_basename + '.vinfo' if not os.path.exists(info): raise ValueError('Cannot find PALP database: '+info+ '. Did you install the polytopes_db_4d optional spkg?') PALPreader.__init__(self, dim, data_basename=data_basename, **kwds) self._h11 = h11 self._h21 = h21
""" Open PALP.
OUTPUT:
A PALP subprocess.
EXAMPLES::
sage: from sage.geometry.polyhedron.palp_database import Reflexive4dHodge sage: polygons = Reflexive4dHodge(1, 101) # optional - polytopes_db_4d sage: polygons._palp_Popen() # optional - polytopes_db_4d <subprocess.Popen object at 0x...> """ return Popen(['class-4d.x', '-He', 'H'+str(self._h21)+':'+str(self._h11)+'L100000000', '-di', self._data_basename], stdout=PIPE)
|