Skip to content

VectorConfiguration and Fan

Vector configurations and fans.

This subpackage provides VectorConfiguration, a configuration of integral vectors (analogous to Polytope for point configurations), and Fan, a subdivision of a vector configuration into cones (analogous to Triangulation), with toric methods such as intersection numbers and Mori and Kähler cones. Both classes build on the regfans package.

Importing this subpackage also adds vc methods to Polytope, Cone and Triangulation, and a fan method to Triangulation.

VectorConfiguration

VectorConfiguration(*args, **kwargs)

Bases: VectorConfiguration

A configuration of integral vectors.

This is the analogue of Polytope (which describes a point configuration) for vector configurations. A vector configuration can be triangulated, giving a simplicial Fan.

This class extends VectorConfiguration from the regfans package, and all arguments are passed to its constructor. These are, in order:

  • vectors (ArrayLike): The vectors, one per row. They must be integral (up to the tolerance eps). Zero vectors are removed with a warning.
  • labels (Iterable[int] | None): Integer labels for the vectors. If not specified, the vectors are labelled \(1, \dots, n\) (label 0 is reserved for the origin).
  • eps (float): The tolerance used to check that the vectors are integral. Defaults to 1e-4.
  • gale_basis (Iterable[int] | None): The labels of the vectors defining the basis of the Gale transform, i.e. such that the rows of gale corresponding to these labels form the identity matrix. They must index a unimodular submatrix. If not specified and the convex hull of the vectors is reflexive, the GLSM basis of the convex hull is used (see is_reflexive).

Typically, a vector configuration is constructed from a reflexive polytope with Polytope.vc, in which case its vectors are the lattice points of the polytope (other than the origin) with the same labels.

Parameters:

  • *args (Any, default: () ) –

    Positional arguments passed to the regfans constructor (see above).

  • **kwargs (Any, default: {} ) –

    Keyword arguments passed to the regfans constructor (see above).

Raises:

  • ValueError –

    If the vectors are not integral or the labels are not integers.

Examples:

We construct a vector configuration, compute its Gale transform, and triangulate it.

>>> from cytools.vector_config import VectorConfiguration
>>> vc = VectorConfiguration([[1,0],[0,1],[-1,-1]])
>>> vc.labels
(1, 2, 3)
>>> vc.gale()
array([[1],
       [1],
       [1]])
>>> vc.triangulate().cones()
((1, 2), (1, 3), (2, 3))

Methods:

  • central_fan –

    Compute the central fan of the vector configuration.

  • conical_hull –

    Compute the conical (positive) hull of some or all of the vectors.

  • convex_hull –

    Compute the convex hull of some or all of the vectors.

  • gale –

    Compute the Gale transform of the vector configuration.

  • moving_cone –

    Compute the moving cone of the vector configuration.

  • triangulate –

    Subdivide the vector configuration, either by heights or by specified cells.

Attributes:

divisor_basis property

divisor_basis

Return the basis of divisors, as labels.

This is the basis in which the Gale transform is written, which for a vector configuration obtained from a polytope agrees with Polytope.glsm_basis.

Returns:

  • Iterable[int] –

    The labels of the vectors whose divisors form the basis.

Raises:

Examples:

>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> p.vc().divisor_basis
array([5, 6])

divisor_basis_inds property

divisor_basis_inds

Return the basis of divisors, as indices.

This is divisor_basis with every label shifted down by one, so it assumes that the vectors are labelled \(1, \dots, n\) (as is the case for configurations constructed from polytopes).

Returns:

  • ndarray –

    The indices of the vectors whose divisors form the basis.

Raises:

is_reflexive property

is_reflexive

Return whether the convex hull of the vectors is reflexive.

Translations are not allowed, i.e. the origin must be the unique interior lattice point. The result is cached. If the convex hull is reflexive and no Gale basis was specified, this also sets the Gale basis (and thus the divisor_basis) to the GLSM basis of the convex hull, computed without points interior to facets.

Returns:

  • bool –

    Whether the convex hull is reflexive.

central_fan

central_fan()

Compute the central fan of the vector configuration.

This is the regular subdivision obtained by lifting every vector to height 1. When the origin is in the interior of the convex hull of the vectors, its cones are the cones over the proper faces of the convex hull. It need not be simplicial or fine.

Returns:

  • Fan –

    The central fan.

Examples:

