6 #include <isl_set_polylib.h>
7 #include <barvinok/barvinok.h>
8 #include <barvinok/evalue.h>
9 #include <barvinok/util.h>
10 #include "param_util.h"
11 #include "reduce_domain.h"
14 #define ALLOC(type) (type*)malloc(sizeof(type))
16 Polyhedron
*unfringe (Polyhedron
*P
, unsigned MaxRays
)
18 int len
= P
->Dimension
+2;
19 Polyhedron
*T
, *R
= P
;
22 Vector
*row
= Vector_Alloc(len
);
23 value_set_si(row
->p
[0], 1);
25 R
= DomainConstraintSimplify(Polyhedron_Copy(P
), MaxRays
);
27 Matrix
*M
= Matrix_Alloc(2, len
-1);
28 value_set_si(M
->p
[1][len
-2], 1);
29 for (int v
= 0; v
< P
->Dimension
; ++v
) {
30 value_set_si(M
->p
[0][v
], 1);
31 Polyhedron
*I
= Polyhedron_Image(R
, M
, 2+1);
32 value_set_si(M
->p
[0][v
], 0);
33 for (int r
= 0; r
< I
->NbConstraints
; ++r
) {
34 if (value_zero_p(I
->Constraint
[r
][0]))
36 if (value_zero_p(I
->Constraint
[r
][1]))
38 if (value_one_p(I
->Constraint
[r
][1]))
40 if (value_mone_p(I
->Constraint
[r
][1]))
42 value_absolute(g
, I
->Constraint
[r
][1]);
43 Vector_Set(row
->p
+1, 0, len
-2);
44 value_division(row
->p
[1+v
], I
->Constraint
[r
][1], g
);
45 mpz_fdiv_q(row
->p
[len
-1], I
->Constraint
[r
][2], g
);
47 R
= AddConstraints(row
->p
, 1, R
, MaxRays
);
59 /* Construct a constraint c from constraints l and u such that if
60 * if constraint c holds then for each value of the other variables
61 * there is at most one value of variable pos (position pos+1 in the constraints).
63 * Given a lower and an upper bound
64 * n_l v_i + <c_l,x> + c_l >= 0
65 * -n_u v_i + <c_u,x> + c_u >= 0
66 * the constructed constraint is
68 * -(n_l<c_u,x> + n_u<c_l,x>) + (-n_l c_u - n_u c_l + n_l n_u - 1)
70 * which is then simplified to remove the content of the non-constant coefficients
72 * len is the total length of the constraints.
73 * v is a temporary variable that can be used by this procedure
75 static void negative_test_constraint(Value
*l
, Value
*u
, Value
*c
, int pos
,
78 value_oppose(*v
, u
[pos
+1]);
79 Vector_Combine(l
+1, u
+1, c
+1, *v
, l
[pos
+1], len
-1);
80 value_multiply(*v
, *v
, l
[pos
+1]);
81 value_subtract(c
[len
-1], c
[len
-1], *v
);
83 Vector_Scale(c
+1, c
+1, *v
, len
-1);
84 value_decrement(c
[len
-1], c
[len
-1]);
85 ConstraintSimplify(c
, c
, len
, v
);
88 static bool parallel_constraints(Value
*l
, Value
*u
, Value
*c
, int pos
,
97 Vector_Gcd(&l
[1+pos
], len
, &g1
);
98 Vector_Gcd(&u
[1+pos
], len
, &g2
);
99 Vector_Combine(l
+1+pos
, u
+1+pos
, c
+1, g2
, g1
, len
);
100 parallel
= First_Non_Zero(c
+1, len
) == -1;
108 static void negative_test_constraint7(Value
*l
, Value
*u
, Value
*c
, int pos
,
109 int exist
, int len
, Value
*v
)
114 Vector_Gcd(&u
[1+pos
], exist
, v
);
115 Vector_Gcd(&l
[1+pos
], exist
, &g
);
116 Vector_Combine(l
+1, u
+1, c
+1, *v
, g
, len
-1);
117 value_multiply(*v
, *v
, g
);
118 value_subtract(c
[len
-1], c
[len
-1], *v
);
119 value_set_si(*v
, -1);
120 Vector_Scale(c
+1, c
+1, *v
, len
-1);
121 value_decrement(c
[len
-1], c
[len
-1]);
122 ConstraintSimplify(c
, c
, len
, v
);
127 /* Turns a x + b >= 0 into a x + b <= -1
129 * len is the total length of the constraint.
130 * v is a temporary variable that can be used by this procedure
132 static void oppose_constraint(Value
*c
, int len
, Value
*v
)
134 value_set_si(*v
, -1);
135 Vector_Scale(c
+1, c
+1, *v
, len
-1);
136 value_decrement(c
[len
-1], c
[len
-1]);
139 /* Split polyhedron P into two polyhedra *pos and *neg, where
140 * existential variable i has at most one solution for each
141 * value of the other variables in *neg.
143 * The splitting is performed using constraints l and u.
145 * nvar: number of set variables
146 * row: temporary vector that can be used by this procedure
147 * f: temporary value that can be used by this procedure
149 static bool SplitOnConstraint(Polyhedron
*P
, int i
, int l
, int u
,
150 int nvar
, int MaxRays
, Vector
*row
, Value
& f
,
151 Polyhedron
**pos
, Polyhedron
**neg
)
153 negative_test_constraint(P
->Constraint
[l
], P
->Constraint
[u
],
154 row
->p
, nvar
+i
, P
->Dimension
+2, &f
);
155 *neg
= AddConstraints(row
->p
, 1, P
, MaxRays
);
156 POL_ENSURE_VERTICES(*neg
);
158 /* We found an independent, but useless constraint
159 * Maybe we should detect this earlier and not
160 * mark the variable as INDEPENDENT
162 if (emptyQ((*neg
))) {
163 Polyhedron_Free(*neg
);
167 oppose_constraint(row
->p
, P
->Dimension
+2, &f
);
168 *pos
= AddConstraints(row
->p
, 1, P
, MaxRays
);
169 POL_ENSURE_VERTICES(*pos
);
171 if (emptyQ((*pos
))) {
172 Polyhedron_Free(*neg
);
173 Polyhedron_Free(*pos
);
181 * unimodularly transform P such that constraint r is transformed
182 * into a constraint that involves only a single (the first)
183 * existential variable
186 static Polyhedron
*rotate_along(Polyhedron
*P
, int r
, int nvar
, int exist
,
192 Matrix
*M
= Matrix_Alloc(exist
, exist
);
193 Vector_Copy(P
->Constraint
[r
]+1+nvar
, M
->p
[0], exist
);
194 Vector_Gcd(M
->p
[0], exist
, &g
);
195 if (value_notone_p(g
))
196 Vector_AntiScale(M
->p
[0], M
->p
[0], g
, exist
);
199 int ok
= unimodular_complete(M
, 1);
201 Matrix
*M2
= Matrix_Alloc(P
->Dimension
+1, P
->Dimension
+1);
202 for (r
= 0; r
< nvar
; ++r
)
203 value_set_si(M2
->p
[r
][r
], 1);
204 for ( ; r
< nvar
+exist
; ++r
)
205 Vector_Copy(M
->p
[r
-nvar
], M2
->p
[r
]+nvar
, exist
);
206 for ( ; r
< P
->Dimension
+1; ++r
)
207 value_set_si(M2
->p
[r
][r
], 1);
208 Polyhedron
*T
= Polyhedron_Image(P
, M2
, MaxRays
);
216 /* Split polyhedron P into two polyhedra *pos and *neg, where
217 * existential variable i has at most one solution for each
218 * value of the other variables in *neg.
220 * If independent is set, then the two constraints on which the
221 * split will be performed need to be independent of the other
222 * existential variables.
224 * Return true if an appropriate split could be performed.
226 * nvar: number of set variables
227 * exist: number of existential variables
228 * row: temporary vector that can be used by this procedure
229 * f: temporary value that can be used by this procedure
231 static bool SplitOnVar(Polyhedron
*P
, int i
,
232 int nvar
, int exist
, int MaxRays
,
233 Vector
*row
, Value
& f
, bool independent
,
234 Polyhedron
**pos
, Polyhedron
**neg
)
238 for (int l
= P
->NbEq
; l
< P
->NbConstraints
; ++l
) {
239 if (value_negz_p(P
->Constraint
[l
][nvar
+i
+1]))
243 for (j
= 0; j
< exist
; ++j
)
244 if (j
!= i
&& value_notzero_p(P
->Constraint
[l
][nvar
+j
+1]))
250 for (int u
= P
->NbEq
; u
< P
->NbConstraints
; ++u
) {
251 if (value_posz_p(P
->Constraint
[u
][nvar
+i
+1]))
255 for (j
= 0; j
< exist
; ++j
)
256 if (j
!= i
&& value_notzero_p(P
->Constraint
[u
][nvar
+j
+1]))
262 if (SplitOnConstraint(P
, i
, l
, u
, nvar
, MaxRays
, row
, f
, pos
, neg
)) {
265 Polyhedron_ExchangeColumns(*neg
, nvar
+1, nvar
+1+i
);
278 INDEPENDENT
= 1 << 2,
282 static evalue
* enumerate_or(Polyhedron
*D
,
283 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
286 fprintf(stderr
, "\nER: Or\n");
287 #endif /* DEBUG_ER */
289 Polyhedron
*N
= D
->next
;
292 barvinok_enumerate_e_with_options(D
, exist
, nparam
, options
);
295 for (D
= N
; D
; D
= N
) {
300 barvinok_enumerate_e_with_options(D
, exist
, nparam
, options
);
312 static evalue
* enumerate_sum(Polyhedron
*P
,
313 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
315 int nvar
= P
->Dimension
- exist
- nparam
;
316 int toswap
= nvar
< exist
? nvar
: exist
;
317 for (int i
= 0; i
< toswap
; ++i
)
318 Polyhedron_ExchangeColumns(P
, 1 + i
, nvar
+exist
- i
);
322 fprintf(stderr
, "\nER: Sum\n");
323 #endif /* DEBUG_ER */
325 evalue
*EP
= barvinok_enumerate_e_with_options(P
, exist
, nparam
, options
);
327 evalue_split_domains_into_orthants(EP
, options
->MaxRays
);
329 evalue_range_reduction(EP
);
331 evalue_frac2floor(EP
);
333 evalue
*sum
= barvinok_summate(EP
, nvar
, options
);
338 evalue_range_reduction(EP
);
343 static evalue
* split_sure(Polyhedron
*P
, Polyhedron
*S
,
344 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
346 int nvar
= P
->Dimension
- exist
- nparam
;
348 Matrix
*M
= Matrix_Alloc(exist
, S
->Dimension
+2);
349 for (int i
= 0; i
< exist
; ++i
)
350 value_set_si(M
->p
[i
][nvar
+i
+1], 1);
352 S
= DomainAddRays(S
, M
, options
->MaxRays
);
354 Polyhedron
*F
= DomainAddRays(P
, M
, options
->MaxRays
);
355 Polyhedron
*D
= DomainDifference(F
, S
, options
->MaxRays
);
357 D
= Disjoint_Domain(D
, 0, options
->MaxRays
);
362 M
= Matrix_Alloc(P
->Dimension
+1-exist
, P
->Dimension
+1);
363 for (int j
= 0; j
< nvar
; ++j
)
364 value_set_si(M
->p
[j
][j
], 1);
365 for (int j
= 0; j
< nparam
+1; ++j
)
366 value_set_si(M
->p
[nvar
+j
][nvar
+exist
+j
], 1);
367 Polyhedron
*T
= Polyhedron_Image(S
, M
, options
->MaxRays
);
368 evalue
*EP
= barvinok_enumerate_e_with_options(T
, 0, nparam
, options
);
373 for (Polyhedron
*Q
= D
; Q
; Q
= Q
->next
) {
374 Polyhedron
*N
= Q
->next
;
376 T
= DomainIntersection(P
, Q
, options
->MaxRays
);
377 evalue
*E
= barvinok_enumerate_e_with_options(T
, exist
, nparam
, options
);
387 static evalue
* enumerate_sure(Polyhedron
*P
,
388 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
392 int nvar
= P
->Dimension
- exist
- nparam
;
398 for (i
= 0; i
< exist
; ++i
) {
399 Matrix
*M
= Matrix_Alloc(S
->NbConstraints
, S
->Dimension
+2);
401 value_set_si(lcm
, 1);
402 for (int j
= 0; j
< S
->NbConstraints
; ++j
) {
403 if (value_negz_p(S
->Constraint
[j
][1+nvar
+i
]))
405 if (value_one_p(S
->Constraint
[j
][1+nvar
+i
]))
407 value_lcm(lcm
, lcm
, S
->Constraint
[j
][1+nvar
+i
]);
410 for (int j
= 0; j
< S
->NbConstraints
; ++j
) {
411 if (value_negz_p(S
->Constraint
[j
][1+nvar
+i
]))
413 if (value_one_p(S
->Constraint
[j
][1+nvar
+i
]))
415 value_division(f
, lcm
, S
->Constraint
[j
][1+nvar
+i
]);
416 Vector_Scale(S
->Constraint
[j
], M
->p
[c
], f
, S
->Dimension
+2);
417 value_subtract(M
->p
[c
][S
->Dimension
+1],
418 M
->p
[c
][S
->Dimension
+1],
420 value_increment(M
->p
[c
][S
->Dimension
+1],
421 M
->p
[c
][S
->Dimension
+1]);
425 S
= AddConstraints(M
->p
[0], c
, S
, options
->MaxRays
);
440 fprintf(stderr
, "\nER: Sure\n");
441 #endif /* DEBUG_ER */
443 return split_sure(P
, S
, exist
, nparam
, options
);
446 static evalue
* enumerate_sure2(Polyhedron
*P
,
447 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
449 int nvar
= P
->Dimension
- exist
- nparam
;
451 for (r
= 0; r
< P
->NbRays
; ++r
)
452 if (value_one_p(P
->Ray
[r
][0]) &&
453 value_one_p(P
->Ray
[r
][P
->Dimension
+1]))
459 Matrix
*M
= Matrix_Alloc(nvar
+ 1 + nparam
, P
->Dimension
+2);
460 for (int i
= 0; i
< nvar
; ++i
)
461 value_set_si(M
->p
[i
][1+i
], 1);
462 for (int i
= 0; i
< nparam
; ++i
)
463 value_set_si(M
->p
[i
+nvar
][1+nvar
+exist
+i
], 1);
464 Vector_Copy(P
->Ray
[r
]+1+nvar
, M
->p
[nvar
+nparam
]+1+nvar
, exist
);
465 value_set_si(M
->p
[nvar
+nparam
][0], 1);
466 value_set_si(M
->p
[nvar
+nparam
][P
->Dimension
+1], 1);
467 Polyhedron
* F
= Rays2Polyhedron(M
, options
->MaxRays
);
470 Polyhedron
*I
= DomainIntersection(F
, P
, options
->MaxRays
);
474 fprintf(stderr
, "\nER: Sure2\n");
475 #endif /* DEBUG_ER */
477 return split_sure(P
, I
, exist
, nparam
, options
);
480 static evalue
* enumerate_cyclic(Polyhedron
*P
,
481 unsigned exist
, unsigned nparam
,
482 evalue
* EP
, int r
, int p
, unsigned MaxRays
)
484 int nvar
= P
->Dimension
- exist
- nparam
;
486 /* If EP in its fractional maps only contains references
487 * to the remainder parameter with appropriate coefficients
488 * then we could in principle avoid adding existentially
489 * quantified variables to the validity domains.
490 * We'd have to replace the remainder by m { p/m }
491 * and multiply with an appropriate factor that is one
492 * only in the appropriate range.
493 * This last multiplication can be avoided if EP
494 * has a single validity domain with no (further)
495 * constraints on the remainder parameter
498 Matrix
*CT
= Matrix_Alloc(nparam
+1, nparam
+3);
499 Matrix
*M
= Matrix_Alloc(1, 1+nparam
+3);
500 for (int j
= 0; j
< nparam
; ++j
)
502 value_set_si(CT
->p
[j
][j
], 1);
503 value_set_si(CT
->p
[p
][nparam
+1], 1);
504 value_set_si(CT
->p
[nparam
][nparam
+2], 1);
505 value_set_si(M
->p
[0][1+p
], -1);
506 value_absolute(M
->p
[0][1+nparam
], P
->Ray
[0][1+nvar
+exist
+p
]);
507 value_set_si(M
->p
[0][1+nparam
+1], 1);
508 Polyhedron
*CEq
= Constraints2Polyhedron(M
, 1);
510 addeliminatedparams_enum(EP
, CT
, CEq
, MaxRays
, nparam
);
511 Polyhedron_Free(CEq
);
517 static void enumerate_vd_add_ray(evalue
*EP
, Matrix
*Rays
, unsigned MaxRays
)
519 if (value_notzero_p(EP
->d
))
522 assert(EP
->x
.p
->type
== partition
);
523 assert(EP
->x
.p
->pos
== EVALUE_DOMAIN(EP
->x
.p
->arr
[0])->Dimension
);
524 for (int i
= 0; i
< EP
->x
.p
->size
/2; ++i
) {
525 Polyhedron
*D
= EVALUE_DOMAIN(EP
->x
.p
->arr
[2*i
]);
526 Polyhedron
*N
= DomainAddRays(D
, Rays
, MaxRays
);
527 EVALUE_SET_DOMAIN(EP
->x
.p
->arr
[2*i
], N
);
532 static evalue
* enumerate_line(Polyhedron
*P
,
533 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
539 fprintf(stderr
, "\nER: Line\n");
540 #endif /* DEBUG_ER */
542 int nvar
= P
->Dimension
- exist
- nparam
;
544 for (i
= 0; i
< nparam
; ++i
)
545 if (value_notzero_p(P
->Ray
[0][1+nvar
+exist
+i
]))
548 for (j
= i
+1; j
< nparam
; ++j
)
549 if (value_notzero_p(P
->Ray
[0][1+nvar
+exist
+j
]))
551 assert(j
>= nparam
); // for now
553 Matrix
*M
= Matrix_Alloc(2, P
->Dimension
+2);
554 value_set_si(M
->p
[0][0], 1);
555 value_set_si(M
->p
[0][1+nvar
+exist
+i
], 1);
556 value_set_si(M
->p
[1][0], 1);
557 value_set_si(M
->p
[1][1+nvar
+exist
+i
], -1);
558 value_absolute(M
->p
[1][1+P
->Dimension
], P
->Ray
[0][1+nvar
+exist
+i
]);
559 value_decrement(M
->p
[1][1+P
->Dimension
], M
->p
[1][1+P
->Dimension
]);
560 Polyhedron
*S
= AddConstraints(M
->p
[0], 2, P
, options
->MaxRays
);
561 evalue
*EP
= barvinok_enumerate_e_with_options(S
, exist
, nparam
, options
);
565 return enumerate_cyclic(P
, exist
, nparam
, EP
, 0, i
, options
->MaxRays
);
568 static int single_param_pos(Polyhedron
*P
, unsigned exist
, unsigned nparam
,
571 int nvar
= P
->Dimension
- exist
- nparam
;
572 if (First_Non_Zero(P
->Ray
[r
]+1, nvar
) != -1)
574 int i
= First_Non_Zero(P
->Ray
[r
]+1+nvar
+exist
, nparam
);
577 if (First_Non_Zero(P
->Ray
[r
]+1+nvar
+exist
+1, nparam
-i
-1) != -1)
582 static evalue
* enumerate_remove_ray(Polyhedron
*P
, int r
,
583 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
586 fprintf(stderr
, "\nER: RedundantRay\n");
587 #endif /* DEBUG_ER */
591 value_set_si(one
, 1);
592 int len
= P
->NbRays
-1;
593 Matrix
*M
= Matrix_Alloc(2 * len
, P
->Dimension
+2);
594 Vector_Copy(P
->Ray
[0], M
->p
[0], r
* (P
->Dimension
+2));
595 Vector_Copy(P
->Ray
[r
+1], M
->p
[r
], (len
-r
) * (P
->Dimension
+2));
596 for (int j
= 0; j
< P
->NbRays
; ++j
) {
599 Vector_Combine(P
->Ray
[j
], P
->Ray
[r
], M
->p
[len
+j
-(j
>r
)],
600 one
, P
->Ray
[j
][P
->Dimension
+1], P
->Dimension
+2);
603 P
= Rays2Polyhedron(M
, options
->MaxRays
);
605 evalue
*EP
= barvinok_enumerate_e_with_options(P
, exist
, nparam
, options
);
612 static evalue
* enumerate_redundant_ray(Polyhedron
*P
,
613 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
615 assert(P
->NbBid
== 0);
616 int nvar
= P
->Dimension
- exist
- nparam
;
620 for (int r
= 0; r
< P
->NbRays
; ++r
) {
621 if (value_notzero_p(P
->Ray
[r
][P
->Dimension
+1]))
623 int i1
= single_param_pos(P
, exist
, nparam
, r
);
626 for (int r2
= r
+1; r2
< P
->NbRays
; ++r2
) {
627 if (value_notzero_p(P
->Ray
[r2
][P
->Dimension
+1]))
629 int i2
= single_param_pos(P
, exist
, nparam
, r2
);
635 value_division(m
, P
->Ray
[r
][1+nvar
+exist
+i1
],
636 P
->Ray
[r2
][1+nvar
+exist
+i1
]);
637 value_multiply(m
, m
, P
->Ray
[r2
][1+nvar
+exist
+i1
]);
638 /* r2 divides r => r redundant */
639 if (value_eq(m
, P
->Ray
[r
][1+nvar
+exist
+i1
])) {
641 return enumerate_remove_ray(P
, r
, exist
, nparam
, options
);
644 value_division(m
, P
->Ray
[r2
][1+nvar
+exist
+i1
],
645 P
->Ray
[r
][1+nvar
+exist
+i1
]);
646 value_multiply(m
, m
, P
->Ray
[r
][1+nvar
+exist
+i1
]);
647 /* r divides r2 => r2 redundant */
648 if (value_eq(m
, P
->Ray
[r2
][1+nvar
+exist
+i1
])) {
650 return enumerate_remove_ray(P
, r2
, exist
, nparam
, options
);
658 static Polyhedron
*upper_bound(Polyhedron
*P
,
659 int pos
, Value
*max
, Polyhedron
**R
)
668 for (Polyhedron
*Q
= P
; Q
; Q
= N
) {
670 for (r
= 0; r
< P
->NbRays
; ++r
) {
671 if (value_zero_p(P
->Ray
[r
][P
->Dimension
+1]) &&
672 value_pos_p(P
->Ray
[r
][1+pos
]))
683 for (r
= 0; r
< P
->NbRays
; ++r
) {
684 if (value_zero_p(P
->Ray
[r
][P
->Dimension
+1]))
686 mpz_fdiv_q(v
, P
->Ray
[r
][1+pos
], P
->Ray
[r
][1+P
->Dimension
]);
687 if ((!Q
->next
&& r
== 0) || value_gt(v
, *max
))
688 value_assign(*max
, v
);
695 static evalue
* enumerate_ray(Polyhedron
*P
,
696 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
698 assert(P
->NbBid
== 0);
699 int nvar
= P
->Dimension
- exist
- nparam
;
702 for (r
= 0; r
< P
->NbRays
; ++r
)
703 if (value_zero_p(P
->Ray
[r
][P
->Dimension
+1]))
709 for (r2
= r
+1; r2
< P
->NbRays
; ++r2
)
710 if (value_zero_p(P
->Ray
[r2
][P
->Dimension
+1]))
712 if (r2
< P
->NbRays
) {
714 return enumerate_sum(P
, exist
, nparam
, options
);
718 fprintf(stderr
, "\nER: Ray\n");
719 #endif /* DEBUG_ER */
725 value_set_si(one
, 1);
726 int i
= single_param_pos(P
, exist
, nparam
, r
);
727 assert(i
!= -1); // for now;
729 Matrix
*M
= Matrix_Alloc(P
->NbRays
, P
->Dimension
+2);
730 for (int j
= 0; j
< P
->NbRays
; ++j
) {
731 Vector_Combine(P
->Ray
[j
], P
->Ray
[r
], M
->p
[j
],
732 one
, P
->Ray
[j
][P
->Dimension
+1], P
->Dimension
+2);
734 Polyhedron
*S
= Rays2Polyhedron(M
, options
->MaxRays
);
736 Polyhedron
*D
= DomainDifference(P
, S
, options
->MaxRays
);
738 // Polyhedron_Print(stderr, P_VALUE_FMT, D);
739 assert(value_pos_p(P
->Ray
[r
][1+nvar
+exist
+i
])); // for now
741 D
= upper_bound(D
, nvar
+exist
+i
, &m
, &R
);
745 M
= Matrix_Alloc(2, P
->Dimension
+2);
746 value_set_si(M
->p
[0][0], 1);
747 value_set_si(M
->p
[1][0], 1);
748 value_set_si(M
->p
[0][1+nvar
+exist
+i
], -1);
749 value_set_si(M
->p
[1][1+nvar
+exist
+i
], 1);
750 value_assign(M
->p
[0][1+P
->Dimension
], m
);
751 value_oppose(M
->p
[1][1+P
->Dimension
], m
);
752 value_addto(M
->p
[1][1+P
->Dimension
], M
->p
[1][1+P
->Dimension
],
753 P
->Ray
[r
][1+nvar
+exist
+i
]);
754 value_decrement(M
->p
[1][1+P
->Dimension
], M
->p
[1][1+P
->Dimension
]);
755 // Matrix_Print(stderr, P_VALUE_FMT, M);
756 D
= AddConstraints(M
->p
[0], 2, P
, options
->MaxRays
);
757 // Polyhedron_Print(stderr, P_VALUE_FMT, D);
758 value_subtract(M
->p
[0][1+P
->Dimension
], M
->p
[0][1+P
->Dimension
],
759 P
->Ray
[r
][1+nvar
+exist
+i
]);
760 // Matrix_Print(stderr, P_VALUE_FMT, M);
761 S
= AddConstraints(M
->p
[0], 1, P
, options
->MaxRays
);
762 // Polyhedron_Print(stderr, P_VALUE_FMT, S);
765 evalue
*EP
= barvinok_enumerate_e_with_options(D
, exist
, nparam
, options
);
770 if (value_notone_p(P
->Ray
[r
][1+nvar
+exist
+i
]))
771 EP
= enumerate_cyclic(P
, exist
, nparam
, EP
, r
, i
, options
->MaxRays
);
773 M
= Matrix_Alloc(1, nparam
+2);
774 value_set_si(M
->p
[0][0], 1);
775 value_set_si(M
->p
[0][1+i
], 1);
776 enumerate_vd_add_ray(EP
, M
, options
->MaxRays
);
781 evalue
*E
= barvinok_enumerate_e_with_options(S
, exist
, nparam
, options
);
789 evalue
*ER
= enumerate_or(R
, exist
, nparam
, options
);
791 free_evalue_refs(ER
);
798 static evalue
* enumerate_vd(Polyhedron
**PA
,
799 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
802 int nvar
= P
->Dimension
- exist
- nparam
;
803 Param_Polyhedron
*PP
= NULL
;
804 Polyhedron
*C
= Universe_Polyhedron(nparam
);
806 PP
= Polyhedron2Param_Polyhedron(PR
, C
, options
);
810 Param_Domain
*D
, *last
;
813 for (nd
= 0, D
=PP
->D
; D
; D
=D
->next
, ++nd
)
816 Polyhedron
**VD
= new Polyhedron
*[nd
];
817 Polyhedron
*TC
= true_context(P
, C
, options
->MaxRays
);
818 FORALL_REDUCED_DOMAIN(PP
, TC
, nd
, options
, i
, D
, rVD
)
821 END_FORALL_REDUCED_DOMAIN
829 /* This doesn't seem to have any effect */
831 Polyhedron
*CA
= align_context(VD
[0], P
->Dimension
, options
->MaxRays
);
833 P
= DomainIntersection(P
, CA
, options
->MaxRays
);
847 fprintf(stderr
, "\nER: VD\n");
848 #endif /* DEBUG_ER */
849 for (int i
= 0; i
< nd
; ++i
) {
850 Polyhedron
*CA
= align_context(VD
[i
], P
->Dimension
, options
->MaxRays
);
851 Polyhedron
*I
= DomainIntersection(P
, CA
, options
->MaxRays
);
854 EP
= barvinok_enumerate_e_with_options(I
, exist
, nparam
, options
);
856 evalue
*E
= barvinok_enumerate_e_with_options(I
, exist
, nparam
,
866 for (int i
= 0; i
< nd
; ++i
)
867 Polyhedron_Free(VD
[i
]);
871 if (!EP
&& nvar
== 0) {
874 Param_Vertices
*V
, *V2
;
875 Matrix
* M
= Matrix_Alloc(1, P
->Dimension
+2);
877 FORALL_PVertex_in_ParamPolyhedron(V
, last
, PP
) {
879 FORALL_PVertex_in_ParamPolyhedron(V2
, last
, PP
) {
886 for (int i
= 0; i
< exist
; ++i
) {
887 value_oppose(f
, V
->Vertex
->p
[i
][nparam
+1]);
888 Vector_Combine(V
->Vertex
->p
[i
],
890 M
->p
[0] + 1 + nvar
+ exist
,
891 V2
->Vertex
->p
[i
][nparam
+1],
895 for (j
= 0; j
< nparam
; ++j
)
896 if (value_notzero_p(M
->p
[0][1+nvar
+exist
+j
]))
900 ConstraintSimplify(M
->p
[0], M
->p
[0],
902 value_set_si(M
->p
[0][0], 0);
903 Polyhedron
*para
= AddConstraints(M
->p
[0], 1, P
,
905 POL_ENSURE_VERTICES(para
);
907 Polyhedron_Free(para
);
910 Polyhedron
*pos
, *neg
;
911 value_set_si(M
->p
[0][0], 1);
912 value_decrement(M
->p
[0][P
->Dimension
+1],
913 M
->p
[0][P
->Dimension
+1]);
914 neg
= AddConstraints(M
->p
[0], 1, P
, options
->MaxRays
);
916 Vector_Scale(M
->p
[0]+1, M
->p
[0]+1, f
,
918 value_decrement(M
->p
[0][P
->Dimension
+1],
919 M
->p
[0][P
->Dimension
+1]);
920 value_decrement(M
->p
[0][P
->Dimension
+1],
921 M
->p
[0][P
->Dimension
+1]);
922 pos
= AddConstraints(M
->p
[0], 1, P
, options
->MaxRays
);
923 POL_ENSURE_VERTICES(neg
);
924 POL_ENSURE_VERTICES(pos
);
925 if (emptyQ(neg
) && emptyQ(pos
)) {
926 Polyhedron_Free(para
);
927 Polyhedron_Free(pos
);
928 Polyhedron_Free(neg
);
932 fprintf(stderr
, "\nER: Order\n");
933 #endif /* DEBUG_ER */
934 EP
= barvinok_enumerate_e_with_options(para
, exist
, nparam
,
938 E
= barvinok_enumerate_e_with_options(pos
, exist
, nparam
,
944 E
= barvinok_enumerate_e_with_options(neg
, exist
, nparam
,
949 Polyhedron_Free(para
);
950 Polyhedron_Free(pos
);
951 Polyhedron_Free(neg
);
956 } END_FORALL_PVertex_in_ParamPolyhedron
;
959 } END_FORALL_PVertex_in_ParamPolyhedron
;
962 /* Search for vertex coordinate to split on */
963 /* First look for one independent of the parameters */
964 FORALL_PVertex_in_ParamPolyhedron(V
, last
, PP
) {
965 for (int i
= 0; i
< exist
; ++i
) {
967 for (j
= 0; j
< nparam
; ++j
)
968 if (value_notzero_p(V
->Vertex
->p
[i
][j
]))
972 value_set_si(M
->p
[0][0], 1);
973 Vector_Set(M
->p
[0]+1, 0, nvar
+exist
);
974 Vector_Copy(V
->Vertex
->p
[i
],
975 M
->p
[0] + 1 + nvar
+ exist
, nparam
+1);
976 value_oppose(M
->p
[0][1+nvar
+i
],
977 V
->Vertex
->p
[i
][nparam
+1]);
979 Polyhedron
*pos
, *neg
;
980 value_set_si(M
->p
[0][0], 1);
981 value_decrement(M
->p
[0][P
->Dimension
+1],
982 M
->p
[0][P
->Dimension
+1]);
983 neg
= AddConstraints(M
->p
[0], 1, P
, options
->MaxRays
);
985 Vector_Scale(M
->p
[0]+1, M
->p
[0]+1, f
,
987 value_decrement(M
->p
[0][P
->Dimension
+1],
988 M
->p
[0][P
->Dimension
+1]);
989 value_decrement(M
->p
[0][P
->Dimension
+1],
990 M
->p
[0][P
->Dimension
+1]);
991 pos
= AddConstraints(M
->p
[0], 1, P
, options
->MaxRays
);
992 POL_ENSURE_VERTICES(neg
);
993 POL_ENSURE_VERTICES(pos
);
994 if (emptyQ(neg
) || emptyQ(pos
)) {
995 Polyhedron_Free(pos
);
996 Polyhedron_Free(neg
);
999 Polyhedron_Free(pos
);
1000 value_increment(M
->p
[0][P
->Dimension
+1],
1001 M
->p
[0][P
->Dimension
+1]);
1002 pos
= AddConstraints(M
->p
[0], 1, P
, options
->MaxRays
);
1004 fprintf(stderr
, "\nER: Vertex\n");
1005 #endif /* DEBUG_ER */
1007 EP
= enumerate_or(pos
, exist
, nparam
, options
);
1012 } END_FORALL_PVertex_in_ParamPolyhedron
;
1016 /* Search for vertex coordinate to split on */
1017 /* Now look for one that depends on the parameters */
1018 FORALL_PVertex_in_ParamPolyhedron(V
, last
, PP
) {
1019 for (int i
= 0; i
< exist
; ++i
) {
1020 value_set_si(M
->p
[0][0], 1);
1021 Vector_Set(M
->p
[0]+1, 0, nvar
+exist
);
1022 Vector_Copy(V
->Vertex
->p
[i
],
1023 M
->p
[0] + 1 + nvar
+ exist
, nparam
+1);
1024 value_oppose(M
->p
[0][1+nvar
+i
],
1025 V
->Vertex
->p
[i
][nparam
+1]);
1027 Polyhedron
*pos
, *neg
;
1028 value_set_si(M
->p
[0][0], 1);
1029 value_decrement(M
->p
[0][P
->Dimension
+1],
1030 M
->p
[0][P
->Dimension
+1]);
1031 neg
= AddConstraints(M
->p
[0], 1, P
, options
->MaxRays
);
1032 value_set_si(f
, -1);
1033 Vector_Scale(M
->p
[0]+1, M
->p
[0]+1, f
,
1035 value_decrement(M
->p
[0][P
->Dimension
+1],
1036 M
->p
[0][P
->Dimension
+1]);
1037 value_decrement(M
->p
[0][P
->Dimension
+1],
1038 M
->p
[0][P
->Dimension
+1]);
1039 pos
= AddConstraints(M
->p
[0], 1, P
, options
->MaxRays
);
1040 POL_ENSURE_VERTICES(neg
);
1041 POL_ENSURE_VERTICES(pos
);
1042 if (emptyQ(neg
) || emptyQ(pos
)) {
1043 Polyhedron_Free(pos
);
1044 Polyhedron_Free(neg
);
1047 Polyhedron_Free(pos
);
1048 value_increment(M
->p
[0][P
->Dimension
+1],
1049 M
->p
[0][P
->Dimension
+1]);
1050 pos
= AddConstraints(M
->p
[0], 1, P
, options
->MaxRays
);
1052 fprintf(stderr
, "\nER: ParamVertex\n");
1053 #endif /* DEBUG_ER */
1055 EP
= enumerate_or(pos
, exist
, nparam
, options
);
1060 } END_FORALL_PVertex_in_ParamPolyhedron
;
1068 Param_Polyhedron_Free(PP
);
1074 evalue
*barvinok_enumerate_isl(Polyhedron
*P
,
1075 unsigned exist
, unsigned nparam
, struct barvinok_options
*options
)
1077 isl_ctx
*ctx
= isl_ctx_alloc();
1079 isl_basic_set
*bset
;
1081 evalue
*EP
= evalue_zero();
1082 Polyhedron
*D
, *Q
, *N
;
1083 Polyhedron
*U
= Universe_Polyhedron(nparam
);
1085 dims
= isl_space_set_alloc(ctx
, nparam
, P
->Dimension
- nparam
- exist
);
1086 bset
= isl_basic_set_new_from_polylib(P
, dims
);
1088 set
= isl_basic_set_compute_divs(bset
);
1090 D
= isl_set_to_polylib(set
);
1091 for (Q
= D
; Q
; Q
= N
) {
1095 E
= barvinok_enumerate_with_options(Q
, U
, options
);
1108 static bool is_single(Value
*row
, int pos
, int len
)
1110 return First_Non_Zero(row
, pos
) == -1 &&
1111 First_Non_Zero(row
+pos
+1, len
-pos
-1) == -1;
1114 static evalue
* barvinok_enumerate_e_r(Polyhedron
*P
,
1115 unsigned exist
, unsigned nparam
, barvinok_options
*options
);
1118 static int er_level
= 0;
1120 evalue
* barvinok_enumerate_e_with_options(Polyhedron
*P
,
1121 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
1123 fprintf(stderr
, "\nER: level %i\n", er_level
);
1125 Polyhedron_PrintConstraints(stderr
, P_VALUE_FMT
, P
);
1126 fprintf(stderr
, "\nE %d\nP %d\n", exist
, nparam
);
1128 P
= DomainConstraintSimplify(Polyhedron_Copy(P
), options
->MaxRays
);
1129 evalue
*EP
= barvinok_enumerate_e_r(P
, exist
, nparam
, options
);
1135 evalue
* barvinok_enumerate_e_with_options(Polyhedron
*P
,
1136 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
1138 P
= DomainConstraintSimplify(Polyhedron_Copy(P
), options
->MaxRays
);
1139 evalue
*EP
= barvinok_enumerate_e_r(P
, exist
, nparam
, options
);
1145 evalue
* barvinok_enumerate_e(Polyhedron
*P
, unsigned exist
, unsigned nparam
,
1149 barvinok_options
*options
= barvinok_options_new_with_defaults();
1150 options
->MaxRays
= MaxRays
;
1151 E
= barvinok_enumerate_e_with_options(P
, exist
, nparam
, options
);
1152 barvinok_options_free(options
);
1156 static evalue
*universal_zero(unsigned nparam
)
1160 eres
= ALLOC(evalue
);
1161 value_init(eres
->d
);
1162 value_set_si(eres
->d
, 0);
1163 eres
->x
.p
= new_enode(partition
, 2, nparam
);
1164 EVALUE_SET_DOMAIN(eres
->x
.p
->arr
[0], Universe_Polyhedron(nparam
));
1165 value_set_si(eres
->x
.p
->arr
[1].d
, 1);
1166 value_init(eres
->x
.p
->arr
[1].x
.n
);
1171 static evalue
* barvinok_enumerate_e_r(Polyhedron
*P
,
1172 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
1175 Polyhedron
*U
= Universe_Polyhedron(nparam
);
1176 evalue
*EP
= barvinok_enumerate_with_options(P
, U
, options
);
1177 //char *param_name[] = {"P", "Q", "R", "S", "T" };
1178 //print_evalue(stdout, EP, param_name);
1183 int nvar
= P
->Dimension
- exist
- nparam
;
1184 int len
= P
->Dimension
+ 2;
1187 POL_ENSURE_FACETS(P
);
1188 POL_ENSURE_VERTICES(P
);
1191 return evalue_zero();
1193 if (nvar
== 0 && nparam
== 0) {
1194 evalue
*EP
= universal_zero(nparam
);
1195 barvinok_count_with_options(P
, &EP
->x
.p
->arr
[1].x
.n
, options
);
1196 if (value_pos_p(EP
->x
.p
->arr
[1].x
.n
))
1197 value_set_si(EP
->x
.p
->arr
[1].x
.n
, 1);
1202 for (r
= 0; r
< P
->NbRays
; ++r
)
1203 if (value_zero_p(P
->Ray
[r
][0]) ||
1204 value_zero_p(P
->Ray
[r
][P
->Dimension
+1])) {
1206 for (i
= 0; i
< nvar
; ++i
)
1207 if (value_notzero_p(P
->Ray
[r
][i
+1]))
1211 for (i
= nvar
+ exist
; i
< nvar
+ exist
+ nparam
; ++i
)
1212 if (value_notzero_p(P
->Ray
[r
][i
+1]))
1214 if (i
>= nvar
+ exist
+ nparam
)
1217 if (r
< P
->NbRays
) {
1218 evalue
*EP
= universal_zero(nparam
);
1219 value_set_si(EP
->x
.p
->arr
[1].x
.n
, -1);
1224 for (r
= 0; r
< P
->NbEq
; ++r
)
1225 if ((first
= First_Non_Zero(P
->Constraint
[r
]+1+nvar
, exist
)) != -1)
1228 if (First_Non_Zero(P
->Constraint
[r
]+1+nvar
+first
+1,
1229 exist
-first
-1) != -1) {
1230 Polyhedron
*T
= rotate_along(P
, r
, nvar
, exist
, options
->MaxRays
);
1232 fprintf(stderr
, "\nER: Equality\n");
1233 #endif /* DEBUG_ER */
1234 evalue
*EP
= barvinok_enumerate_e_with_options(T
, exist
-1, nparam
,
1240 fprintf(stderr
, "\nER: Fixed\n");
1241 #endif /* DEBUG_ER */
1243 return barvinok_enumerate_e_with_options(P
, exist
-1, nparam
,
1246 Polyhedron
*T
= Polyhedron_Copy(P
);
1247 Polyhedron_ExchangeColumns(T
, nvar
+1, nvar
+1+first
);
1248 evalue
*EP
= barvinok_enumerate_e_with_options(T
, exist
-1, nparam
,
1256 Vector
*row
= Vector_Alloc(len
);
1257 value_set_si(row
->p
[0], 1);
1262 enum constraint
* info
= new constraint
[exist
];
1263 for (int i
= 0; i
< exist
; ++i
) {
1265 for (int l
= P
->NbEq
; l
< P
->NbConstraints
; ++l
) {
1266 if (value_negz_p(P
->Constraint
[l
][nvar
+i
+1]))
1268 bool l_parallel
= is_single(P
->Constraint
[l
]+nvar
+1, i
, exist
);
1269 for (int u
= P
->NbEq
; u
< P
->NbConstraints
; ++u
) {
1270 if (value_posz_p(P
->Constraint
[u
][nvar
+i
+1]))
1272 bool lu_parallel
= l_parallel
||
1273 is_single(P
->Constraint
[u
]+nvar
+1, i
, exist
);
1274 value_oppose(f
, P
->Constraint
[u
][nvar
+i
+1]);
1275 Vector_Combine(P
->Constraint
[l
]+1, P
->Constraint
[u
]+1, row
->p
+1,
1276 f
, P
->Constraint
[l
][nvar
+i
+1], len
-1);
1277 if (!(info
[i
] & INDEPENDENT
)) {
1279 for (j
= 0; j
< exist
; ++j
)
1280 if (j
!= i
&& value_notzero_p(row
->p
[nvar
+j
+1]))
1283 //printf("independent: i: %d, l: %d, u: %d\n", i, l, u);
1284 info
[i
] = (constraint
)(info
[i
] | INDEPENDENT
);
1287 if (info
[i
] & ALL_POS
) {
1288 value_addto(row
->p
[len
-1], row
->p
[len
-1],
1289 P
->Constraint
[l
][nvar
+i
+1]);
1290 value_addto(row
->p
[len
-1], row
->p
[len
-1], f
);
1291 value_multiply(f
, f
, P
->Constraint
[l
][nvar
+i
+1]);
1292 value_subtract(row
->p
[len
-1], row
->p
[len
-1], f
);
1293 value_decrement(row
->p
[len
-1], row
->p
[len
-1]);
1294 ConstraintSimplify(row
->p
, row
->p
, len
, &f
);
1295 value_set_si(f
, -1);
1296 Vector_Scale(row
->p
+1, row
->p
+1, f
, len
-1);
1297 value_decrement(row
->p
[len
-1], row
->p
[len
-1]);
1298 Polyhedron
*T
= AddConstraints(row
->p
, 1, P
, options
->MaxRays
);
1299 POL_ENSURE_VERTICES(T
);
1301 //printf("not all_pos: i: %d, l: %d, u: %d\n", i, l, u);
1302 info
[i
] = (constraint
)(info
[i
] ^ ALL_POS
);
1304 //puts("pos remainder");
1305 //Polyhedron_Print(stdout, P_VALUE_FMT, T);
1308 if (!(info
[i
] & ONE_NEG
)) {
1310 negative_test_constraint(P
->Constraint
[l
],
1312 row
->p
, nvar
+i
, len
, &f
);
1313 oppose_constraint(row
->p
, len
, &f
);
1314 Polyhedron
*T
= AddConstraints(row
->p
, 1, P
,
1316 POL_ENSURE_VERTICES(T
);
1318 //printf("one_neg i: %d, l: %d, u: %d\n", i, l, u);
1319 info
[i
] = (constraint
)(info
[i
] | ONE_NEG
);
1321 //puts("neg remainder");
1322 //Polyhedron_Print(stdout, P_VALUE_FMT, T);
1324 } else if (!(info
[i
] & ROT_NEG
)) {
1325 if (parallel_constraints(P
->Constraint
[l
],
1327 row
->p
, nvar
, exist
)) {
1328 negative_test_constraint7(P
->Constraint
[l
],
1330 row
->p
, nvar
, exist
,
1332 oppose_constraint(row
->p
, len
, &f
);
1333 Polyhedron
*T
= AddConstraints(row
->p
, 1, P
,
1335 POL_ENSURE_VERTICES(T
);
1337 // printf("rot_neg i: %d, l: %d, u: %d\n", i, l, u);
1338 info
[i
] = (constraint
)(info
[i
] | ROT_NEG
);
1341 //puts("neg remainder");
1342 //Polyhedron_Print(stdout, P_VALUE_FMT, T);
1347 if (!(info
[i
] & ALL_POS
) && (info
[i
] & (ONE_NEG
| ROT_NEG
)))
1351 if (info
[i
] & ALL_POS
)
1358 for (int i = 0; i < exist; ++i)
1359 printf("%i: %i\n", i, info[i]);
1361 for (int i
= 0; i
< exist
; ++i
)
1362 if (info
[i
] & ALL_POS
) {
1364 fprintf(stderr
, "\nER: Positive\n");
1365 #endif /* DEBUG_ER */
1367 // Maybe we should chew off some of the fat here
1368 Matrix
*M
= Matrix_Alloc(P
->Dimension
, P
->Dimension
+1);
1369 for (int j
= 0; j
< P
->Dimension
; ++j
)
1370 value_set_si(M
->p
[j
][j
+ (j
>= i
+nvar
)], 1);
1371 Polyhedron
*T
= Polyhedron_Image(P
, M
, options
->MaxRays
);
1373 evalue
*EP
= barvinok_enumerate_e_with_options(T
, exist
-1, nparam
,
1381 for (int i
= 0; i
< exist
; ++i
)
1382 if (info
[i
] & ONE_NEG
) {
1384 fprintf(stderr
, "\nER: Negative\n");
1385 #endif /* DEBUG_ER */
1390 return barvinok_enumerate_e_with_options(P
, exist
-1, nparam
,
1393 Polyhedron
*T
= Polyhedron_Copy(P
);
1394 Polyhedron_ExchangeColumns(T
, nvar
+1, nvar
+1+i
);
1395 evalue
*EP
= barvinok_enumerate_e_with_options(T
, exist
-1, nparam
,
1401 for (int i
= 0; i
< exist
; ++i
)
1402 if (info
[i
] & ROT_NEG
) {
1404 fprintf(stderr
, "\nER: Rotate\n");
1405 #endif /* DEBUG_ER */
1409 Polyhedron
*T
= rotate_along(P
, r
, nvar
, exist
, options
->MaxRays
);
1410 evalue
*EP
= barvinok_enumerate_e_with_options(T
, exist
-1, nparam
,
1415 for (int i
= 0; i
< exist
; ++i
)
1416 if (info
[i
] & INDEPENDENT
) {
1417 Polyhedron
*pos
, *neg
;
1419 /* Find constraint again and split off negative part */
1421 if (SplitOnVar(P
, i
, nvar
, exist
, options
->MaxRays
,
1422 row
, f
, true, &pos
, &neg
)) {
1424 fprintf(stderr
, "\nER: Split\n");
1425 #endif /* DEBUG_ER */
1428 barvinok_enumerate_e_with_options(neg
, exist
-1, nparam
, options
);
1430 barvinok_enumerate_e_with_options(pos
, exist
, nparam
, options
);
1433 Polyhedron_Free(neg
);
1434 Polyhedron_Free(pos
);
1448 EP
= enumerate_line(P
, exist
, nparam
, options
);
1452 EP
= barvinok_enumerate_isl(P
, exist
, nparam
, options
);
1456 EP
= enumerate_redundant_ray(P
, exist
, nparam
, options
);
1460 EP
= enumerate_sure(P
, exist
, nparam
, options
);
1464 EP
= enumerate_ray(P
, exist
, nparam
, options
);
1468 EP
= enumerate_sure2(P
, exist
, nparam
, options
);
1472 F
= unfringe(P
, options
->MaxRays
);
1473 if (!PolyhedronIncludes(F
, P
)) {
1475 fprintf(stderr
, "\nER: Fringed\n");
1476 #endif /* DEBUG_ER */
1477 EP
= barvinok_enumerate_e_with_options(F
, exist
, nparam
, options
);
1484 EP
= enumerate_vd(&P
, exist
, nparam
, options
);
1489 EP
= enumerate_sum(P
, exist
, nparam
, options
);
1496 Polyhedron
*pos
, *neg
;
1497 for (i
= 0; i
< exist
; ++i
)
1498 if (SplitOnVar(P
, i
, nvar
, exist
, options
->MaxRays
,
1499 row
, f
, false, &pos
, &neg
))
1505 EP
= enumerate_or(pos
, exist
, nparam
, options
);