Interface to LattE integrale programs

sage.interfaces.latte.count(arg, ehrhart_polynomial=False, multivariate_generating_function=False, raw_output=False, verbose=False, **kwds)[source]

Call to the program count from LattE integrale.

INPUT:

  • arg – a cdd or LattE description string

  • ehrhart_polynomial, multivariate_generating_function – to compute Ehrhart polynomial or multivariate generating function instead of just counting points

  • raw_output – if True then return directly the output string from LattE

  • For all other options of the count program, consult the LattE manual

OUTPUT:

Either a string (if raw_output if set to True) or an integer (when counting points), or a polynomial (if ehrhart_polynomial is set to True) or a multivariate THING (if multivariate_generating_function is set to True)

EXAMPLES:

sage: from sage.interfaces.latte import count    # optional - latte_int
sage: P = 2 * polytopes.cube()
>>> from sage.all import *
>>> from sage.interfaces.latte import count    # optional - latte_int
>>> P = Integer(2) * polytopes.cube()

Counting integer points from either the H or V representation:

sage: count(P.cdd_Hrepresentation(), cdd=True)   # optional - latte_int
125
sage: count(P.cdd_Vrepresentation(), cdd=True)   # optional - latte_int
125
>>> from sage.all import *
>>> count(P.cdd_Hrepresentation(), cdd=True)   # optional - latte_int
125
>>> count(P.cdd_Vrepresentation(), cdd=True)   # optional - latte_int
125

Ehrhart polynomial:

sage: count(P.cdd_Hrepresentation(), cdd=True, ehrhart_polynomial=True)  # optional - latte_int
64*t^3 + 48*t^2 + 12*t + 1
>>> from sage.all import *
>>> count(P.cdd_Hrepresentation(), cdd=True, ehrhart_polynomial=True)  # optional - latte_int
64*t^3 + 48*t^2 + 12*t + 1

Multivariate generating function currently only work with raw_output=True:

sage: opts = {'cdd': True,
....:         'multivariate_generating_function': True,
....:         'raw_output': True}
sage: cddin = P.cdd_Hrepresentation()
sage: print(count(cddin, **opts))  # optional - latte_int
x[0]^2*x[1]^(-2)*x[2]^(-2)/((1-x[1])*(1-x[2])*(1-x[0]^(-1)))
 + x[0]^(-2)*x[1]^(-2)*x[2]^(-2)/((1-x[1])*(1-x[2])*(1-x[0]))
 + x[0]^2*x[1]^(-2)*x[2]^2/((1-x[1])*(1-x[2]^(-1))*(1-x[0]^(-1)))
 + x[0]^(-2)*x[1]^(-2)*x[2]^2/((1-x[1])*(1-x[0])*(1-x[2]^(-1)))
 + x[0]^2*x[1]^2*x[2]^(-2)/((1-x[2])*(1-x[1]^(-1))*(1-x[0]^(-1)))
 + x[0]^(-2)*x[1]^2*x[2]^(-2)/((1-x[2])*(1-x[0])*(1-x[1]^(-1)))
 + x[0]^2*x[1]^2*x[2]^2/((1-x[2]^(-1))*(1-x[1]^(-1))*(1-x[0]^(-1)))
 + x[0]^(-2)*x[1]^2*x[2]^2/((1-x[0])*(1-x[2]^(-1))*(1-x[1]^(-1)))