>>> from cytools.vector_config import VectorConfiguration
>>> vc = VectorConfiguration([[1,1],[1,-1],[-1,1],[-1,-1],[1,0]])
>>> vc.central_fan().cones()
((1, 2, 5), (1, 3), (2, 4), (3, 4))

conical_hull

conical_hull(which=None)

Compute the conical (positive) hull of some or all of the vectors.

This is the natural hull to take for a vector configuration, as opposed to the convex hull.

Also available as positive_hull, pos, coni, and cone.

Parameters:

  • which (Iterable[int] | None, default: None ) –

    The labels of the vectors to use. If not specified, all vectors are used, giving the support of the configuration.

Returns:

  • Cone –

    The cone generated by the vectors.

Examples:

>>> from cytools.vector_config import VectorConfiguration
>>> vc = VectorConfiguration([[1,0],[0,1],[-1,-1]])
>>> vc.conical_hull([1,2])
A 2-dimensional rational polyhedral cone in RR^2 generated by 2 rays

convex_hull

convex_hull(which=None)

Compute the convex hull of some or all of the vectors.

This hull is not very natural from the point of view of vector configurations, but it connects them to polytopes and point configurations. In the resulting Polytope, the chosen vectors keep their labels, while its other lattice points (such as the origin) are assigned new labels. The polytope is cached for each choice of which.

Also available as conv and polytope.

Parameters:

  • which (Iterable[int] | None, default: None ) –

    The labels of the vectors to use. If not specified, all vectors are used.

Returns:

  • Polytope –

    The convex hull of the vectors, with the vectors keeping their labels.

Examples:

>>> from cytools.vector_config import VectorConfiguration
>>> vc = VectorConfiguration([[1,0],[0,1],[-1,-1]])
>>> vc.convex_hull().is_reflexive()
True

gale

gale(set_basis=None, **kwargs)

Compute the Gale transform of the vector configuration.

This is a basis of the integral linear relations among the vectors, i.e. of the kernel of the matrix whose columns are the vectors. It is returned as an \(n \times (n-d)\) matrix, where \(n\) is the number of vectors and \(d\) is the dimension, whose \(i\)-th row is the Gale vector (the GLSM charges) of the \(i\)-th vector. When it is written in a basis, the rows corresponding to the labels in divisor_basis form the identity matrix. The result is cached.

Parameters:

  • set_basis (bool | None, default: None ) –

    Whether to write the Gale transform in the chosen basis. If not specified, it is written in the basis if and only if the convex hull of the vectors is reflexive.

  • **kwargs (Any, default: {} ) –

    Additional keyword arguments passed to the regfans method.

Returns:

Examples:

>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> p.vc().gale()
array([[1, 0],
       [9, 3],
       [6, 2],
       [1, 0],
       [1, 0],
       [0, 1]])

moving_cone

moving_cone(pushed_down=False, verbosity=0)

Compute the moving cone of the vector configuration.

This is the intersection, over all vectors, of the cones generated by the Gale vectors of all other vectors. It is the support of the part of the secondary fan corresponding to fine regular triangulations.

Parameters:

  • pushed_down (bool, default: False ) –

    Whether to return the cone in the space of the Gale transform, of dimension \(n-d\) (\(h^{1,1}\) for a configuration from a favorable reflexive 4D polytope), instead of the \(n\)-dimensional space of heights. In the latter case, the cone contains the linear height functions as a lineality space.

  • verbosity (int, default: 0 ) –

    The verbosity level.

Returns:

  • Cone –

    The moving cone.

Examples:

>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> p.vc().moving_cone(pushed_down=True).rays()
array([[3, 1],
       [1, 0]])

triangulate

triangulate(*args, **kwargs)

Subdivide the vector configuration, either by heights or by specified cells.

This calls the regfans method of the same name and converts the result into a CYTools Fan. If neither heights nor cells are given, a fine triangulation is computed from Delaunay-like heights.

Also available as subdivide.

Parameters:

  • *args (Any, default: () ) –

    Positional arguments passed to the regfans method.

  • **kwargs (Any, default: {} ) –

    Keyword arguments passed to the regfans method. These are: heights (ArrayLike | None), the heights to lift the vectors by; cells (ArrayLike | None), the cones of the fan, each given by the labels of its vectors; tol (float), the numerical tolerance used when curing heights; backend (str | None), the lifting backend, either "cgal" or "ppl" (the default is CGAL when no heights are given and PPL otherwise); make_fine (bool | None), whether to make the triangulation fine (the default is true only when no heights are given); check_heights (bool), whether to check that the heights lie in the secondary cone of the output; cure_heights (bool), whether to try to cure heights that do not; and verbosity (int), the verbosity level.

