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 stringehrhart_polynomial
,multivariate_generating_function
– to compute Ehrhart polynomial or multivariate generating function instead of just counting pointsraw_output
– ifTrue
then return directly the output string from LattEFor all other options of the count program, consult the LattE manual
name
– – (default:'y'
) a stringThe variable names of the Laurent polynomial ring of the multivariate_generating_function
Factorization_sort
(default:False
) andFactorization_simplify
(default:False
) – booleansThese are passed on to
sage.structure.factorization.Factorization
when creating the result.
OUTPUT:
Either a string (if
raw_output
if set toTrue
) or an integer (when counting points), or a polynomial (ifehrhart_polynomial
is set toTrue
) or a tuple ofFactorization
objectsFactorization
whose factors are Laurent polynomials (ifmultivariate_generating_function
is set toTrue
)EXAMPLES:
sage: from sage.interfaces.latte import count sage: P = 2 * polytopes.cube()
>>> from sage.all import * >>> from sage.interfaces.latte import count >>> 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, # optional - latte_int ....: ehrhart_polynomial=True) 64*t^3 + 48*t^2 + 12*t + 1
>>> from sage.all import * >>> count(P.cdd_Hrepresentation(), cdd=True, # optional - latte_int ... ehrhart_polynomial=True) 64*t^3 + 48*t^2 + 12*t + 1
Returning a string of the multivariate generating function when
raw_output=True
. Returning the summands of the multivariate generating function in a tuple ofFactorization
objects with the same format assage.geometry.polyhedron.generating_function.generating_function_of_integral_points()
does whenresult_as_tuple=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))) sage: count(cddin, cdd=True, multivariate_generating_function=True) # optional - latte_int ((y0^2*y1^-2*y2^-2) * (-y1 + 1)^-1 * (-y2 + 1)^-1 * (1 - y0^-1)^-1, (y0^-2*y1^-2*y2^-2) * (-y1 + 1)^-1 * (-y2 + 1)^-1 * (-y0 + 1)^-1, (y0^2*y1^-2*y2^2) * (-y1 + 1)^-1 * (1 - y2^-1)^-1 * (1 - y0^-1)^-1, (y0^-2*y1^-2*y2^2) * (-y1 + 1)^-1 * (-y0 + 1)^-1 * (1 - y2^-1)^-1, (y0^2*y1^2*y2^-2) * (-y2 + 1)^-1 * (1 - y1^-1)^-1 * (1 - y0^-1)^-1, (y0^-2*y1^2*y2^-2) * (-y2 + 1)^-1 * (-y0 + 1)^-1 * (1 - y1^-1)^-1, y0^2*y1^2*y2^2 * (1 - y2^-1)^-1 * (1 - y1^-1)^-1 * (1 - y0^-1)^-1, (y0^-2*y1^2*y2^2) * (-y0 + 1)^-1 * (1 - y2^-1)^-1 * (1 - y1^-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))) >>> count(cddin, cdd=True, multivariate_generating_function=True) # optional - latte_int ((y0^2*y1^-2*y2^-2) * (-y1 + 1)^-1 * (-y2 + 1)^-1 * (1 - y0^-1)^-1, (y0^-2*y1^-2*y2^-2) * (-y1 + 1)^-1 * (-y2 + 1)^-1 * (-y0 + 1)^-1, (y0^2*y1^-2*y2^2) * (-y1 + 1)^-1 * (1 - y2^-1)^-1 * (1 - y0^-1)^-1, (y0^-2*y1^-2*y2^2) * (-y1 + 1)^-1 * (-y0 + 1)^-1 * (1 - y2^-1)^-1, (y0^2*y1^2*y2^-2) * (-y2 + 1)^-1 * (1 - y1^-1)^-1 * (1 - y0^-1)^-1, (y0^-2*y1^2*y2^-2) * (-y2 + 1)^-1 * (-y0 + 1)^-1 * (1 - y1^-1)^-1, y0^2*y1^2*y2^2 * (1 - y2^-1)^-1 * (1 - y1^-1)^-1 * (1 - y0^-1)^-1, (y0^-2*y1^2*y2^2) * (-y0 + 1)^-1 * (1 - y2^-1)^-1 * (1 - y1^-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 stringpolynomial
– multivariate polynomial or valid LattE polynomial description string If given, the valuation parameter of LattE is set to integrate, and is set to volume otherwisealgorithm
– (default:'triangulate'
) the integration method; use ‘triangulate’ for polytope triangulation or ‘cone-decompose’ for tangent cone decomposition methodraw_output
– ifTrue
then return directly the output string from LattEverbose
– ifTrue
then return directly verbose output from LattEFor all other options of the integrate program, consult the LattE manual
OUTPUT: either a string (if
raw_output
if set toTrue
) or a rationalEXAMPLES:
sage: from sage.interfaces.latte import integrate sage: P = 2 * polytopes.cube() sage: x, y, z = polygen(QQ, 'x, y, z')
>>> from sage.all import * >>> from sage.interfaces.latte import integrate >>> 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