count: Count Integer Points in a Polytope

Description Usage Arguments Details Value Examples

View source: R/count.r

Description

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

Usage

1
count(spec, dir = tempdir(), opts = "", quiet = TRUE, mpoly = TRUE)

Arguments

spec

specification, see details and examples

dir

directory to place the files in, without an ending /

opts

options for count; "" for a hyperplane representation, "–vrep" for a vertex representation; see the LattE manual at http://www.math.ucdavis.edu/~latte

quiet

show latte output

mpoly

when opts = "–ehrhart-polynomial", return the mpoly version of 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, or (3) raw code for LattE's count program. If a character vector is supplied, (1) and (3) 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.

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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
## Not run: 





spec <- c("x + y <= 10", "x >= 1", "y >= 1")
count(spec)
count(spec, opts = "--dilation=10")
count(spec, opts = "--homog")

# by default, the output from LattE is in
list.files(tempdir())
list.files(tempdir(), recursive = TRUE)

# ehrhart polynomials
count(spec, opts = "--ehrhart-polynomial")
count(spec, opts = "--ehrhart-polynomial", mpoly = FALSE)

# ehrhart series (raw since mpoly can't handle rational functions)
count(spec, opts = "--ehrhart-series")

# simplified ehrhart series - not yet implemented
#count(spec, opts = "--simplified-ehrhart-polynomial")

# first 3 terms of the ehrhart series
count(spec, opts = "--ehrhart-taylor=3")

# multivariate generating function
count(spec, opts = "--multivariate-generating-function")


# the number of tables with the same marginals
data(politics)
count(c(
  "x11 + x12 == 10",
  "x21 + x22 == 10",
  "x11 + x21 == 9",
  "x12 + x22 == 11",
  "x11 >= 0", "x21 >= 0", "x12 >= 0", "x22 >= 0"
))
countTables(politics)


# by vertices
spec <- list(c(1,1),c(10,1),c(1,10),c(10,10))
count(spec)
count(spec, opts = "--vrep")

code <- "
5 3
1 -1 0
1 0 -1
1 -1 -1
0 1 0
0 0 1
"
count(code)




## End(Not run)

algstat documentation built on May 29, 2017, 10:34 p.m.

Related to count in algstat...