Returns:

  • Fan –

    The resulting subdivision.

Examples:

>>> from cytools.vector_config import VectorConfiguration
>>> vc = VectorConfiguration([[1,1],[1,-1],[-1,1],[-1,-1],[1,0]])
>>> vc.triangulate().cones()
((1, 3), (1, 5), (2, 4), (2, 5), (3, 4))
>>> vc.triangulate(heights=[1,1,1,1,2]).cones()
((1, 2), (1, 3), (2, 4), (3, 4))

Fan

Bases: Fan

A fan over a vector configuration.

This is the analogue of Triangulation for vector configurations. Besides the combinatorial methods inherited from the Fan class of the regfans package, it provides toric methods such as intersection numbers and Mori and Kähler cones. Most of these assume that the fan is a triangulation (i.e. simplicial) and, for the methods involving a basis of divisors or the Calabi-Yau hypersurface, that the convex hull of the vectors is a reflexive 4D polytope.

This class is not intended to be constructed directly. Instead, use VectorConfiguration.triangulate (also available as subdivide) or Triangulation.fan (see fan). The constructor is inherited from regfans and takes the following arguments:

  • vc (VectorConfiguration): The vector configuration that the fan is over.
  • cones (list[list[int]]): The maximal cones of the fan, each given by the labels of its vectors.
  • heights (ArrayLike | None): Heights defining the fan, if it is regular. If not specified, they are computed when needed.

Examples:

We construct a fan from a triangulation of a reflexive polytope and find its cones.

>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> f = p.triangulate().fan()
>>> len(f.cones())
9
>>> f.cones()[:3]
((1, 2, 3, 4), (1, 2, 3, 5), (1, 2, 4, 6))

Methods:

  • c2 –

    Compute the second Chern class of the anticanonical hypersurface.

  • cones –

    Return the cones of the fan.

  • flop_linear –

    Flip along a linear path of heights, tracking the intersection numbers.

  • from_regfans –

    Convert a regfans Fan object into a CYTools Fan object.

  • get_pc_triangulation –

    Return the triangulation of the point configuration associated to the fan.

  • h21_cy –

    Return \(h^{2,1}\) of the anticanonical Calabi-Yau hypersurface.

  • intersection_numbers –

    Compute the intersection numbers of the toric variety defined by the fan.

  • is_gorenstein_fano –

    Return whether the polytope of the anticanonical divisor is reflexive.

  • kahler_cone –

    Compute the Kähler cone of the toric variety.

  • mori_cone –

    Compute the Mori cone of the toric variety.

  • mori_rays –

    Compute the generators of the Mori cone of the toric variety.

  • newton_polytope –

    Compute the polytope of a torus-invariant divisor.

  • restricted_simps –

    Restrict the cones of the fan to the faces of the polytope.

  • secondary_cone –

    Compute the secondary cone of the fan.

c2

c2(eps=0.0001, digits=4)

Compute the second Chern class of the anticanonical hypersurface.

The second Chern class is returned as its integrals \(\int c_2 \wedge D_a\) over the prime toric divisors, computed as \(\sum_{\{i,j\}} \kappa_{ija}\) where the sum runs over the 2-dimensional cones of the fan. This assumes a 4-dimensional fan, so that the hypersurface is a Calabi-Yau threefold.

Parameters:

  • eps (float, default: 0.0001 ) –

    Passed to intersection_numbers. Currently it has no effect, since the pushed-down intersection numbers are used.

  • digits (int, default: 4 ) –

    Passed to intersection_numbers. Currently it has no effect, since the pushed-down intersection numbers are used.

Returns:

  • list[int] –

    The integrals of \(c_2\) over the divisors with labels \(1, 2, \dots\), up to the largest label used by the fan.

Examples:

>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> p.triangulate().fan().c2()
[36, 306, 204, 36, 36, -6]

cones

cones(dim=None, formal=False, as_hyps=False, as_inds=False, ind_offset=0)

Return the cones of the fan.

