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– ifTruethen return directly the output string from LattEFor all other options of the count program, consult the LattE manual
OUTPUT:
Either a string (if
raw_outputif set toTrue) or an integer (when counting points), or a polynomial (ifehrhart_polynomialis set toTrue) or a multivariate THING (ifmultivariate_generating_functionis set toTrue)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 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– ifTruethen return directly the output string from LattEverbose– ifTruethen return directly verbose output from LattEFor all other options of the integrate program, consult the LattE manual
OUTPUT: either a string (if
raw_outputif set toTrue) or a rationalEXAMPLES:
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