>>> from sage.all import *
>>> opts = {'cdd': True,
...         'multivariate_generating_function': True,
...         'raw_output': True}
>>> cddin = P.cdd_Hrepresentation()
>>> print(count(cddin, **opts))  # optional - latte_int
x[0]^2*x[1]^(-2)*x[2]^(-2)/((1-x[1])*(1-x[2])*(1-x[0]^(-1)))
 + x[0]^(-2)*x[1]^(-2)*x[2]^(-2)/((1-x[1])*(1-x[2])*(1-x[0]))
 + x[0]^2*x[1]^(-2)*x[2]^2/((1-x[1])*(1-x[2]^(-1))*(1-x[0]^(-1)))
 + x[0]^(-2)*x[1]^(-2)*x[2]^2/((1-x[1])*(1-x[0])*(1-x[2]^(-1)))
 + x[0]^2*x[1]^2*x[2]^(-2)/((1-x[2])*(1-x[1]^(-1))*(1-x[0]^(-1)))
 + x[0]^(-2)*x[1]^2*x[2]^(-2)/((1-x[2])*(1-x[0])*(1-x[1]^(-1)))
 + x[0]^2*x[1]^2*x[2]^2/((1-x[2]^(-1))*(1-x[1]^(-1))*(1-x[0]^(-1)))
 + x[0]^(-2)*x[1]^2*x[2]^2/((1-x[0])*(1-x[2]^(-1))*(1-x[1]^(-1)))
sage.interfaces.latte.integrate(arg, polynomial=None, algorithm='triangulate', raw_output=False, verbose=False, **kwds)[source]

Call to the function integrate from LattE integrale.

INPUT:

  • arg – a cdd or LattE description string

  • polynomial – multivariate polynomial or valid LattE polynomial description string If given, the valuation parameter of LattE is set to integrate, and is set to volume otherwise

  • algorithm – (default: 'triangulate') the integration method; use ‘triangulate’ for polytope triangulation or ‘cone-decompose’ for tangent cone decomposition method

  • raw_output – if True then return directly the output string from LattE

  • verbose – if True then return directly verbose output from LattE

  • For all other options of the integrate program, consult the LattE manual

OUTPUT: either a string (if raw_output if set to True) or a rational

EXAMPLES:

sage: from sage.interfaces.latte import integrate   # optional - latte_int
sage: P = 2 * polytopes.cube()
sage: x, y, z = polygen(QQ, 'x, y, z')
>>> from sage.all import *
>>> from sage.interfaces.latte import integrate   # optional - latte_int
>>> P = Integer(2) * polytopes.cube()
>>> x, y, z = polygen(QQ, 'x, y, z')

Integrating over a polynomial over a polytope in either the H or V representation:

sage: integrate(P.cdd_Hrepresentation(), x^2*y^2*z^2, cdd=True)   # optional - latte_int
4096/27
sage: integrate(P.cdd_Vrepresentation(), x^2*y^2*z^2, cdd=True)   # optional - latte_int
4096/27
>>> from sage.all import *
>>> integrate(P.cdd_Hrepresentation(), x**Integer(2)*y**Integer(2)*z**Integer(2), cdd=True)   # optional - latte_int
4096/27
>>> integrate(P.cdd_Vrepresentation(), x**Integer(2)*y**Integer(2)*z**Integer(2), cdd=True)   # optional - latte_int
4096/27

Computing the volume of a polytope in either the H or V representation:

sage: integrate(P.cdd_Hrepresentation(), cdd=True)   # optional - latte_int
64
sage: integrate(P.cdd_Vrepresentation(), cdd=True)   # optional - latte_int
64
>>> from sage.all import *
>>> integrate(P.cdd_Hrepresentation(), cdd=True)   # optional - latte_int
64
>>> integrate(P.cdd_Vrepresentation(), cdd=True)   # optional - latte_int
64

Polynomials given as a string in LattE description are also accepted:

sage: integrate(P.cdd_Hrepresentation(), '[[1,[2,2,2]]]', cdd=True)   # optional - latte_int
4096/27
>>> from sage.all import *
>>> integrate(P.cdd_Hrepresentation(), '[[1,[2,2,2]]]', cdd=True)   # optional - latte_int
4096/27
sage.interfaces.latte.to_latte_polynomial(polynomial)[source]

Helper function to transform a polynomial to its LattE description.

INPUT:

  • polynomial – a multivariate polynomial

OUTPUT: string that describes the monomials list and exponent vectors