By default, the maximal cones are returned, each as a sorted tuple of labels. If dim is set, the dim-dimensional faces of the maximal cones are returned instead, in no particular order.

Also available as simplices and simps.

Parameters:

  • dim (int | None, default: None ) –

    If set, return the dim-dimensional cones (faces of the maximal cones). Only implemented for simplicial fans.

  • formal (bool, default: False ) –

    Whether to return the cones as Cone objects. If true, the remaining format options are ignored.

  • as_hyps (bool, default: False ) –

    Whether to return each cone by its hyperplane inequalities.

  • as_inds (bool, default: False ) –

    Whether to return each cone by the indices of its vectors instead of their labels.

  • ind_offset (int, default: 0 ) –

    An offset added to the indices when as_inds is true.

Returns:

  • tuple[tuple[int, ...], ...] | list –

    The cones, as tuples of labels, tuples of indices, lists of hyperplane inequalities, or Cone objects (the latter in a tuple).

Raises:

  • ValueError –

    If more than one of as_hyps and as_inds is set, or if dim is set for a non-simplicial fan.

Examples:

>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> f = p.triangulate().fan()
>>> f.cones()[:2]
((1, 2, 3, 4), (1, 2, 3, 5))
>>> f.cones(as_inds=True)[:2]
((0, 1, 2, 3), (0, 1, 2, 4))
>>> f.cones(formal=True)[0]
A 4-dimensional rational polyhedral cone in RR^4 generated by 4 rays

flop_linear

flop_linear(*args, **kwargs)

Flip along a linear path of heights, tracking the intersection numbers.

This calls regfans' Fan.flip_linear (which performs all the flips along the linear homotopy of heights from this fan to a target), with hooks that keep track of the intersection numbers of the Calabi-Yau hypersurface. The initial fan and every fan reached after a flip get an attribute _kappa_np holding the pushed-down intersection numbers in the divisor basis, as a NumPy array. These are computed directly for the initial fan and then updated through each flop with flop, instead of being recomputed.

Parameters:

  • *args (Any, default: () ) –

    Positional arguments passed to flip_linear.

  • **kwargs (Any, default: {} ) –

    Keyword arguments passed to flip_linear, such as h_target, direction, h_init, max_N_flips, and verbosity. They must not include hook_init or hook_flip.

Returns:

  • list –

    The output of flip_linear: the status of the homotopy (1 on success, or the exception raised), the final heights, the final fan, the hyperplanes of its secondary cone, and the number of flips (plus any requested records).

from_regfans classmethod

from_regfans(fan)

Convert a regfans Fan object into a CYTools Fan object.

The new object shares the state of the input (a shallow copy of its attributes is made). This is used by VectorConfiguration.triangulate.

Parameters:

  • fan (Fan) –

    The regfans fan.

Returns:

  • Fan –

    The CYTools fan.

get_pc_triangulation

get_pc_triangulation(check=True, verbosity=0)

Return the triangulation of the point configuration associated to the fan.

This requires that the fan respects the point configuration, i.e. that it is the fan over a star triangulation of the convex hull of the vectors (with the origin labelled 0). For regular fans, the triangulation is obtained by lifting the points by the heights of the fan, with the origin at height 0; otherwise, it is constructed from the cones of the fan, with the origin added to each of them.

Also available as triang.

Parameters:

  • check (bool, default: True ) –

    Whether to check that the fan respects the point configuration and, for regular fans, that the heights generate the triangulation.

  • verbosity (int, default: 0 ) –

    The verbosity level. Currently unused.

Returns:

Raises:

  • ValueError –

    If check is true and the fan does not respect the point configuration, or if the heights of a regular fan are negative.

  • NotImplementedError –

    If check is true and the fan is not regular.

Examples:

>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> t = p.triangulate()
>>> t.fan().get_pc_triangulation() == t
True

h21_cy

h21_cy()

Return \(h^{2,1}\) of the anticanonical Calabi-Yau hypersurface.

The Hodge numbers are determined by the polytope alone (they are birational invariants), so they are the same for every fine regular star triangulation of it, and this returns \(h^{2,1}\) of the convex hull of the vectors.

Returns:

  • int –

    The Hodge number \(h^{2,1}\).

Raises:

Examples:

>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> p.triangulate().fan().h21_cy()
272

intersection_numbers

