latte_count uses LattE's count function to count the (integer) lattice points in a polytope and compute Ehrhart polynomials.

count_core(spec, dir = tempdir(), quiet = TRUE, mpoly = TRUE, ...)

latte_count(spec, dir = tempdir(), quiet = TRUE, mpoly = TRUE, ...)

latte_fcount(spec, dir = tempdir(), quiet = TRUE, mpoly = TRUE, ...)

Arguments

spec

Specification, see details and examples

dir

Directory to place the files in, without an ending /

quiet

Show latte output?

mpoly

When opts = "--ehrhart-polynomial", return the mpoly version of it

...

Additional arguments to pass to the function, see count --help at the command line to see examples. Note that dashes - should be specified with underscores _

Value

The count. If the count is a number has less than 10 digits, an integer is returned. If the number has 10 or more digits, an integer in a character string is returned. You may want to use the gmp package's as.bigz to parse it.

Details

The specification should be one of the following: (1) a character string or strings containing an inequality in the mpoly expression format (see examples), (2) a list of vertices, (3) a list of A and b for the equation Ax <= b (see examples), or (4) raw code for LattE's count program. If a character vector is supplied, (1) and (4) are distinguished by the number of strings.

Behind the scenes, count works by writing a latte file and running count on it. If a specification other than a length one character is given to it (which is considered to be the code), count attempts to convert it into LattE code and then run count on it.

Examples

if (has_latte()) { spec <- c("x + y <= 10", "x >= 1", "y >= 1") latte_count(spec) # 45 latte_count(spec, quiet = FALSE) # 45 latte_count(spec, dilation = 10) # 3321 latte_count(spec, homog = TRUE) # 45 # by default, the output from LattE is in list.files(tempdir()) list.files(tempdir(), recursive = TRUE) # ehrhart polynomials latte_count(spec, ehrhart_polynomial = TRUE) latte_count(spec, ehrhart_polynomial = TRUE, mpoly = FALSE) # ehrhart series (raw since mpoly can't handle rational functions) latte_count(spec, ehrhart_series = TRUE) # simplified ehrhart series - not yet implemented #latte_count(spec, simplified_ehrhart_polynomial = TRUE) # first terms of the ehrhart series latte_count(spec, ehrhart_taylor = 1) # latte_count(spec, ehrhart_taylor = 2) # latte_count(spec, ehrhart_taylor = 3) # latte_count(spec, ehrhart_taylor = 4) # multivariate generating function latte_count(spec, multivariate_generating_function = TRUE) # by vertices spec <- list(c(1,1), c(10,1), c(1,10), c(10,10)) latte_count(spec) latte_count(spec, vrep = TRUE) code <- " 5 3 1 -1 0 1 0 -1 1 -1 -1 0 1 0 0 0 1 " latte_count(code) # for Ax <= b, see this example from the latte manual p.10 A <- matrix(c( 1, 0, 0, 1, 1, 1, -1, 0, 0, -1 ), nrow = 5, byrow = TRUE) b <- c(1, 1, 1, 0, 0) latte_count(list(A = A, b = b)) }
#> Ray Support Algorithm. #> The codimension is 3 #> #> Left = 1, Col = 3, Size = 3 Time: 0.00 #> Left = 1, Col = 3, Size = 3, Time: 0.00 #> 45
#> This is LattE integrale 1.6 #> Available from http://www.math.ucdavis.edu/~latte/ #> #> Invocation: /Applications/latte/bin/count.bin /var/folders/r3/126_d6t55f5d32tplbg5mk1d0c48s9/T//RtmpugrA1n/2020_03_17_23_45_33_Z3vEafHYTa/count_code.latte #> Checking whether the input polytope is empty or not...size = 3 x 3 #> Number Type = rational #> done. #> Removing redundant inequalities and finding hidden equalities using cddlib...done. #> Ax <= b, given as (b|-A): #> ========================= #> [10 -1 -1] #> [-1 1 0] #> [-1 0 1] #> #> Ax = b, given as (b|-A): #> ======================== #> [] #> #> Time for reading and preprocessing: 0 sec #> The polytope has 3 vertices. #> Time for computing vertices and supporting cones: 0 sec #> Time for dualizing general cones: 0 sec #> Dualizing all cones...All cones are now dualized. #> Time for dualizing general cones: 0 sec #> decomposeCones_Single: Decomposing all cones. (Memory Save on) #> 3 cones total to be done!decomposeCones_Single: degree = 1 #> Number of cones: 3 #> Triangulating cone... done. #> 0 vertex cones done. #> Triangulating cone... done. #> 1 vertex cones done. #> Triangulating cone... done. #> 2 vertex cones done. #> #> Total Unimodular Cones: 3 #> Maximum number of simplicial cones in memory at once: 0 #> #> **** The number of lattice points is: **** #> Total time: 0 sec
#> Time for reading and preprocessing: 0 sec #> Time for computing vertices and supporting cones: 0 sec #> Time for irrationalizing general cones: 0 sec #> Time for dualizing general cones: 0 sec #> Time for triangulating cones into simplicial cones: 0 sec #> Time for Barvinok decomposition and residue calculation: 0 sec #> Total time: 0 sec #> Total number of simplicial cones: 3 #> Total number of unimodular cones: 3 #> Maximum depth of the decomposition tree: 0 #>
#> Undeclared vertex specification, setting vrep = TRUE.
#> [1] 3