barvinok_maximize: move --(bernstein-)recurse option to main library
[barvinok.git] / doc / implementation.tex
blob458da8aef6ea54774d0270181a8192749939c71a
1 \section{Implementation details}
3 \subsection{An interior point of a polyhedron}
4 \label{s:interior}
6 We often need a point that lies in the interior of a polyhedron.
7 The function \ai[\tt]{inner\_point} implements the following algorithm.
8 Each polyhedron $P$ can be written as the sum of a polytope $P'$ and a cone $C$
9 (the \ai{recession cone} or \ai{characteristic cone} of $P$).
10 Adding a positive multiple of the sum of the extremal rays of $C$ to
11 the \ai{barycenter}
13 \frac 1 N \sum_i \vec v_i(\vec p)
15 of $P'$, where $N$ is the number of vertices, results in a point
16 in the interior of $P$.
18 \subsection{The integer points in the fundamental parallelepiped of a simple cone}
20 \label{s:fundamental}
22 This section is based on \shortciteN[Lemma 5.1]{Barvinok1992volume} and
23 \shortciteN{Koeppe2006experiments}.
25 \sindex{simple}{cone}
26 \sindex{open}{facet}
27 \sindex{open}{ray}
28 \sindex{explicit}{representation}
29 In this section we will deal exclusively with \ai{simple cone}s,
30 i.e. $d$-dimensional cones with $d$ extremal rays and $d$ facets.
31 \index{open facet}%
32 Some of the facets of these cones may be open.
33 Since we will mostly be dealing with cones in their
34 \ai{explicit representation}, we will have occasion to speak of
35 ``\ai{open ray}s'', by which we will mean that the facet not
36 containing the ray is open. (There is only one such facet because the cone
37 is simple.)
39 \sindex{fundamental}{parallelepiped}
40 \begin{definition}[Fundamental parallelepiped]
41 Let $K = \vec v + \poshull \lb\, \vec u_i \,\rb$ be
42 a closed (shifted) cone, then the \defindex{fundamental parallelepiped} $\Pi$
43 of $K$ is
45 \Pi = \vec v +
46 \lb\, \sum_i \alpha_i \vec u_i \mid 0 \leq \alpha_i < 1 \,\rb
49 If some of the rays $\vec u_i$ of $K$ are open, then the constraints on
50 the corresponding coefficient $\alpha_i$ are such that $0 < \alpha_i \le 1$.
51 \end{definition}
53 \begin{lemma}[Integer points in the fundamental parallelepiped of a simple cone]
54 \label{l:fundamental}
55 Let $K = \vec v + \poshull \lb\, \vec u_i \,\rb$ be a closed simple cone
56 and let $A$ be the matrix with the generators $\vec u_i$ of $K$
57 as rows.
58 Furthermore let $V A W^{-1} = S = \diag \vec s$ be the \indac{SNF} of $A$.
59 Then the integer points in the fundamental parallelepiped of $K$ are given
61 \begin{eqnarray}
62 \label{eq:parallelepiped}
63 \vec w^\T & = & \vec v^\T + \fractional{(\vec k^\T W - \vec v^\T) A^{-1}} A
65 \nonumber
66 & = &
67 \vec v^T +
68 \sum_{i=1}^d
69 \fractional{\sps{\sum_{j=1}^d k_j \vec w^T_j - \vec v^\T}{\vec u^*_i}} \vec u_i,
70 \end{eqnarray}
71 where $\vec u^*_i$ are the columns of $A^{-1}$ and $k_j \in \ZZ$ ranges
72 over $0 \le k_j < s_j$.
73 \end{lemma}
75 \begin{proof}
76 Since $0 \le \fractional{x} < 1$, it is clear that each such $\vec w$
77 lies inside the fundamental parallelepiped.
78 Furthermore,
79 \begin{eqnarray*}
80 \vec w^\T & = & \vec v^\T + \fractional{(\vec k^\T W - \vec v^\T) A^{-1}} A
82 & = &
83 \vec v^T +
84 \left(
85 (\vec k^\T W - \vec v^\T) A^{-1} - \floor{(\vec k^\T W - \vec v^\T) A^{-1}}
86 \right) A
88 & = &
89 \underbrace{\vec k^\T W\mathstrut}_{\in \ZZ^{1\times d}}
91 \underbrace{\floor{(\vec k^\T W - \vec v^\T) A^{-1}}}_{\in \ZZ^{1\times d}}
92 \underbrace{A\mathstrut}_{\in \ZZ^{d\times d}} \in \ZZ^{1\times d}.
93 \end{eqnarray*}
94 Finally, if two such $\vec w$ are equal, i.e., $\vec w_1 = \vec w_2$,
95 then
96 \begin{eqnarray*}
97 \vec 0^\T = \vec w_1^\T - \vec w_2^\T
98 & = & \vec k_1^\T W - \vec k_2^\T W + \vec p^\T A
100 & = & \left(\vec k_1^\T - \vec k_2^\T \right) W + \vec p^\T V^{-1} S W,
101 \end{eqnarray*}
102 with $\vec p \in \ZZ^d$,
103 or $\vec k_1 \equiv \vec k_2 \mod \vec s$, i.e., $\vec k_1 = \vec k_2$.
104 Since $\det S = \det A$, we obtain all points in the fundamental parallelepiped
105 by taking all $\vec k \in \ZZ^d$ satisfying $0 \le k_j < s_j$.
106 \end{proof}
108 If the cone $K$ is not closed then the coefficients of the open rays
109 should be in $(0,1]$ rather than in $[0,1)$.
110 In (\ref{eq:parallelepiped}),
111 we therefore need to replace the fractional part $\fractional{x} = x - \floor{x}$
112 by $\cractional{x} = x - \ceil{x-1}$ for the open rays.
114 \begin{figure}
115 \intercol=1.2cm
116 \begin{xy}
117 <\intercol,0pt>:<0pt,\intercol>::
118 \POS@i@={(0,-3),(0,0),(4,2),(4,-3)},{0*[grey]\xypolyline{*}}
119 \POS@i@={(0,-3),(0,0),(4,2)},{0*[|(2)]\xypolyline{}}
120 \POS(-1,0)\ar(4.5,0)
121 \POS(0,-3)\ar(0,3)
122 \POS(0,0)\ar@[|(3)](0,-1)
123 \POS(0,0)\ar@[|(3)](2,1)
124 \POS(0,-1)\ar@{--}@[|(2)](2,0)
125 \POS(2,1)\ar@{--}@[|(2)](2,0)
126 \POS(0,0)*{\bullet}
127 \POS(1,0)*{\bullet}
128 \end{xy}
129 \caption{The integer points in the fundamental parallelepiped of $K$}
130 \label{f:parallelepiped}
131 \end{figure}
133 \begin{example}
134 Let $K$ be the cone
136 K = \sm{0 \\ 0} + \poshull \lb\, \sm{2 \\ 1}, \sm{0 \\ -1} \,\rb
139 shown in Figure~\ref{f:parallelepiped}.
140 Then
142 A = \sm{2 & 1\\0 & -1} \qquad A^{-1} = \sm{1/2 & 1/2 \\ 0 & -1 }
146 \sm{1 & 0 \\ 1 & 1 } \sm{2 & 1\\0 & -1} = \sm{1 & 0 \\ 0 & 2} \sm{2 & 1 \\ 1 & 0}.
148 We have $\det A = \det S = 2$ and
149 $\vec k_1^\T = \sm{0 & 0}$ and $\vec k_2^\T = \sm{0 & 1}$.
150 Therefore,
152 \vec w_1^\T = \fractional{\sm{0 & 0} \sm{2 & 1 \\ 1 & 0} \sm{1/2 & 1/2 \\ 0 & -1 }}
153 \sm{2 & 1\\0 & -1} = \sm{0 & 0}
156 \begin{eqnarray*}
157 \vec w_2^\T & = &
158 \fractional{\sm{0 & 1} \sm{2 & 1 \\ 1 & 0} \sm{1/2 & 1/2 \\ 0 & -1 }}
159 \sm{2 & 1\\0 & -1}
161 & = &
162 \sm{1/2 & 1/2} \sm{2 & 1\\0 & -1} = \sm{1 & 0}.
163 \end{eqnarray*}
164 \end{example}
169 \subsection{Barvinok's decomposition of simple cones in primal space}
170 \label{s:decomposition}
172 As described by \shortciteN{DeLoera2003effective}, the first
173 implementation of Barvinok's counting algorithm applied
174 \ai{Barvinok's decomposition} \shortcite{Barvinok1994} in the \ai{dual space}.
175 \ai{Brion's polarization trick} \shortcite{Brion88} then ensures that you
176 do not need to worry about lower-dimensional faces in the decomposition.
177 Another way of avoiding the lower-dimensional faces, in the \ai{primal space},
178 is to perturb the vertex of the cone such that none of the lower-dimensional
179 face encountered contain any integer points \shortcite{Koeppe2006primal}.
180 In this section, we describe another technique that is based on allowing
181 some of the facets of the cone to be open.
183 The basic step in Barvinok's decomposition is to replace a
184 $d$-dimensional simple cone
185 $K = \poshull \lb\, \vec u_i \,\rb_{i=1}^d \subset \QQ^d$
186 by a signed sum of (at most) $d$ cones $K_j$
187 with a smaller determinant (in absolute value).
188 The cones are obtained by successively replacing each generator
189 of $K$ by an appropriately chosen
190 $\vec w = \sum_{i=1}^d \alpha_i \vec u_i$, i.e.,
191 \begin{equation}
192 \label{eq:K_j}
193 K_j =
194 \poshull \left(\lb\, \vec u_i \,\rb_{i=1}^d
195 \setminus \{\, \vec u_j \,\} \cup \{\, \vec w \,\}\right)
197 \end{equation}
198 To see that we can use these $K_j$ to perform a decomposition,
199 rearrange the $\vec u_i$ such that for all $1 \le i \le k$ we have
200 $\alpha_i < 0$ and for all $k+1 \le i \le d'$ we have $\alpha_i > 0$,
201 with $d - d'$ the number of zero $\alpha_i$.
202 We may assume $k < d'$; otherwise replace $\vec w \in B$ by
203 $-\vec w \in B$. We have
205 \vec w + \sum_{i=1}^k (-\alpha_i) \vec u_i =
206 \sum_{i=k+1}^{d'} \alpha_i \vec u_i
209 \begin{equation}
210 \label{eq:sub}
211 \sum_{i=0}^k \beta_i \vec u_i =
212 \sum_{i=k+1}^{d'} \alpha_i \vec u_i
214 \end{equation}
215 with $\vec u_0 = \vec w$, $\beta_0 = 1$ and $\beta_i = -\alpha_i > 0$
216 for $1 \le i \le k$. Any two $\vec u_j$ and $\vec u_l$ on the same side
217 of the equality are on opposite sides of the linear hull $H$ of
218 the other $\vec u_i$s since there exists a convex combination
219 of $\vec u_j$ and $\vec u_l$ on this hyperplane.
220 In particular, since $\alpha_j$ and $\alpha_l$ have the same sign,
221 we have
222 \begin{equation}
223 \label{eq:opposite}
224 \frac {\alpha_j}{\alpha_j+\alpha_l} \vec u_j
226 \frac {\alpha_l}{\alpha_j+\alpha_l} \vec u_l
227 \in H
228 \qquad\text{for $\alpha_i \alpha_l > 0$}
230 \end{equation}
231 The corresponding cones $K_j$ and $K_l$ (with $K_0 = K$)
232 therefore intersect in a common face $F \subset H$.
233 Let
235 K' :=
236 \poshull \left(\lb\, \vec u_i \,\rb_{i=1}^d \cup \{\, \vec w \,\}\right)
239 then any $\vec x \in K'$ lies both in some cone $K_i$ with
240 $0 \le i \le k$ and in some cone $K_i$ with $k+1 \le i \le d'$.
241 (Just subtract an appropriate multiple of Equation~(\ref{eq:sub}).)
242 The cones
243 $\{\, K_i \,\}_{i=0}^k$
245 $\{\, K_i \,\}_{i=k+1}^{d'}$
246 therefore both form a triangulation of $K'$ and hence
247 \begin{equation}
248 \label{eq:triangulations}
249 \indf{K'}
251 \indf{K} + \sum_{i=1}^k \indf{K_i} - \sum_{j\in J_1} \indf{F_j}
253 \sum_{i=k+1}^{d'} \indf{K_i} - \sum_{j\in J_2} \indf{F_j}
254 \end{equation}
256 \begin{equation}
257 \label{eq:decomposition}
258 \indf{K} = \sum_{i=1}^{d'} \varepsilon_i \indf{K_i} + \sum_j \delta_j \indf{F_j}
260 \end{equation}
261 with $\varepsilon_i = -1$ for $1 \le i \le k$,
262 $\varepsilon_i = 1$ for $k+1 \le i \le d'$,
263 $\delta_j \in \{ -1, 1 \}$ and $F_j$ some lower-dimensional faces.
264 Figure~\ref{fig:w} shows the possible configurations
265 in the case of a $3$-dimensional cone.
267 \begin{figure}
268 \intercol=0.48cm
269 \begin{center}
270 \begin{minipage}{0cm}
271 \begin{xy}
272 <\intercol,0pt>:<0pt,\intercol>::
274 \xybox{
275 \POS(-2,-1)="a"*+!U{+}
276 \POS(2,0)="b"*+!L{+}
277 \POS(0,2)="c"*+!D{+}
278 \POS(0,0)="w"*+!DR{\vec w}
279 \POS"a"\ar@{-}"b"
280 \POS"b"\ar@{-}"c"
281 \POS"c"\ar@{-}"a"
282 \POS"a"\ar@{--}"w"
283 \POS"b"\ar@{--}"w"
284 \POS"c"\ar@{--}"w"
285 }="a"
286 +R+(2,0)*!L
287 \xybox{
288 \POS(-2,-1)="a"*+!U{+}
289 \POS(2,0)="b"*+!L{-}
290 \POS(0,2)="c"*+!D{+}
291 \POS(-3,1)="w"*+!DR{\vec w}
292 \POS"a"\ar@{-}"b"
293 \POS"b"\ar@{-}"c"
294 \POS"c"\ar@{-}"a"
295 \POS"a"\ar@{--}"w"
296 \POS"b"\ar@{--}"w"
297 \POS"c"\ar@{--}"w"
298 }="b"
299 +R+(2,0)*!L
300 \xybox{
301 \POS(-2,-1)="a"*+!U{-}
302 \POS(2,0)="b"*+!U{+}
303 \POS(0,2)="c"*+!D{-}
304 \POS(5,-1)="w"*+!L{\vec w}
305 \POS"a"\ar@{-}"b"
306 \POS"b"\ar@{-}"c"
307 \POS"c"\ar@{-}"a"
308 \POS"a"\ar@{--}"w"
309 \POS"b"\ar@{--}"w"
310 \POS"c"\ar@{--}"w"
312 \POS"a"
313 +D-(0,1)*!U
314 \xybox{
315 \POS(-2,-1)="a"*+!U{0}
316 \POS(2,0)="b"*+!L{+}
317 \POS(0,2)="c"*+!D{+}
318 \POS(1,1)="w"*+!DL{\vec w}
319 \POS"a"\ar@{-}"b"
320 \POS"b"\ar@{-}"c"
321 \POS"c"\ar@{-}"a"
322 \POS"a"\ar@{--}"w"
324 \POS"b"
325 +DL-(0,1)*!UL
326 \xybox{
327 \POS(-2,-1)="a"*+!U{0}
328 \POS(2,0)="b"*+!U{+}
329 \POS(0,2)="c"*+!D{-}
330 \POS(4,-2)="w"*+!L{\vec w}
331 \POS"a"\ar@{-}"b"
332 \POS"b"\ar@{-}"c"
333 \POS"c"\ar@{-}"a"
334 \POS"a"\ar@{--}"w"
335 \POS"b"\ar@{--}"w"
337 \end{xy}
338 \end{minipage}
339 \end{center}
340 \caption[Possible locations of the vector $\vec w$ with respect to the rays
341 of a $3$-dimensional cone.]
342 {Possible locations of $\vec w$ with respect to the rays
343 of a $3$-dimensional cone. The figure shows a section of the cones.}
344 \label{fig:w}
345 \end{figure}
347 As explained above there are several ways of avoiding the lower-dimensional
348 faces in (\ref{eq:decomposition}). Here we will apply the following proposition.
349 \begin{proposition}[\shortciteN{Koeppe2007parametric}]
350 \label{p:inclusion-exclusion}
351 Let
352 \begin{equation}
353 \label{eq:full-source-identity}
354 \sum_{i\in {I_1}} \epsilon_i [P_i] + \sum_{i\in {I_2}} \delta_k [P_i] = 0
355 \end{equation}
356 be a (finite) linear identity of indicator functions of closed
357 polyhedra~$P_i\subseteq\QQ^d$, where the
358 polyhedra~$P_i$ with $i \in I_1$ are full-dimensional and those with $i \in I_2$
359 lower-dimensional. Let each closed polyhedron be given as
361 P_i = \left\{\, \vec x \mid \sp{b^*_{i,j}}{x} \ge \beta_{i,j} \text{
362 for $j\in J_i$}\,\right\}
365 Let $\vec y\in\QQ^d$ be a vector such that $\langle \vec b^*_{i,j}, \vec
366 y\rangle \neq 0$ for all $i\in I_1\cup I_2$, $j\in J_i$.
367 For each $i\in I_1$, we define the half-open polyhedron
368 \begin{equation}
369 \label{eq:half-open-by-y}
370 \begin{aligned}
371 \tilde P_i = \Bigl\{\, \vec x\in\QQ^d \mid {}&
372 \sp{b^*_{i,j}}{x} \ge \beta_{i,j}
373 \text{ for $j\in J_i$ with $\sp{b^*_{i,j}}{y} > 0$,} \\
374 & \sp{b^*_{i,j}}{x} > \beta_{i,j}
375 \text{ for $j\in J_i$ with $\sp{b^*_{i,j}}{y} < 0$} \,\Bigr\}.
376 \end{aligned}
377 \end{equation}
378 Then
379 \begin{equation}
380 \label{eq:target-identity}
381 \sum_{i\in I_1} \epsilon_i [\tilde P_i] = 0.
382 \end{equation}
383 \end{proposition}
384 When applying this proposition to (\ref{eq:decomposition}), we obtain
385 \begin{equation}
386 \label{eq:decomposition:2}
387 \indf{\tilde K} = \sum_{i=1}^{d'} \varepsilon_i \indf{\tilde K_i}
389 \end{equation}
390 where we start out
391 from a given $\tilde K$, which may be $K$ itself, i.e., a fully closed cone,
392 or the result of a previous application of the proposition, either through
393 a triangulation (Section~\ref{s:triangulation}) or a previous decomposition.
394 In either case, a suitable $\vec y$ is available, either as an interior
395 point of the cone or as the vector used in the previous application
396 (which may require a slight perturbation if it happens to lie on one of
397 the new facets of the cones $K_i$).
398 We are, however, free to construct a new $\vec y$ on each application
399 of the proposition.
400 In fact, we will not even construct such a vector explicitly, but
401 rather apply a set of rules that is equivalent to a valid choice of $\vec y$.
402 Below, we will present an ``intuitive'' motivation for these rules.
403 For a more algebraic, shorter, and arguably simpler motivation we
404 refer to \shortciteN{Koeppe2007parametric}.
406 The vector $\vec y$ has to satisfy $\sp{b^*_j}y > 0$ for normals $\vec b^*_j$
407 of closed facets and $\sp{b^*_j}y < 0$ for normals $\vec b^*_j$ of open facets of
408 $\tilde K$.
409 These constraints delineate a non-empty open cone $R$ from which
410 $\vec y$ should be selected. For some of the new facets of the cones
411 $\tilde K_j$, the cone $R$ will not be cut by the affine hull of the facet.
412 The closedness of these facets is therefore predetermined by $\tilde K$.
413 For the other facets, a choice will have to be made.
414 To be able to make the choice based on local information and without
415 computing an explicit vector $\vec y$, we use the following convention.
416 We first assign an arbitrary total order to the rays.
417 If (the affine hull of) a facet separates the two rays not on the facet $\vec u_i$
418 and $\vec u_j$, i.e., $\alpha_i \alpha_j > 0$ (\ref{eq:opposite}), then
419 we choose $\vec y$ to lie on the side of the smallest ray, according
420 to the chosen order.
421 That is, $\sp{{\tilde n}_{ij}}y > 0$, for
422 $\vec {\tilde n}_{ij}$ the normal of the facet pointing towards this smallest ray.
423 Otherwise, i.e., if $\alpha_i \alpha_j < 0$,
424 the interior of $K$ will lie on one side
425 of the facet and then we choose $\vec y$ to lie on the other side.
426 That is, $\sp{{\tilde n}_{ij}}y > 0$, for
427 $\vec {\tilde n}_{ij}$ the normal of the facet pointing away from the cone $K$.
428 Figure~\ref{fig:primal:examples} shows some example decompositions with
429 an explicitly marked $\vec y$.
431 \begin{figure}
432 \begin{align*}
433 \intercol=0.48cm
434 \begin{xy}
435 <\intercol,0pt>:<0pt,\intercol>::
436 \POS(-2,-1)="a"*+!U{+}
437 \POS(2,0)="b"*+!L{+}
438 \POS(0,2)="c"*+!D{+}
439 \POS"a"\ar@{-}@[|(3)]"b"
440 \POS"b"\ar@{-}@[|(3)]"c"
441 \POS"c"\ar@{-}@[|(3)]"a"
442 \POS(0.3,0.6)*{\bullet},*+!L{\vec y}
443 \end{xy}
445 \intercol=0.48cm
446 \begin{xy}
447 <\intercol,0pt>:<0pt,\intercol>::
448 \POS(2,0)="b"*+!L{+}
449 \POS(0,2)="c"*+!D{+}
450 \POS(0,0)="w"*+!DR{\vec w}
451 \POS"b"\ar@{-}@[|(3)]"c"
452 \POS"b"\ar@{-}@[|(3)]"w"
453 \POS"c"\ar@{-}@[|(3)]"w"
454 \POS(0.3,0.6)*{\bullet},*+!L{\vec y}
455 \end{xy}
457 \begin{xy}
458 <\intercol,0pt>:<0pt,\intercol>::
459 \POS(-2,-1)="a"*+!U{+}
460 \POS(0,2)="c"*+!D{+}
461 \POS(0,0)="w"*+!DR{\vec w}
462 \POS"c"\ar@{-}@[|(3)]"a"
463 \POS"a"\ar@{-}@[|(3)]"w"
464 \POS"c"\ar@{--}@[|(3)]"w"
465 \POS(0.3,0.6)*{\bullet},*+!L{\vec y}
466 \end{xy}
468 \begin{xy}
469 <\intercol,0pt>:<0pt,\intercol>::
470 \POS(-2,-1)="a"*+!U{+}
471 \POS(2,0)="b"*+!L{+}
472 \POS(0,0)="w"*+!DR{\vec w}
473 \POS"a"\ar@{-}@[|(3)]"b"
474 \POS"a"\ar@{--}@[|(3)]"w"
475 \POS"b"\ar@{--}@[|(3)]"w"
476 \POS(0.3,0.6)*{\bullet},*+!L{\vec y}
477 \end{xy}
479 \intercol=0.48cm
480 \begin{xy}
481 <\intercol,0pt>:<0pt,\intercol>::
482 \POS(-2,-1)="a"*+!U{+}
483 \POS(2,0)="b"*+!L{+}
484 \POS(0,2)="c"*+!D{+}
485 \POS"a"\ar@{--}@[|(3)]"b"
486 \POS"b"\ar@{-}@[|(3)]"c"
487 \POS"c"\ar@{--}@[|(3)]"a"
488 \POS(-2.5,-1.5)*{\bullet},*+!U{\vec y}
489 \end{xy}
491 \intercol=0.48cm
492 \begin{xy}
493 <\intercol,0pt>:<0pt,\intercol>::
494 \POS(2,0)="b"*+!L{+}
495 \POS(0,2)="c"*+!D{+}
496 \POS(0,0)="w"*+!DR{\vec w}
497 \POS"b"\ar@{-}@[|(3)]"c"
498 \POS"b"\ar@{--}@[|(3)]"w"
499 \POS"c"\ar@{--}@[|(3)]"w"
500 \POS(-2.5,-1.5)*{\bullet},*+!U{\vec y}
501 \end{xy}
503 \begin{xy}
504 <\intercol,0pt>:<0pt,\intercol>::
505 \POS(-2,-1)="a"*+!U{+}
506 \POS(0,2)="c"*+!D{+}
507 \POS(0,0)="w"*+!DR{\vec w}
508 \POS"c"\ar@{--}@[|(3)]"a"
509 \POS"a"\ar@{--}@[|(3)]"w"
510 \POS"c"\ar@{-}@[|(3)]"w"
511 \POS(-2.5,-1.5)*{\bullet},*+!U{\vec y}
512 \end{xy}
514 \begin{xy}
515 <\intercol,0pt>:<0pt,\intercol>::
516 \POS(-2,-1)="a"*+!U{+}
517 \POS(2,0)="b"*+!L{+}
518 \POS(0,0)="w"*+!DR{\vec w}
519 \POS"a"\ar@{--}@[|(3)]"b"
520 \POS"a"\ar@{-}@[|(3)]"w"
521 \POS"b"\ar@{-}@[|(3)]"w"
522 \POS(-2.5,-1.5)*{\bullet},*+!U{\vec y}
523 \end{xy}
525 \intercol=0.48cm
526 \begin{xy}
527 <\intercol,0pt>:<0pt,\intercol>::
528 \POS(-2,-1)="a"*+!U{+}
529 \POS(2,0)="b"*+!L{+}
530 \POS(0,2)="c"*+!D{+}
531 \POS"a"\ar@{--}@[|(3)]"b"
532 \POS"b"\ar@{-}@[|(3)]"c"
533 \POS"c"\ar@{-}@[|(3)]"a"
534 \POS(1,-1.5)*{\bullet},*+!L{\vec y}
535 \end{xy}
537 \intercol=0.48cm
538 \begin{xy}
539 <\intercol,0pt>:<0pt,\intercol>::
540 \POS(2,0)="b"*+!L{+}
541 \POS(0,2)="c"*+!D{+}
542 \POS(0,0)="w"*+!DR{\vec w}
543 \POS"b"\ar@{-}@[|(3)]"c"
544 \POS"b"\ar@{--}@[|(3)]"w"
545 \POS"c"\ar@{-}@[|(3)]"w"
546 \POS(1,-1.5)*{\bullet},*+!L{\vec y}
547 \end{xy}
549 \begin{xy}
550 <\intercol,0pt>:<0pt,\intercol>::
551 \POS(-2,-1)="a"*+!U{+}
552 \POS(0,2)="c"*+!D{+}
553 \POS(0,0)="w"*+!DR{\vec w}
554 \POS"c"\ar@{-}@[|(3)]"a"
555 \POS"a"\ar@{--}@[|(3)]"w"
556 \POS"c"\ar@{--}@[|(3)]"w"
557 \POS(1,-1.5)*{\bullet},*+!L{\vec y}
558 \end{xy}
560 \begin{xy}
561 <\intercol,0pt>:<0pt,\intercol>::
562 \POS(-2,-1)="a"*+!U{+}
563 \POS(2,0)="b"*+!L{+}
564 \POS(0,0)="w"*+!DR{\vec w}
565 \POS"a"\ar@{--}@[|(3)]"b"
566 \POS"a"\ar@{-}@[|(3)]"w"
567 \POS"b"\ar@{-}@[|(3)]"w"
568 \POS(1,-1.5)*{\bullet},*+!L{\vec y}
569 \end{xy}
571 \intercol=0.48cm
572 \begin{xy}
573 <\intercol,0pt>:<0pt,\intercol>::
574 \POS(-2,-1)="a"*+!U{0}
575 \POS(2,0)="b"*+!L{+}
576 \POS(0,2)="c"*+!D{+}
577 \POS"a"\ar@{-}@[|(3)]"b"
578 \POS"b"\ar@{-}@[|(3)]"c"
579 \POS"c"\ar@{-}@[|(3)]"a"
580 \POS(1,0.2)*{\bullet},*+!R{\vec y}
581 \end{xy}
583 \intercol=0.48cm
584 \begin{xy}
585 <\intercol,0pt>:<0pt,\intercol>::
586 \POS(-2,-1)="a"*+!U{0}
587 \POS(2,0)="b"*+!L{+}
588 \POS(1,1)="w"*+!DL{\vec w}
589 \POS"a"\ar@{-}@[|(3)]"b"
590 \POS"a"\ar@{-}@[|(3)]"w"
591 \POS"b"\ar@{-}@[|(3)]"w"
592 \POS(1,0.2)*{\bullet},*+!R{\vec y}
593 \end{xy}
595 \begin{xy}
596 <\intercol,0pt>:<0pt,\intercol>::
597 \POS(-2,-1)="a"*+!U{0}
598 \POS(0,2)="c"*+!D{+}
599 \POS(1,1)="w"*+!DL{\vec w}
600 \POS"c"\ar@{-}@[|(3)]"a"
601 \POS"a"\ar@{--}@[|(3)]"w"
602 \POS"c"\ar@{-}@[|(3)]"w"
603 \POS(1,0.2)*{\bullet},*+!R{\vec y}
604 \end{xy}
606 \intercol=0.48cm
607 \begin{xy}
608 <\intercol,0pt>:<0pt,\intercol>::
609 \POS(-2,-1)="a"*+!U{0}
610 \POS(2,0)="b"*+!U{+}
611 \POS(0,2)="c"*+!D{-}
612 \POS"a"\ar@{-}@[|(3)]"b"
613 \POS"b"\ar@{--}@[|(3)]"c"
614 \POS"c"\ar@{-}@[|(3)]"a"
615 \POS(1.5,1.5)*{\bullet},*+!D{\vec y}
616 \end{xy}
618 \intercol=0.48cm
619 \begin{xy}
620 <\intercol,0pt>:<0pt,\intercol>::
621 \POS(-2,-1)="a"*+!U{0}
622 \POS(0,2)="c"*+!D{-}
623 \POS(4,-2)="w"*+!L{\vec w}
624 \POS"c"\ar@{-}@[|(3)]"a"
625 \POS"a"\ar@{-}@[|(3)]"w"
626 \POS"c"\ar@{--}@[|(3)]"w"
627 \POS(1.5,1.5)*{\bullet},*+!D{\vec y}
628 \end{xy}
630 \begin{xy}
631 <\intercol,0pt>:<0pt,\intercol>::
632 \POS(-2,-1)="a"*+!U{0}
633 \POS(2,0)="b"*+!U{+}
634 \POS(4,-2)="w"*+!L{\vec w}
635 \POS"a"\ar@{--}@[|(3)]"b"
636 \POS"a"\ar@{-}@[|(3)]"w"
637 \POS"b"\ar@{--}@[|(3)]"w"
638 \POS(1.5,1.5)*{\bullet},*+!D{\vec y}
639 \end{xy}
641 \intercol=0.48cm
642 \begin{xy}
643 <\intercol,0pt>:<0pt,\intercol>::
644 \POS(-2,-1)="a"*+!U{0}
645 \POS(2,0)="b"*+!U{+}
646 \POS(0,2)="c"*+!D{-}
647 \POS"a"\ar@{--}@[|(3)]"b"
648 \POS"b"\ar@{--}@[|(3)]"c"
649 \POS"c"\ar@{-}@[|(3)]"a"
650 \POS(4.7,-2.5)*{\bullet},*+!R{\vec y}
651 \end{xy}
653 \intercol=0.48cm
654 \begin{xy}
655 <\intercol,0pt>:<0pt,\intercol>::
656 \POS(-2,-1)="a"*+!U{0}
657 \POS(0,2)="c"*+!D{-}
658 \POS(4,-2)="w"*+!L{\vec w}
659 \POS"c"\ar@{-}@[|(3)]"a"
660 \POS"a"\ar@{--}@[|(3)]"w"
661 \POS"c"\ar@{--}@[|(3)]"w"
662 \POS(4.7,-2.5)*{\bullet},*+!R{\vec y}
663 \end{xy}
665 \begin{xy}
666 <\intercol,0pt>:<0pt,\intercol>::
667 \POS(-2,-1)="a"*+!U{0}
668 \POS(2,0)="b"*+!U{+}
669 \POS(4,-2)="w"*+!L{\vec w}
670 \POS"a"\ar@{-}@[|(3)]"b"
671 \POS"a"\ar@{--}@[|(3)]"w"
672 \POS"b"\ar@{--}@[|(3)]"w"
673 \POS(4.7,-2.5)*{\bullet},*+!R{\vec y}
674 \end{xy}
675 \end{align*}
676 \caption{Examples of decompositions in primal space.}
677 \label{fig:primal:examples}
678 \end{figure}
680 To see that there is a $\vec y$ satisfying the above constraints,
681 we need to show that $R \cap S$ is non-empty, with
682 $S = \{ \vec y \mid \sp{{\tilde n}_{i_kj_k}}y > 0 \text{ for all $k$}\}$.
683 It will be easier to show this set is non-empty when the $\vec u_i$ form
684 an orthogonal basis. Applying a non-singular linear transformation $T$
685 does not change the decomposition of $\vec w$ in terms of the $\vec u_i$ (i.e., the
686 $\alpha_i$ remain unchanged), nor does this change
687 any of the scalar products in the constraints that define $R \cap S$
688 (the normals are transformed by $\left(T^{-1}\right)^\T$).
689 Finding a vector $\vec y \in T(R \cap S)$ ensures that
690 $T^{-1}(\vec y) \in R \cap S$.
691 Without loss of generality, we can therefore assume for the purpose of
692 showing that $R \cap S$ is non-empty that
693 the $\vec u_i$ indeed form an orthogonal basis.
695 In the orthogonal basis, we have $\vec b_i^* = \vec u_i$
696 and the corresponding inward normal $\vec N_i$ is either
697 $\vec u_i$ or $-\vec u_i$.
698 Furthermore, each normal of a facet of $S$ of the first type is of the
699 form $\vec {\tilde n}_{i_kj_k} = a_k \vec u_{i_k} - b_k \vec u_{j_k}$, with
700 $a_k, b_k > 0$ and ${i_k} < {j_k}$,
701 while for the second type each normal is of the form
702 $\vec {\tilde n}_{i_kj_k} = -a_k \vec u_{i_k} - b_k \vec u_{j_k}$, with
703 $a_k, b_k > 0$.
704 If $\vec {\tilde n}_{i_kj_k} = a_k \vec u_{i_k} - b_k \vec u_{j_k}$
705 is the normal of a facet of $S$
706 then either
707 $(\vec N_{i_k}, \vec N_{j_k}) = (\vec u_{i_k}, \vec u_{j_k})$
709 $(\vec N_{i_k}, \vec N_{j_k}) = (-\vec u_{i_k}, -\vec u_{j_k})$.
710 Otherwise, the facet would not cut $R$.
711 Similarly,
712 if $\vec {\tilde n}_{i_kj_k} = -a_k \vec u_{i_k} - b_k \vec u_{j_k}$
713 is the normal of a facet of $S$
714 then either
715 $(\vec N_{i_k}, \vec N_{j_k}) = (\vec u_{i_k}, -\vec u_{j_k})$
717 $(\vec N_{i_k}, \vec N_{j_k}) = (-\vec u_{i_k}, \vec u_{j_k})$.
718 Assume now that $R \cap S$ is empty, then there exist
719 $\lambda_k, \mu_i \ge 0$ not all zero
720 such that
721 $\sum_k \lambda_k \vec {\tilde n}_{i_kj_k} + \sum_l \mu_i \vec N_i = \vec 0$.
722 Assume $\lambda_k > 0$ for some facet of the first type.
723 If $\vec N_{j_k} = -\vec u_{j_k}$, then $-b_k$ can only be canceled
724 by another facet $k'$ of the first type with $j_k = i_{k'}$, but then
725 also $\vec N_{j_{k'}} = -\vec u_{j_{k'}}$. Since the $j_k$ are strictly
726 increasing, this sequence has to stop with a strictly positive coefficient
727 for the largest $\vec u_{j_k}$ in this sequence.
728 If, on the other hand, $\vec N_{i_k} = \vec u_{i_k}$, then $a_k$ can only
729 be canceled by the normal of a facet $k'$ of the second kind
730 with $i_k = j_{k'}$, but then
731 $\vec N_{i_{k'}} = -\vec u_{i_{k'}}$ and we return to the first case.
732 Finally, if $\lambda_k > 0$ only for normals of facets of the second type,
733 then either $\vec N_{i_k} = -\vec u_{i_k}$ or $\vec N_{j_k} = -\vec u_{j_k}$
734 and so the coefficient of one of these basis vectors will be strictly
735 negative.
736 That is, the sum of the normals will never be zero and
737 the set $R \cap S$ is non-empty.
739 For each ray $\vec u_j$ of cone $K_i$, i.e., the cone with $\vec u_i$ replaced
740 by $\vec w$, we now need to determine whether the facet not containing this
741 ray is closed or not. We denote the (inward) normal of this cone by
742 $\vec n_{ij}$. Note that cone $K_j$ (if it appears in (\ref{eq:triangulations}),
743 i.e., $\alpha_j \ne 0$) has the same facet opposite $\vec u_i$
744 and its normal $\vec n_{ji}$ will be equal to either $\vec n_{ij}$ or
745 $-\vec n_{ij}$, depending on whether we are dealing with an ``external'' facet,
746 i.e., a facet of $K'$, or an ``internal'' facet.
747 If, on the other hand, $\alpha_j = 0$, then $\vec n_{ij} = \vec n_{0j}$.
748 If $\sp{n_{ij}}y > 0$, then the facet is closed.
749 Otherwise it is open.
750 It follows that the two (or more) occurrences of external facets are either all open
751 or all closed, while for internal facets, exactly one is closed.
753 First consider the facet not containing $\vec u_0 = \vec w$.
754 If $\alpha_i > 0$, then $\vec u_i$ and $\vec w$ are on the same side of the facet
755 and so $\vec n_{i0} = \vec n_{0i}$. Otherwise, $\vec n_{i0} = -\vec n_{i0}$.
756 Second, if $\alpha_j = 0$, then replacing $\vec u_i$ by $\vec w$ does not
757 change the affine hull of the facet and so $\vec n_{ij} = \vec n_{0j}$.
758 Now consider the case that $\alpha_i \alpha_j < 0$, i.e., $\vec u_i$
759 and $\vec u_j$ are on the same side of the hyperplane through the other rays.
760 If we project $\vec u_i$, $\vec u_j$ and $\vec w$ onto a plane orthogonal
761 to the ridge through the other rays, then the possible locations of $\vec w$
762 with respect to $\vec u_i$ and $\vec u_j$ are shown in Figure~\ref{fig:w:same}.
763 If both $\vec n_{0i}$ and $\vec n_{0j}$ are closed then $\vec y$ lies in region~1
764 and therefore $\vec n_{ij}$ (as well as $\vec n_{ji}$) is closed too.
765 Similarly, if both $\vec n_{0i}$ and $\vec n_{0j}$ are open then so is
766 $\vec n_{ij}$. If only one of the facets is closed, then, as explained above,
767 we choose $\vec n_{ij}$ to be open, i.e., we take $\vec y$ to lie in region~3
768 or~5.
769 Figure~\ref{fig:w:opposite} shows the possible configurations
770 for the case that $\alpha_i \alpha_j > 0$.
771 If exactly one of $\vec n_{0i}$ and $\vec n_{0j}$ is closed, then
772 $\vec y$ lies in region~3 or region~5 and therefore $\vec n_{ij}$ is closed iff
773 $\vec n_{0j}$ is closed.
774 Otherwise, as explained above, we choose $\vec n_{ij}$ to be closed if $i < j$.
776 \begin{figure}
777 \intercol=0.7cm
778 \begin{minipage}{0cm}
779 \begin{xy}
780 <\intercol,0pt>:<0pt,\intercol>::
781 \POS(-4,0)="a"\ar@[|(2)]@{-}(4,0)
782 \POS?(0)/\intercol/="b"\POS(2,0)*\xybox{"b"-"a":(0,0)\ar^{\vec n_{0i}}(0,0.75)}
783 \POS(2,0)*{\bullet},*+!U{\vec u_j}
784 \POS(-2,-3)="a"\ar@[|(2)]@{-}(2,3)
785 \POS?(0)/\intercol/="b"\POS(1,1.5)*\xybox{"b"-"a":(0,0)\ar^{\vec n_{0j}}(0,-0.75)}
786 \POS(1,1.5)*{\bullet},*+!R{\vec u_i}
787 \POS(-2,3)="a"\ar@{-}(2,-3)
788 \POS?(0)/\intercol/="b"\POS(1.5,-2.25)
789 *\xybox{"b"-"a":(0,0)\ar_{\vec n_{ji}}^{\vec n_{ij}}(0,+0.75)}
790 \POS(1.5,-2.25)*{\bullet},*+!R{\vec u_0 = \vec w}
791 \POS(0,0)*{\bullet}
792 \POS(3,1.5)*+[o][F]{\scriptstyle 1}
793 \POS(0,2.5)*+[o][F]{\scriptstyle 2}
794 \POS(-3,1.5)*+[o][F]{\scriptstyle 3}
795 \POS(-3,-1.5)*+[o][F]{\scriptstyle 4}
796 \POS(0,-3)*+[o][F]{\scriptstyle 5}
797 \POS(3,-1.5)*+[o][F]{\scriptstyle 6}
798 \end{xy}
799 \end{minipage}
800 \begin{minipage}{0cm}
801 \begin{xy}
802 <\intercol,0pt>:<0pt,\intercol>::
803 \POS(-4,0)="a"\ar@[|(2)]@{-}(4,0)
804 \POS?(0)/\intercol/="b"\POS(2,0)*\xybox{"b"-"a":(0,0)\ar^{\vec n_{0i}}(0,0.75)}
805 \POS(2,0)*{\bullet},*+!U{\vec u_j}
806 \POS(-2,-3)="a"\ar@[|(2)]@{-}(2,3)
807 \POS?(0)/\intercol/="b"\POS(1,1.5)*\xybox{"b"-"a":(0,0)\ar^{\vec n_{0j}}(0,-0.75)}
808 \POS(1,1.5)*{\bullet},*+!R{\vec u_i}
809 \POS(-2,3)="a"\ar@{-}(2,-3)
810 \POS?(0)/\intercol/="b"\POS(-1.5,2.25)
811 *\xybox{"b"-"a":(0,0)\ar_{\vec n_{ji}}^{\vec n_{ij}}(0,+0.75)}
812 \POS(-1.5,2.25)*{\bullet},*+!R{\vec u_0 = \vec w}
813 \POS(0,0)*{\bullet}
814 \POS(3,1.5)*+[o][F]{\scriptstyle 1}
815 \POS(0,2.5)*+[o][F]{\scriptstyle 2}
816 \POS(-3,1.5)*+[o][F]{\scriptstyle 3}
817 \POS(-3,-1.5)*+[o][F]{\scriptstyle 4}
818 \POS(0,-3)*+[o][F]{\scriptstyle 5}
819 \POS(3,-1.5)*+[o][F]{\scriptstyle 6}
820 \end{xy}
821 \end{minipage}
822 \caption{Possible locations of $\vec w$ with respect to $\vec u_i$ and
823 $\vec u_j$, projected onto a plane orthogonal to the other rays, when
824 $\alpha_i \alpha_j < 0$.}
825 \label{fig:w:same}
826 \end{figure}
828 \begin{figure}
829 \intercol=0.7cm
830 \begin{minipage}{0cm}
831 \begin{xy}
832 <\intercol,0pt>:<0pt,\intercol>::
833 \POS(-4,0)="a"\ar@[|(2)]@{-}(4,0)
834 \POS?(0)/\intercol/="b"\POS(2,0)*\xybox{"b"-"a":(0,0)\ar^{\vec n_{0i}}(0,0.75)}
835 \POS(2,0)*{\bullet},*+!U{\vec u_j}
836 \POS(-2,3)="a"\ar@[|(2)]@{-}(2,-3)
837 \POS?(0)/\intercol/="b"\POS(-1,1.5)*\xybox{"b"-"a":(0,0)\ar^{\vec n_{0j}}(0,+0.75)}
838 \POS(-1,1.5)*{\bullet},*+!R{\vec u_i}
839 \POS(-2,-3)="a"\ar@{-}(2,3)
840 \POS?(0)/\intercol/="b"\POS(1.5,2.25)
841 *\xybox{"b"-"a":(0,0)\ar^{\vec n_{ji}}(0,+0.75)
842 \POS(0,0)\ar_{\vec n_{ij}}(0,-0.75)}
843 \POS(1.5,2.25)*{\bullet},*+!L{\vec u_0 = \vec w}
844 \POS(0,0)*{\bullet}
845 \POS(3,1.5)*+[o][F]{\scriptstyle 1}
846 \POS(0,2.5)*+[o][F]{\scriptstyle 2}
847 \POS(-3,1.5)*+[o][F]{\scriptstyle 3}
848 \POS(-3,-1.5)*+[o][F]{\scriptstyle 4}
849 \POS(0,-3)*+[o][F]{\scriptstyle 5}
850 \POS(3,-1.5)*+[o][F]{\scriptstyle 6}
851 \end{xy}
852 \end{minipage}
853 \begin{minipage}{0cm}
854 \begin{xy}
855 <\intercol,0pt>:<0pt,\intercol>::
856 \POS(-4,0)="a"\ar@[|(2)]@{-}(4,0)
857 \POS?(0)/\intercol/="b"\POS(2,0)*\xybox{"b"-"a":(0,0)\ar^{\vec n_{0i}}(0,0.75)}
858 \POS(2,0)*{\bullet},*+!U{\vec u_j}
859 \POS(-2,3)="a"\ar@[|(2)]@{-}(2,-3)
860 \POS?(0)/\intercol/="b"\POS(-1,1.5)*\xybox{"b"-"a":(0,0)\ar^{\vec n_{0j}}(0,+0.75)}
861 \POS(-1,1.5)*{\bullet},*+!R{\vec u_i}
862 \POS(-2,-3)="a"\ar@{-}(2,3)
863 \POS?(0)/\intercol/="b"\POS(-1.5,-2.25)
864 *\xybox{"b"-"a":(0,0)\ar^{\vec n_{ji}}(0,+0.75)
865 \POS(0,0)\ar_{\vec n_{ij}}(0,-0.75)}
866 \POS(-1.5,-2.25)*{\bullet},*+!L{\vec u_0 = \vec w}
867 \POS(0,0)*{\bullet}
868 \POS(3,1.5)*+[o][F]{\scriptstyle 1}
869 \POS(0,2.5)*+[o][F]{\scriptstyle 2}
870 \POS(-3,1.5)*+[o][F]{\scriptstyle 3}
871 \POS(-3,-1.5)*+[o][F]{\scriptstyle 4}
872 \POS(0,-3)*+[o][F]{\scriptstyle 5}
873 \POS(3,-1.5)*+[o][F]{\scriptstyle 6}
874 \end{xy}
875 \end{minipage}
876 \caption{Possible locations of $\vec w$ with respect to $\vec u_i$ and
877 $\vec u_j$, projected onto a plane orthogonal to the other rays, when
878 $\alpha_i \alpha_j > 0$.}
879 \label{fig:w:opposite}
880 \end{figure}
882 The algorithm is summarized in Algorithm~\ref{alg:closed}, where
883 we use the convention that in cone $K_i$, $\vec u_i$ refers to
884 $\vec u_0 = \vec w$.
885 Note that we do not need any of the rays or normals in this code.
886 The only information we need is the closedness of the facets in the
887 original cone and the signs of the $\alpha_i$.
889 \begin{algorithm}
890 \begin{tabbing}
891 next \= next \= next \= \kill
892 if $\alpha_j = 0$ \\
893 \> closed[$K_i$][$\vec u_j$] := closed[$\tilde K$][$\vec u_j$] \\
894 else if $i = j$ \\
895 \> if $\alpha_j > 0$ \\
896 \> \> closed[$K_i$][$\vec u_j$] := closed[$\tilde K$][$\vec u_j$] \\
897 \> else \\
898 \> \> closed[$K_i$][$\vec u_j$] := $\lnot$closed[$\tilde K$][$\vec u_j$] \\
899 else if $\alpha_i \alpha_j > 0$ \\
900 \> if closed[$\tilde K$][$\vec u_i$] = closed[$\tilde K$][$\vec u_j$] \\
901 \> \> closed[$K_i$][$\vec u_j$] := $i < j$ \\
902 \> else \\
903 \> \> closed[$K_i$][$\vec u_j$] := closed[$\tilde K$][$\vec u_j$] \\
904 else \\
905 \> closed[$K_i$][$\vec u_j$] := closed[$\tilde K$][$\vec u_i$] and
906 closed[$\tilde K$][$\vec u_j$]
907 \end{tabbing}
908 \caption{Determine whether the facet opposite $\vec u_j$ is closed in $K_i$.}
909 \label{alg:closed}
910 \end{algorithm}
912 \subsection{Triangulation in primal space}
913 \label{s:triangulation}
915 As in the case for Barvinok's decomposition (Section~\ref{s:decomposition}),
916 we can transform a triangulation of a (closed) cone into closed simple cones
917 into a triangulation of half-open simple cones that fully partitions the
918 original cone, i.e., such that the half-open simple cones do not intersect at their
919 facets.
920 Again, we apply Proposition~\ref{p:inclusion-exclusion} with $\vec y$
921 an interior point of the cone (Section~\ref{s:interior}).
923 \subsection{Multivariate quasi-polynomials as lists of polynomials}
925 There are many definitions for a (univariate) \ai{quasi-polynomial}.
926 \shortciteN{Ehrhart1977} uses a definition based on {\em periodic number}s.
928 \begin{definition}
929 \label{d:periodic:1}
930 A rational \defindex{periodic number} $U(p)$
931 is a function $\ZZ \to \QQ$,
932 such that there exists a \defindex{period} $q$
933 such that $U(p) = U(p')$ whenever $p \equiv p' \mod q$.
934 \end{definition}
936 \begin{definition}
937 \label{d:qp:1}
938 A (univariate)
939 \defindex{quasi-polynomial}\/ $f$ of degree $d$ is
940 a function
942 f(n) = c_d(n) \, n^d + \cdots + c_1(n) \, n + c_0
945 where $c_i(n)$ are rational periodic numbers.
946 I.e., it is a polynomial expression of degree $d$
947 with rational periodic numbers for coefficients.
948 The \defindex{period} of a quasi-polynomial is the \ac{lcm}
949 of the periods of its coefficients.
950 \end{definition}
952 Other authors (e.g., \shortciteNP{Stanley1986})
953 use the following definition of a quasi-polynomial.
954 \begin{definition}
955 \label{d:qp:1:list}
956 A function $f : \ZZ \to \QQ$ is
957 a (univariate) \defindex{quasi-polynomial} of period $q$ if there
958 exists a list of $q$ polynomials $g_i \in \QQ[T]$ for $0 \le i < q$ such
959 that
961 f (s) = g_i(s) \qquad \hbox{if $s \equiv i \mod {q}$}
964 The functions $g_i$ are called the {\em constituents}.
965 \index{constituent}
966 \end{definition}
968 In our implementation, we use Definition~\ref{d:qp:1},
969 but whereas
970 \shortciteN{Ehrhart1977} uses a list of $q$ rational
971 numbers enclosed in square brackets to represent periodic
972 numbers, our periodic numbers are polynomial expressions
973 in fractional parts (Section~\ref{a:data}).
974 These fractional parts naturally extend to multivariate
975 quasi-polynomials.
976 The bracketed (``explicit'') periodic numbers can
977 be extended to multiple variables by nesting them
978 (e.g., \shortciteNP{Loechner1999}).
980 Definition~\ref{d:qp:1:list} could be extended in a similar way
981 by having a constituent for each residue modulo a vector period $\vec q$.
982 However, as pointed out by \citeN{Woods2006personal}, this may not result
983 in the minimum number of constituents.
984 A vector period can be considered as a lattice with orthogonal generators and
985 the number of constituents is equal to the index or determinant of that lattice.
986 By considering more general lattices, we can potentially reduce the number
987 of constituents.
988 \begin{definition}
989 \label{d:qp}
990 A function $f : \ZZ^n \to \QQ$ is
991 a (multivariate) \defindex{quasi-polynomial} of period $L$ if there
992 exists a list of $\det L$ polynomials $g_{\vec i} \in \QQ[T_1,\ldots,T_n]$
993 for $\vec i$ in the fundamental parallelepiped of $L$ such
994 that
996 f (\vec s) = g_{\vec i}(\vec s) \qquad \hbox{if $\vec s \equiv \vec i \mod L$}
999 \end{definition}
1001 To compute the period lattice from a fractional representation, we compute
1002 the appropriate lattice for each fractional part and then take their intersection.
1003 Recall that the argument of each fractional part is an affine expression
1004 in the parameters $(\sp a p + c)/m$,
1005 with $\vec a \in \ZZ^n$ and $c, m \in \ZZ$.
1006 Such a fractional part is translation invariant over
1007 any (integer) value of $\vec p$
1008 such that $\sp a p + m t = 0$, for some $\vec t \in \ZZ$.
1009 Solving this homogeneous equation over the integers (in our implementation,
1010 we use \PolyLib/'s \ai[\tt]{SolveDiophantine}) gives the general solution
1012 \begin{bmatrix}
1013 \vec p \\ t
1014 \end{bmatrix}
1016 \begin{bmatrix}
1017 U_1 \\ U_2
1018 \end{bmatrix}
1019 \vec x
1020 \qquad\text{for $\vec x \in \ZZ^n$}
1023 The matrix $U_1 \in \ZZ^{n \times n}$ then has the generators of
1024 the required lattice as columns.
1025 The constituents are computed by plugging in each integer point
1026 in the fundamental parallelepiped of the lattice.
1027 These points themselves are computed as explained in Section~\ref{s:fundamental}.
1028 Note that for computing the constituents, it is sufficient to take any
1029 representative of the residue class. For example, we could take
1030 $\vec w^\T = \vec k^\T W$ in the notations of Lemma~\ref{l:fundamental}.
1032 \begin{example}[\shortciteN{Woods2006personal}]
1033 Consider the parametric polytope
1035 P_{s,t}=\{\, x \mid 0 \le x \le (s+t)/2 \,\}
1038 The enumerator of $P_{s,t}$ is
1040 \begin{cases}
1041 \frac s 2 + \frac t 2 + 1 &
1042 \text{if $\begin{bmatrix}s \\ t \end{bmatrix} \in
1043 \begin{bmatrix}
1044 -1 & -2 \\ 1 & 0
1045 \end{bmatrix}
1046 \ZZ^2 +
1047 \begin{bmatrix}
1048 0 \\ 0
1049 \end{bmatrix}
1052 \frac s 2 + \frac t 2 + \frac 1 2 &
1053 \text{if $\begin{bmatrix}s \\ t \end{bmatrix} \in
1054 \begin{bmatrix}
1055 -1 & -2 \\ 1 & 0
1056 \end{bmatrix}
1057 \ZZ^2 +
1058 \begin{bmatrix}
1059 -1 \\ 0
1060 \end{bmatrix}
1063 \end{cases}
1065 The corresponding output of \ai[\tt]{barvinok\_enumerate} is
1066 \begin{verbatim}
1067 s + t >= 0
1068 1 >= 0
1070 Lattice:
1071 [[-1 1]
1072 [-2 0]
1074 [0 0]
1075 ( 1/2 * s + ( 1/2 * t + 1 )
1077 [-1 0]
1078 ( 1/2 * s + ( 1/2 * t + 1/2 )
1080 \end{verbatim}
1081 \end{example}