intersection_numbers(pushed_down=False, in_basis=False, symmetrize=False, as_np_array=False, eps=_INTERSECTION_NUMBERS_DEFAULT_EPS, digits=_INTERSECTION_NUMBERS_DEFAULT_DIGITS, copy=True, verbosity=0)

Compute the intersection numbers of the toric variety defined by the fan.

The intersection numbers are returned in a sparse format: a dictionary whose keys are sorted tuples of indices \((i_1 \le \dots \le i_d)\) and whose values are the corresponding intersection numbers \(D_{i_1} \cdots D_{i_d}\), where \(D_1, \dots, D_n\) are the prime toric divisors (index \(i\) corresponding to the vector with label \(i\)) and \(D_0 = K = -\sum_i D_i\) is the canonical divisor. The numbers are computed as floating-point values. With pushed_down, they are the intersection numbers of the anticanonical hypersurface (the Calabi-Yau for a reflexive 4D polytope), \(\kappa_{ijk} = -D_0 D_i D_j D_k\).

The full set of ambient intersection numbers is computed once and cached, as are the formatted outputs for pushed_down or in_basis.

Also available as int_nums and kappa.

Parameters:

  • pushed_down (bool, default: False ) –

    Whether to return the intersection numbers of the anticanonical hypersurface instead of those of the toric variety.

  • in_basis (bool, default: False ) –

    Whether to only return the intersection numbers of the divisors in divisor_basis. Indices then refer to positions in the basis.

  • symmetrize (bool, default: False ) –

    Whether to include all permutations of the indices, instead of only sorted ones.

  • as_np_array (bool, default: False ) –

    Whether to return the intersection numbers as a dense NumPy array. This implies symmetrize=True. Without in_basis, the array is indexed by the labels, together with 0 for the canonical divisor, when pushed_down is false, and by the labels minus one when it is true.

  • eps (float, default: _INTERSECTION_NUMBERS_DEFAULT_EPS ) –

    Entries with absolute value below this are dropped. Only used when neither pushed_down nor in_basis is set, and it does not affect the cached values.

  • digits (int | None, default: _INTERSECTION_NUMBERS_DEFAULT_DIGITS ) –

    The number of decimal digits the values are rounded to (None for no rounding). Only used when neither pushed_down nor in_basis is set, and it does not affect the cached values.

  • copy (bool, default: True ) –

    Whether to return a copy of the cached output when pushed_down or in_basis is set. Set it to false only if the result will not be modified, to avoid copying it on every call.

  • verbosity (int, default: 0 ) –

    The verbosity level.

Returns:

Raises:

  • ValueError –

    If the fan is not a triangulation.

Examples:

We compute the intersection numbers of a Calabi-Yau hypersurface, which agree with those computed by CalabiYau.intersection_numbers up to rounding.

>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> f = p.triangulate().fan()
>>> kappa = f.intersection_numbers(pushed_down=True, in_basis=True)
>>> {k: round(v) for k, v in kappa.items()}
{(0, 0, 1): 1, (0, 1, 1): -3, (1, 1, 1): 9}

is_gorenstein_fano

is_gorenstein_fano()

Return whether the polytope of the anticanonical divisor is reflexive.

The anticanonical polytope is newton_polytope of \(-K = \sum_\rho D_\rho\). Its reflexivity is necessary for the toric variety to be Gorenstein Fano, and sufficient when the fan is the face fan of the convex hull of its rays. Note that the fan itself is not checked.

Returns:

  • bool –

    Whether the anticanonical polytope is reflexive.

kahler_cone

kahler_cone(pushed_down=False, in_basis=False, verbosity=0)

Compute the Kähler cone of the toric variety.

This is the dual of the mori_cone.

Parameters:

  • pushed_down (bool, default: False ) –

    Whether to drop the coordinate corresponding to the origin (the canonical divisor). Ignored if in_basis is true.

  • in_basis (bool, default: False ) –

    Whether to use divisor_basis.

  • verbosity (int, default: 0 ) –

    The verbosity level. Currently unused.

Returns:

  • Cone –

    The Kähler cone.

Examples:

>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> p.triangulate().fan().kahler_cone(in_basis=True).rays()
array([[3, 1],
       [1, 0]])

mori_cone

mori_cone(pushed_down=False, in_basis=False, verbosity=0)

Compute the Mori cone of the toric variety.

The rays of the cone are given by mori_rays.

Parameters:

  • pushed_down (bool, default: False ) –

    Whether to drop the coordinate corresponding to the origin (the canonical divisor). Ignored if in_basis is true.

  • in_basis (bool, default: False ) –

    Whether to use the basis of curves dual to divisor_basis.

  • verbosity (int, default: 0 ) –

    The verbosity level. Currently unused.

Returns:

  • Cone –

    The Mori cone.

Examples:

>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> f = p.triangulate().fan()
>>> f.mori_cone()
A 2-dimensional rational polyhedral cone in RR^7 generated by 3 rays
>>> f.mori_cone(in_basis=True).rays()
array([[ 1, -3],
       [ 1,  0],
       [ 0,  1]])

mori_rays

mori_rays()

Compute the generators of the Mori cone of the toric variety.

The generators are the torus-invariant curves corresponding to the \((d-1)\)-dimensional cones of the fan, each given by its intersection numbers with the divisors. The first column corresponds to the origin (the canonical divisor) and column \(i\) to the prime toric divisor with label \(i\).

Returns:

  • ndarray –

    The generators of the Mori cone, one per row.

Examples:

>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> p.triangulate().fan().mori_rays()
array([[  0,   1,   0,   0,   1,   1,  -3],
       [-18,   1,   9,   6,   1,   1,   0],
       [ -6,   0,   3,   2,   0,   0,   1]])

newton_polytope

newton_polytope(divisor, dilate=False)

Compute the polytope of a torus-invariant divisor.

For the divisor \(D = \sum_\rho a_\rho D_\rho\), where \(D_\rho\) are the prime toric divisors corresponding to the rays \(u_\rho\) of the fan, this is the polytope \(P_D = \{m : \langle m, u_\rho \rangle + a_\rho \geq 0 \ \forall \rho\}\), whose lattice points correspond to the monomials of the Cox ring of degree \([D]\) (the multidegree being obtained by multiplying the coefficients by the GLSM charge matrix). If \(P_D\) is not a lattice polytope, it is converted into one as described in HPolytope.

Parameters:

  • divisor (list[int]) –

    The coefficients \(a_\rho\) of the divisor, one for each ray of the fan, in the order of used_labels.

  • dilate (bool, default: False ) –

    Whether to rescale \(P_D\) so that it becomes a lattice polytope, instead of taking its integer hull.

Returns:

Examples:

The polytope of the anticanonical divisor is the polar dual of the convex hull of the rays.

>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> f = p.triangulate().fan()
>>> f.newton_polytope([1]*6).is_reflexive()
True

restricted_simps

restricted_simps(to_dim=2, padded=False, as_face_inds=False)

Restrict the cones of the fan to the faces of the polytope.

For each to_dim-dimensional face of the convex hull of the vectors, each maximal cone is intersected with the face (as sets of labels), and the maximal such intersections with at least two elements are kept. For a fine star triangulation of a polytope, this gives the restriction of the triangulation to each face.

Parameters:

  • to_dim (int, default: 2 ) –

    The dimension of the faces to restrict to.

  • padded (bool, default: False ) –

    Whether to pad restricted simplices consisting of two points by repeating their last point, so that they have three entries.

  • as_face_inds (bool, default: False ) –

    Whether to specify the points by their indices within the labels of each face instead of by their labels.

Returns:

  • list[list[list[int]]] –

    For each to_dim-dimensional face (in the order given by Polytope.faces), the sorted list of restricted simplices, each a sorted list of labels (or of face indices).

Examples:

>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> f = p.triangulate().fan()
>>> f.restricted_simps()[5]
[[1, 4, 6], [1, 5, 6], [4, 5, 6]]

secondary_cone

secondary_cone(via_circuits=False, project_lineality=False, verbosity=0)

Compute the secondary cone of the fan.

For a regular fan, a height vector generates the fan if and only if it lies in the relative interior of the secondary cone. Irregular fans are not generated by any heights, so they do not have secondary cones. When computed by local folding (via_circuits=False), the resulting cone is solid (full-dimensional) if and only if the fan is regular, so this can be used to check regularity. The result is cached separately for each value of via_circuits.

Parameters:

  • via_circuits (bool, default: False ) –

    Whether to compute the cone from the circuits of the fan instead of by local folding. This is correct for regular fans, but it can give a full-dimensional cone for an irregular fan, so it must not be used to check regularity.

  • project_lineality (bool, default: False ) –

    Whether to project out the lineality space (the linear height functions) by mapping the rays with the Gale transform. This gives the corresponding cone in the chamber complex, of dimension \(n-d\). For a fine regular star triangulation of a reflexive polytope, this is the Kähler cone of the toric variety.

  • verbosity (int, default: 0 ) –

    The verbosity level.

Returns:

  • Cone –

    The secondary cone, in the \(n\)-dimensional space of heights, or its projection if project_lineality is true.

Warning

Irregularity can only be detected with via_circuits=False.

Examples:

>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> f = p.triangulate().fan()
>>> f.secondary_cone()
A rational polyhedral cone in RR^6 defined by 18 hyperplanes
>>> f.secondary_cone(project_lineality=True).rays()
array([[3, 1],
       [1, 0]])

Other functions in cytools.vector_config

The following functions are also attached as methods to other classes: vc is available as Polytope.vc, Cone.vc, and Triangulation.vc, and fan as Triangulation.fan.

Vector configurations.

This module defines the VectorConfiguration class. Importing it also adds a vc method to Polytope and Cone that constructs the associated vector configuration.

Functions:

  • vc –

    Construct the vector configuration given by the rays of the cone.

vc

vc(self)

Construct the vector configuration given by the rays of the cone.

This function is attached to Cone as Cone.vc when cytools.vector_config is imported.

Returns:

  • VectorConfiguration –

    The vector configuration whose vectors are the rays of the cone, labelled \(1, \dots, n\).

Examples:

>>> from cytools import Cone
>>> Cone([[1,0],[0,1]]).vc().vectors()
array([[1, 0],
       [0, 1]])

Fans over vector configurations.

This module defines the Fan class, which describes a subdivision of a vector configuration into cones, together with helper functions to compute intersection numbers and to track them through flops. Importing it also adds vc and fan methods to Triangulation.

Functions:

  • curve_to_gv –

    Compute the GV invariant of the curve contracted in a flop.

  • fan –

    Return the fan associated to the triangulation.

  • flop –

    Compute the intersection numbers after flopping a circuit.

  • kappa_solve_1x1 –

    Solve for one unknown intersection number from linear relations.

  • kappa_solve_2x2 –

    Solve for two unknown intersection numbers from linear relations.

  • kappa_solve_3x3 –

    Solve for three unknown intersection numbers from linear relations.

  • kappa_solve_nxn –

    Solve for unknown intersection numbers from linear relations.

  • minface_dim –

    Return the dimension of the smallest face of the polytope containing some points.

  • vc –

    Return the vector configuration associated to the triangulation.

curve_to_gv

curve_to_gv(fan, kappa, circ, verbosity=0)

Compute the GV invariant of the curve contracted in a flop.

The circuit describes a flop between two triangulations of a 4D reflexive polytope, and the returned value is the genus-zero Gopakumar-Vafa invariant of the flopping curve class of the Calabi-Yau hypersurface. It is determined by the signature of the circuit and the dimension of the smallest face of the polytope containing it: for signature \((3,2)\) it is 1 if that face is the whole polytope and 0 otherwise, while for signature \((2,2)\) it is the triple intersection number of the three divisors spanning a cone on one side of the circuit.

Parameters:

  • fan (Fan) –

    The fan before the flop.

  • kappa (ndarray) –

    The pushed-down intersection numbers of fan in the divisor basis, as a dense array.

  • circ (Circuit) –

    The flopped circuit.

  • verbosity (int, default: 0 ) –

    The verbosity level.

Returns:

Raises:

  • ValueError –

    If the circuit does not describe a flop (i.e. both sides of its signature are not at least 2), or if the flop is not of a supported type.

fan

fan(self, include_points_interior_to_facets=None)

Return the fan associated to the triangulation.

The fan consists of the cones over the simplices of the triangulation that contain the origin (i.e. the star of the origin), as a fan over the vector configuration of the polytope. For a star triangulation, this is the complete fan defining the toric variety.

This function is attached to Triangulation as Triangulation.fan when cytools.vector_config is imported.

Parameters:

  • include_points_interior_to_facets (bool | None, default: None ) –

    Whether to include the points interior to facets in the vector configuration. If not specified, they are included if and only if the triangulation uses any of them.

Returns:

  • Fan –

    The associated fan.

Raises:

  • ValueError –

    If the origin is not a lattice point of the polytope, if the triangulation does not use the origin or has no simplex containing it, or if the triangulation uses points interior to facets but include_points_interior_to_facets is false.

Examples:

>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> f = p.triangulate().fan()
>>> f.is_fine(), f.is_regular()
(True, True)
>>> f.cones()[:3]
((1, 2, 3, 4), (1, 2, 3, 5), (1, 2, 4, 6))

flop

flop(fan, kappa, circ, verbosity=0)

Compute the intersection numbers after flopping a circuit.

Under the flop of a curve class \(C\) with GV invariant \(n_C\) (see curve_to_gv), the intersection numbers transform as \(\kappa_{ijk} \to \kappa_{ijk} - n_C\, q_i q_j q_k\), where \(q\) is the normal vector of the circuit restricted to the divisor basis.

Parameters:

  • fan (Fan) –

    The fan before the flop.

  • kappa (ndarray) –

    The pushed-down intersection numbers of fan in the divisor basis, as a dense array.

  • circ (Circuit) –

    The flopped circuit.

  • verbosity (int, default: 0 ) –

    The verbosity level.

Returns:

  • ndarray –

    The intersection numbers after the flop, as a new array.

kappa_solve_1x1

kappa_solve_1x1(pts, known)

Solve for one unknown intersection number from linear relations.

Specialization of kappa_solve_nxn for r=1, compiled with Numba.

Parameters:

  • pts (ndarray) –

    The vectors, one per row. The first row corresponds to the unknown and the rest to the known values.

  • known (ndarray) –

    The known intersection numbers, as a column vector.

Returns:

  • list[float] –

    The unknown intersection number.

Raises:

  • ValueError –

    If the normal equations are singular.

kappa_solve_2x2

kappa_solve_2x2(pts, known)

Solve for two unknown intersection numbers from linear relations.

Specialization of kappa_solve_nxn for r=2, compiled with Numba.

Parameters:

  • pts (ndarray) –

    The vectors, one per row. The first two rows correspond to the unknowns and the rest to the known values.

  • known (ndarray) –

    The known intersection numbers, as a column vector.

Returns:

  • list[float] –

    The two unknown intersection numbers.

Raises:

  • ValueError –

    If the normal equations are singular.

kappa_solve_3x3

kappa_solve_3x3(pts, known)

Solve for three unknown intersection numbers from linear relations.

Specialization of kappa_solve_nxn for r=3, compiled with Numba.

Parameters:

  • pts (ndarray) –

    The vectors, one per row. The first three rows correspond to the unknowns and the rest to the known values.

  • known (ndarray) –

    The known intersection numbers, as a column vector.

Returns:

  • list[float] –

    The three unknown intersection numbers.

Raises:

  • ValueError –

    If the normal equations are singular.

kappa_solve_nxn

kappa_solve_nxn(pts, known, r)

Solve for unknown intersection numbers from linear relations.

Helper for Fan.intersection_numbers. Finds the least-squares solution \(x\) of pts.T @ [x, known] = 0, i.e. of \(M x = b\) with M = pts[:r].T and b = -pts[r:].T @ known, via the normal equations.

Parameters:

  • pts (ndarray) –

    The vectors, one per row. The first r rows correspond to the unknowns and the rest to the known values.

  • known (ndarray) –

    The known intersection numbers, as a column vector.

  • r (int) –

    The number of unknowns.

Returns:

  • ndarray –

    The r unknown intersection numbers.

minface_dim

minface_dim(config, labels)

Return the dimension of the smallest face of the polytope containing some points.

The polytope is the convex hull of the vector configuration.

Parameters:

Returns:

  • int –

    The dimension of the smallest face of the convex hull of config whose labels include all of labels.

vc

vc(self, include_points_interior_to_facets=None)

Return the vector configuration associated to the triangulation.

This is the (cached) vector configuration returned by Polytope.vc for the polytope of the triangulation.

This function is attached to Triangulation as Triangulation.vc when cytools.vector_config is imported.

Parameters:

  • include_points_interior_to_facets (bool | None, default: None ) –

    Whether to include the points interior to facets. If not specified, they are included if and only if the triangulation uses any of them.

Returns:

Examples:

>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> p.triangulate().vc().labels
(1, 2, 3, 4, 5, 6)