3 #include <isl_set_polylib.h>
4 #include <barvinok/barvinok.h>
5 #include <barvinok/evalue.h>
6 #include <barvinok/util.h>
7 #include "param_util.h"
8 #include "reduce_domain.h"
11 #define ALLOC(type) (type*)malloc(sizeof(type))
13 Polyhedron
*unfringe (Polyhedron
*P
, unsigned MaxRays
)
15 int len
= P
->Dimension
+2;
16 Polyhedron
*T
, *R
= P
;
19 Vector
*row
= Vector_Alloc(len
);
20 value_set_si(row
->p
[0], 1);
22 R
= DomainConstraintSimplify(Polyhedron_Copy(P
), MaxRays
);
24 Matrix
*M
= Matrix_Alloc(2, len
-1);
25 value_set_si(M
->p
[1][len
-2], 1);
26 for (int v
= 0; v
< P
->Dimension
; ++v
) {
27 value_set_si(M
->p
[0][v
], 1);
28 Polyhedron
*I
= Polyhedron_Image(R
, M
, 2+1);
29 value_set_si(M
->p
[0][v
], 0);
30 for (int r
= 0; r
< I
->NbConstraints
; ++r
) {
31 if (value_zero_p(I
->Constraint
[r
][0]))
33 if (value_zero_p(I
->Constraint
[r
][1]))
35 if (value_one_p(I
->Constraint
[r
][1]))
37 if (value_mone_p(I
->Constraint
[r
][1]))
39 value_absolute(g
, I
->Constraint
[r
][1]);
40 Vector_Set(row
->p
+1, 0, len
-2);
41 value_division(row
->p
[1+v
], I
->Constraint
[r
][1], g
);
42 mpz_fdiv_q(row
->p
[len
-1], I
->Constraint
[r
][2], g
);
44 R
= AddConstraints(row
->p
, 1, R
, MaxRays
);
56 /* Construct a constraint c from constraints l and u such that if
57 * if constraint c holds then for each value of the other variables
58 * there is at most one value of variable pos (position pos+1 in the constraints).
60 * Given a lower and an upper bound
61 * n_l v_i + <c_l,x> + c_l >= 0
62 * -n_u v_i + <c_u,x> + c_u >= 0
63 * the constructed constraint is
65 * -(n_l<c_u,x> + n_u<c_l,x>) + (-n_l c_u - n_u c_l + n_l n_u - 1)
67 * which is then simplified to remove the content of the non-constant coefficients
69 * len is the total length of the constraints.
70 * v is a temporary variable that can be used by this procedure
72 static void negative_test_constraint(Value
*l
, Value
*u
, Value
*c
, int pos
,
75 value_oppose(*v
, u
[pos
+1]);
76 Vector_Combine(l
+1, u
+1, c
+1, *v
, l
[pos
+1], len
-1);
77 value_multiply(*v
, *v
, l
[pos
+1]);
78 value_subtract(c
[len
-1], c
[len
-1], *v
);
80 Vector_Scale(c
+1, c
+1, *v
, len
-1);
81 value_decrement(c
[len
-1], c
[len
-1]);
82 ConstraintSimplify(c
, c
, len
, v
);
85 static bool parallel_constraints(Value
*l
, Value
*u
, Value
*c
, int pos
,
94 Vector_Gcd(&l
[1+pos
], len
, &g1
);
95 Vector_Gcd(&u
[1+pos
], len
, &g2
);
96 Vector_Combine(l
+1+pos
, u
+1+pos
, c
+1, g2
, g1
, len
);
97 parallel
= First_Non_Zero(c
+1, len
) == -1;
105 static void negative_test_constraint7(Value
*l
, Value
*u
, Value
*c
, int pos
,
106 int exist
, int len
, Value
*v
)
111 Vector_Gcd(&u
[1+pos
], exist
, v
);
112 Vector_Gcd(&l
[1+pos
], exist
, &g
);
113 Vector_Combine(l
+1, u
+1, c
+1, *v
, g
, len
-1);
114 value_multiply(*v
, *v
, g
);
115 value_subtract(c
[len
-1], c
[len
-1], *v
);
116 value_set_si(*v
, -1);
117 Vector_Scale(c
+1, c
+1, *v
, len
-1);
118 value_decrement(c
[len
-1], c
[len
-1]);
119 ConstraintSimplify(c
, c
, len
, v
);
124 /* Turns a x + b >= 0 into a x + b <= -1
126 * len is the total length of the constraint.
127 * v is a temporary variable that can be used by this procedure
129 static void oppose_constraint(Value
*c
, int len
, Value
*v
)
131 value_set_si(*v
, -1);
132 Vector_Scale(c
+1, c
+1, *v
, len
-1);
133 value_decrement(c
[len
-1], c
[len
-1]);
136 /* Split polyhedron P into two polyhedra *pos and *neg, where
137 * existential variable i has at most one solution for each
138 * value of the other variables in *neg.
140 * The splitting is performed using constraints l and u.
142 * nvar: number of set variables
143 * row: temporary vector that can be used by this procedure
144 * f: temporary value that can be used by this procedure
146 static bool SplitOnConstraint(Polyhedron
*P
, int i
, int l
, int u
,
147 int nvar
, int MaxRays
, Vector
*row
, Value
& f
,
148 Polyhedron
**pos
, Polyhedron
**neg
)
150 negative_test_constraint(P
->Constraint
[l
], P
->Constraint
[u
],
151 row
->p
, nvar
+i
, P
->Dimension
+2, &f
);
152 *neg
= AddConstraints(row
->p
, 1, P
, MaxRays
);
153 POL_ENSURE_VERTICES(*neg
);
155 /* We found an independent, but useless constraint
156 * Maybe we should detect this earlier and not
157 * mark the variable as INDEPENDENT
159 if (emptyQ((*neg
))) {
160 Polyhedron_Free(*neg
);
164 oppose_constraint(row
->p
, P
->Dimension
+2, &f
);
165 *pos
= AddConstraints(row
->p
, 1, P
, MaxRays
);
166 POL_ENSURE_VERTICES(*pos
);
168 if (emptyQ((*pos
))) {
169 Polyhedron_Free(*neg
);
170 Polyhedron_Free(*pos
);
178 * unimodularly transform P such that constraint r is transformed
179 * into a constraint that involves only a single (the first)
180 * existential variable
183 static Polyhedron
*rotate_along(Polyhedron
*P
, int r
, int nvar
, int exist
,
189 Matrix
*M
= Matrix_Alloc(exist
, exist
);
190 Vector_Copy(P
->Constraint
[r
]+1+nvar
, M
->p
[0], exist
);
191 Vector_Gcd(M
->p
[0], exist
, &g
);
192 if (value_notone_p(g
))
193 Vector_AntiScale(M
->p
[0], M
->p
[0], g
, exist
);
196 int ok
= unimodular_complete(M
, 1);
198 Matrix
*M2
= Matrix_Alloc(P
->Dimension
+1, P
->Dimension
+1);
199 for (r
= 0; r
< nvar
; ++r
)
200 value_set_si(M2
->p
[r
][r
], 1);
201 for ( ; r
< nvar
+exist
; ++r
)
202 Vector_Copy(M
->p
[r
-nvar
], M2
->p
[r
]+nvar
, exist
);
203 for ( ; r
< P
->Dimension
+1; ++r
)
204 value_set_si(M2
->p
[r
][r
], 1);
205 Polyhedron
*T
= Polyhedron_Image(P
, M2
, MaxRays
);
213 /* Split polyhedron P into two polyhedra *pos and *neg, where
214 * existential variable i has at most one solution for each
215 * value of the other variables in *neg.
217 * If independent is set, then the two constraints on which the
218 * split will be performed need to be independent of the other
219 * existential variables.
221 * Return true if an appropriate split could be performed.
223 * nvar: number of set variables
224 * exist: number of existential variables
225 * row: temporary vector that can be used by this procedure
226 * f: temporary value that can be used by this procedure
228 static bool SplitOnVar(Polyhedron
*P
, int i
,
229 int nvar
, int exist
, int MaxRays
,
230 Vector
*row
, Value
& f
, bool independent
,
231 Polyhedron
**pos
, Polyhedron
**neg
)
235 for (int l
= P
->NbEq
; l
< P
->NbConstraints
; ++l
) {
236 if (value_negz_p(P
->Constraint
[l
][nvar
+i
+1]))
240 for (j
= 0; j
< exist
; ++j
)
241 if (j
!= i
&& value_notzero_p(P
->Constraint
[l
][nvar
+j
+1]))
247 for (int u
= P
->NbEq
; u
< P
->NbConstraints
; ++u
) {
248 if (value_posz_p(P
->Constraint
[u
][nvar
+i
+1]))
252 for (j
= 0; j
< exist
; ++j
)
253 if (j
!= i
&& value_notzero_p(P
->Constraint
[u
][nvar
+j
+1]))
259 if (SplitOnConstraint(P
, i
, l
, u
, nvar
, MaxRays
, row
, f
, pos
, neg
)) {
262 Polyhedron_ExchangeColumns(*neg
, nvar
+1, nvar
+1+i
);
275 INDEPENDENT
= 1 << 2,
279 static evalue
* enumerate_or(Polyhedron
*D
,
280 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
283 fprintf(stderr
, "\nER: Or\n");
284 #endif /* DEBUG_ER */
286 Polyhedron
*N
= D
->next
;
289 barvinok_enumerate_e_with_options(D
, exist
, nparam
, options
);
292 for (D
= N
; D
; D
= N
) {
297 barvinok_enumerate_e_with_options(D
, exist
, nparam
, options
);
309 static evalue
* enumerate_sum(Polyhedron
*P
,
310 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
312 int nvar
= P
->Dimension
- exist
- nparam
;
313 int toswap
= nvar
< exist
? nvar
: exist
;
314 for (int i
= 0; i
< toswap
; ++i
)
315 Polyhedron_ExchangeColumns(P
, 1 + i
, nvar
+exist
- i
);
319 fprintf(stderr
, "\nER: Sum\n");
320 #endif /* DEBUG_ER */
322 evalue
*EP
= barvinok_enumerate_e_with_options(P
, exist
, nparam
, options
);
324 evalue_split_domains_into_orthants(EP
, options
->MaxRays
);
326 evalue_range_reduction(EP
);
328 evalue_frac2floor(EP
);
330 evalue
*sum
= barvinok_summate(EP
, nvar
, options
);
335 evalue_range_reduction(EP
);
340 static evalue
* split_sure(Polyhedron
*P
, Polyhedron
*S
,
341 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
343 int nvar
= P
->Dimension
- exist
- nparam
;
345 Matrix
*M
= Matrix_Alloc(exist
, S
->Dimension
+2);
346 for (int i
= 0; i
< exist
; ++i
)
347 value_set_si(M
->p
[i
][nvar
+i
+1], 1);
349 S
= DomainAddRays(S
, M
, options
->MaxRays
);
351 Polyhedron
*F
= DomainAddRays(P
, M
, options
->MaxRays
);
352 Polyhedron
*D
= DomainDifference(F
, S
, options
->MaxRays
);
354 D
= Disjoint_Domain(D
, 0, options
->MaxRays
);
359 M
= Matrix_Alloc(P
->Dimension
+1-exist
, P
->Dimension
+1);
360 for (int j
= 0; j
< nvar
; ++j
)
361 value_set_si(M
->p
[j
][j
], 1);
362 for (int j
= 0; j
< nparam
+1; ++j
)
363 value_set_si(M
->p
[nvar
+j
][nvar
+exist
+j
], 1);
364 Polyhedron
*T
= Polyhedron_Image(S
, M
, options
->MaxRays
);
365 evalue
*EP
= barvinok_enumerate_e_with_options(T
, 0, nparam
, options
);
370 for (Polyhedron
*Q
= D
; Q
; Q
= Q
->next
) {
371 Polyhedron
*N
= Q
->next
;
373 T
= DomainIntersection(P
, Q
, options
->MaxRays
);
374 evalue
*E
= barvinok_enumerate_e_with_options(T
, exist
, nparam
, options
);
384 static evalue
* enumerate_sure(Polyhedron
*P
,
385 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
389 int nvar
= P
->Dimension
- exist
- nparam
;
395 for (i
= 0; i
< exist
; ++i
) {
396 Matrix
*M
= Matrix_Alloc(S
->NbConstraints
, S
->Dimension
+2);
398 value_set_si(lcm
, 1);
399 for (int j
= 0; j
< S
->NbConstraints
; ++j
) {
400 if (value_negz_p(S
->Constraint
[j
][1+nvar
+i
]))
402 if (value_one_p(S
->Constraint
[j
][1+nvar
+i
]))
404 value_lcm(lcm
, lcm
, S
->Constraint
[j
][1+nvar
+i
]);
407 for (int j
= 0; j
< S
->NbConstraints
; ++j
) {
408 if (value_negz_p(S
->Constraint
[j
][1+nvar
+i
]))
410 if (value_one_p(S
->Constraint
[j
][1+nvar
+i
]))
412 value_division(f
, lcm
, S
->Constraint
[j
][1+nvar
+i
]);
413 Vector_Scale(S
->Constraint
[j
], M
->p
[c
], f
, S
->Dimension
+2);
414 value_subtract(M
->p
[c
][S
->Dimension
+1],
415 M
->p
[c
][S
->Dimension
+1],
417 value_increment(M
->p
[c
][S
->Dimension
+1],
418 M
->p
[c
][S
->Dimension
+1]);
422 S
= AddConstraints(M
->p
[0], c
, S
, options
->MaxRays
);
437 fprintf(stderr
, "\nER: Sure\n");
438 #endif /* DEBUG_ER */
440 return split_sure(P
, S
, exist
, nparam
, options
);
443 static evalue
* enumerate_sure2(Polyhedron
*P
,
444 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
446 int nvar
= P
->Dimension
- exist
- nparam
;
448 for (r
= 0; r
< P
->NbRays
; ++r
)
449 if (value_one_p(P
->Ray
[r
][0]) &&
450 value_one_p(P
->Ray
[r
][P
->Dimension
+1]))
456 Matrix
*M
= Matrix_Alloc(nvar
+ 1 + nparam
, P
->Dimension
+2);
457 for (int i
= 0; i
< nvar
; ++i
)
458 value_set_si(M
->p
[i
][1+i
], 1);
459 for (int i
= 0; i
< nparam
; ++i
)
460 value_set_si(M
->p
[i
+nvar
][1+nvar
+exist
+i
], 1);
461 Vector_Copy(P
->Ray
[r
]+1+nvar
, M
->p
[nvar
+nparam
]+1+nvar
, exist
);
462 value_set_si(M
->p
[nvar
+nparam
][0], 1);
463 value_set_si(M
->p
[nvar
+nparam
][P
->Dimension
+1], 1);
464 Polyhedron
* F
= Rays2Polyhedron(M
, options
->MaxRays
);
467 Polyhedron
*I
= DomainIntersection(F
, P
, options
->MaxRays
);
471 fprintf(stderr
, "\nER: Sure2\n");
472 #endif /* DEBUG_ER */
474 return split_sure(P
, I
, exist
, nparam
, options
);
477 static evalue
* enumerate_cyclic(Polyhedron
*P
,
478 unsigned exist
, unsigned nparam
,
479 evalue
* EP
, int r
, int p
, unsigned MaxRays
)
481 int nvar
= P
->Dimension
- exist
- nparam
;
483 /* If EP in its fractional maps only contains references
484 * to the remainder parameter with appropriate coefficients
485 * then we could in principle avoid adding existentially
486 * quantified variables to the validity domains.
487 * We'd have to replace the remainder by m { p/m }
488 * and multiply with an appropriate factor that is one
489 * only in the appropriate range.
490 * This last multiplication can be avoided if EP
491 * has a single validity domain with no (further)
492 * constraints on the remainder parameter
495 Matrix
*CT
= Matrix_Alloc(nparam
+1, nparam
+3);
496 Matrix
*M
= Matrix_Alloc(1, 1+nparam
+3);
497 for (int j
= 0; j
< nparam
; ++j
)
499 value_set_si(CT
->p
[j
][j
], 1);
500 value_set_si(CT
->p
[p
][nparam
+1], 1);
501 value_set_si(CT
->p
[nparam
][nparam
+2], 1);
502 value_set_si(M
->p
[0][1+p
], -1);
503 value_absolute(M
->p
[0][1+nparam
], P
->Ray
[0][1+nvar
+exist
+p
]);
504 value_set_si(M
->p
[0][1+nparam
+1], 1);
505 Polyhedron
*CEq
= Constraints2Polyhedron(M
, 1);
507 addeliminatedparams_enum(EP
, CT
, CEq
, MaxRays
, nparam
);
508 Polyhedron_Free(CEq
);
514 static void enumerate_vd_add_ray(evalue
*EP
, Matrix
*Rays
, unsigned MaxRays
)
516 if (value_notzero_p(EP
->d
))
519 assert(EP
->x
.p
->type
== partition
);
520 assert(EP
->x
.p
->pos
== EVALUE_DOMAIN(EP
->x
.p
->arr
[0])->Dimension
);
521 for (int i
= 0; i
< EP
->x
.p
->size
/2; ++i
) {
522 Polyhedron
*D
= EVALUE_DOMAIN(EP
->x
.p
->arr
[2*i
]);
523 Polyhedron
*N
= DomainAddRays(D
, Rays
, MaxRays
);
524 EVALUE_SET_DOMAIN(EP
->x
.p
->arr
[2*i
], N
);
529 static evalue
* enumerate_line(Polyhedron
*P
,
530 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
536 fprintf(stderr
, "\nER: Line\n");
537 #endif /* DEBUG_ER */
539 int nvar
= P
->Dimension
- exist
- nparam
;
541 for (i
= 0; i
< nparam
; ++i
)
542 if (value_notzero_p(P
->Ray
[0][1+nvar
+exist
+i
]))
545 for (j
= i
+1; j
< nparam
; ++j
)
546 if (value_notzero_p(P
->Ray
[0][1+nvar
+exist
+j
]))
548 assert(j
>= nparam
); // for now
550 Matrix
*M
= Matrix_Alloc(2, P
->Dimension
+2);
551 value_set_si(M
->p
[0][0], 1);
552 value_set_si(M
->p
[0][1+nvar
+exist
+i
], 1);
553 value_set_si(M
->p
[1][0], 1);
554 value_set_si(M
->p
[1][1+nvar
+exist
+i
], -1);
555 value_absolute(M
->p
[1][1+P
->Dimension
], P
->Ray
[0][1+nvar
+exist
+i
]);
556 value_decrement(M
->p
[1][1+P
->Dimension
], M
->p
[1][1+P
->Dimension
]);
557 Polyhedron
*S
= AddConstraints(M
->p
[0], 2, P
, options
->MaxRays
);
558 evalue
*EP
= barvinok_enumerate_e_with_options(S
, exist
, nparam
, options
);
562 return enumerate_cyclic(P
, exist
, nparam
, EP
, 0, i
, options
->MaxRays
);
565 static int single_param_pos(Polyhedron
*P
, unsigned exist
, unsigned nparam
,
568 int nvar
= P
->Dimension
- exist
- nparam
;
569 if (First_Non_Zero(P
->Ray
[r
]+1, nvar
) != -1)
571 int i
= First_Non_Zero(P
->Ray
[r
]+1+nvar
+exist
, nparam
);
574 if (First_Non_Zero(P
->Ray
[r
]+1+nvar
+exist
+1, nparam
-i
-1) != -1)
579 static evalue
* enumerate_remove_ray(Polyhedron
*P
, int r
,
580 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
583 fprintf(stderr
, "\nER: RedundantRay\n");
584 #endif /* DEBUG_ER */
588 value_set_si(one
, 1);
589 int len
= P
->NbRays
-1;
590 Matrix
*M
= Matrix_Alloc(2 * len
, P
->Dimension
+2);
591 Vector_Copy(P
->Ray
[0], M
->p
[0], r
* (P
->Dimension
+2));
592 Vector_Copy(P
->Ray
[r
+1], M
->p
[r
], (len
-r
) * (P
->Dimension
+2));
593 for (int j
= 0; j
< P
->NbRays
; ++j
) {
596 Vector_Combine(P
->Ray
[j
], P
->Ray
[r
], M
->p
[len
+j
-(j
>r
)],
597 one
, P
->Ray
[j
][P
->Dimension
+1], P
->Dimension
+2);
600 P
= Rays2Polyhedron(M
, options
->MaxRays
);
602 evalue
*EP
= barvinok_enumerate_e_with_options(P
, exist
, nparam
, options
);
609 static evalue
* enumerate_redundant_ray(Polyhedron
*P
,
610 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
612 assert(P
->NbBid
== 0);
613 int nvar
= P
->Dimension
- exist
- nparam
;
617 for (int r
= 0; r
< P
->NbRays
; ++r
) {
618 if (value_notzero_p(P
->Ray
[r
][P
->Dimension
+1]))
620 int i1
= single_param_pos(P
, exist
, nparam
, r
);
623 for (int r2
= r
+1; r2
< P
->NbRays
; ++r2
) {
624 if (value_notzero_p(P
->Ray
[r2
][P
->Dimension
+1]))
626 int i2
= single_param_pos(P
, exist
, nparam
, r2
);
632 value_division(m
, P
->Ray
[r
][1+nvar
+exist
+i1
],
633 P
->Ray
[r2
][1+nvar
+exist
+i1
]);
634 value_multiply(m
, m
, P
->Ray
[r2
][1+nvar
+exist
+i1
]);
635 /* r2 divides r => r redundant */
636 if (value_eq(m
, P
->Ray
[r
][1+nvar
+exist
+i1
])) {
638 return enumerate_remove_ray(P
, r
, exist
, nparam
, options
);
641 value_division(m
, P
->Ray
[r2
][1+nvar
+exist
+i1
],
642 P
->Ray
[r
][1+nvar
+exist
+i1
]);
643 value_multiply(m
, m
, P
->Ray
[r
][1+nvar
+exist
+i1
]);
644 /* r divides r2 => r2 redundant */
645 if (value_eq(m
, P
->Ray
[r2
][1+nvar
+exist
+i1
])) {
647 return enumerate_remove_ray(P
, r2
, exist
, nparam
, options
);
655 static Polyhedron
*upper_bound(Polyhedron
*P
,
656 int pos
, Value
*max
, Polyhedron
**R
)
665 for (Polyhedron
*Q
= P
; Q
; Q
= N
) {
667 for (r
= 0; r
< P
->NbRays
; ++r
) {
668 if (value_zero_p(P
->Ray
[r
][P
->Dimension
+1]) &&
669 value_pos_p(P
->Ray
[r
][1+pos
]))
680 for (r
= 0; r
< P
->NbRays
; ++r
) {
681 if (value_zero_p(P
->Ray
[r
][P
->Dimension
+1]))
683 mpz_fdiv_q(v
, P
->Ray
[r
][1+pos
], P
->Ray
[r
][1+P
->Dimension
]);
684 if ((!Q
->next
&& r
== 0) || value_gt(v
, *max
))
685 value_assign(*max
, v
);
692 static evalue
* enumerate_ray(Polyhedron
*P
,
693 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
695 assert(P
->NbBid
== 0);
696 int nvar
= P
->Dimension
- exist
- nparam
;
699 for (r
= 0; r
< P
->NbRays
; ++r
)
700 if (value_zero_p(P
->Ray
[r
][P
->Dimension
+1]))
706 for (r2
= r
+1; r2
< P
->NbRays
; ++r2
)
707 if (value_zero_p(P
->Ray
[r2
][P
->Dimension
+1]))
709 if (r2
< P
->NbRays
) {
711 return enumerate_sum(P
, exist
, nparam
, options
);
715 fprintf(stderr
, "\nER: Ray\n");
716 #endif /* DEBUG_ER */
722 value_set_si(one
, 1);
723 int i
= single_param_pos(P
, exist
, nparam
, r
);
724 assert(i
!= -1); // for now;
726 Matrix
*M
= Matrix_Alloc(P
->NbRays
, P
->Dimension
+2);
727 for (int j
= 0; j
< P
->NbRays
; ++j
) {
728 Vector_Combine(P
->Ray
[j
], P
->Ray
[r
], M
->p
[j
],
729 one
, P
->Ray
[j
][P
->Dimension
+1], P
->Dimension
+2);
731 Polyhedron
*S
= Rays2Polyhedron(M
, options
->MaxRays
);
733 Polyhedron
*D
= DomainDifference(P
, S
, options
->MaxRays
);
735 // Polyhedron_Print(stderr, P_VALUE_FMT, D);
736 assert(value_pos_p(P
->Ray
[r
][1+nvar
+exist
+i
])); // for now
738 D
= upper_bound(D
, nvar
+exist
+i
, &m
, &R
);
742 M
= Matrix_Alloc(2, P
->Dimension
+2);
743 value_set_si(M
->p
[0][0], 1);
744 value_set_si(M
->p
[1][0], 1);
745 value_set_si(M
->p
[0][1+nvar
+exist
+i
], -1);
746 value_set_si(M
->p
[1][1+nvar
+exist
+i
], 1);
747 value_assign(M
->p
[0][1+P
->Dimension
], m
);
748 value_oppose(M
->p
[1][1+P
->Dimension
], m
);
749 value_addto(M
->p
[1][1+P
->Dimension
], M
->p
[1][1+P
->Dimension
],
750 P
->Ray
[r
][1+nvar
+exist
+i
]);
751 value_decrement(M
->p
[1][1+P
->Dimension
], M
->p
[1][1+P
->Dimension
]);
752 // Matrix_Print(stderr, P_VALUE_FMT, M);
753 D
= AddConstraints(M
->p
[0], 2, P
, options
->MaxRays
);
754 // Polyhedron_Print(stderr, P_VALUE_FMT, D);
755 value_subtract(M
->p
[0][1+P
->Dimension
], M
->p
[0][1+P
->Dimension
],
756 P
->Ray
[r
][1+nvar
+exist
+i
]);
757 // Matrix_Print(stderr, P_VALUE_FMT, M);
758 S
= AddConstraints(M
->p
[0], 1, P
, options
->MaxRays
);
759 // Polyhedron_Print(stderr, P_VALUE_FMT, S);
762 evalue
*EP
= barvinok_enumerate_e_with_options(D
, exist
, nparam
, options
);
767 if (value_notone_p(P
->Ray
[r
][1+nvar
+exist
+i
]))
768 EP
= enumerate_cyclic(P
, exist
, nparam
, EP
, r
, i
, options
->MaxRays
);
770 M
= Matrix_Alloc(1, nparam
+2);
771 value_set_si(M
->p
[0][0], 1);
772 value_set_si(M
->p
[0][1+i
], 1);
773 enumerate_vd_add_ray(EP
, M
, options
->MaxRays
);
778 evalue
*E
= barvinok_enumerate_e_with_options(S
, exist
, nparam
, options
);
786 evalue
*ER
= enumerate_or(R
, exist
, nparam
, options
);
788 free_evalue_refs(ER
);
795 static evalue
* enumerate_vd(Polyhedron
**PA
,
796 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
799 int nvar
= P
->Dimension
- exist
- nparam
;
800 Param_Polyhedron
*PP
= NULL
;
801 Polyhedron
*C
= Universe_Polyhedron(nparam
);
803 PP
= Polyhedron2Param_Polyhedron(PR
, C
, options
);
807 Param_Domain
*D
, *last
;
810 for (nd
= 0, D
=PP
->D
; D
; D
=D
->next
, ++nd
)
813 Polyhedron
**VD
= new Polyhedron
*[nd
];
814 Polyhedron
*TC
= true_context(P
, C
, options
->MaxRays
);
815 FORALL_REDUCED_DOMAIN(PP
, TC
, nd
, options
, i
, D
, rVD
)
818 END_FORALL_REDUCED_DOMAIN
826 /* This doesn't seem to have any effect */
828 Polyhedron
*CA
= align_context(VD
[0], P
->Dimension
, options
->MaxRays
);
830 P
= DomainIntersection(P
, CA
, options
->MaxRays
);
844 fprintf(stderr
, "\nER: VD\n");
845 #endif /* DEBUG_ER */
846 for (int i
= 0; i
< nd
; ++i
) {
847 Polyhedron
*CA
= align_context(VD
[i
], P
->Dimension
, options
->MaxRays
);
848 Polyhedron
*I
= DomainIntersection(P
, CA
, options
->MaxRays
);
851 EP
= barvinok_enumerate_e_with_options(I
, exist
, nparam
, options
);
853 evalue
*E
= barvinok_enumerate_e_with_options(I
, exist
, nparam
,
863 for (int i
= 0; i
< nd
; ++i
)
864 Polyhedron_Free(VD
[i
]);
868 if (!EP
&& nvar
== 0) {
871 Param_Vertices
*V
, *V2
;
872 Matrix
* M
= Matrix_Alloc(1, P
->Dimension
+2);
874 FORALL_PVertex_in_ParamPolyhedron(V
, last
, PP
) {
876 FORALL_PVertex_in_ParamPolyhedron(V2
, last
, PP
) {
883 for (int i
= 0; i
< exist
; ++i
) {
884 value_oppose(f
, V
->Vertex
->p
[i
][nparam
+1]);
885 Vector_Combine(V
->Vertex
->p
[i
],
887 M
->p
[0] + 1 + nvar
+ exist
,
888 V2
->Vertex
->p
[i
][nparam
+1],
892 for (j
= 0; j
< nparam
; ++j
)
893 if (value_notzero_p(M
->p
[0][1+nvar
+exist
+j
]))
897 ConstraintSimplify(M
->p
[0], M
->p
[0],
899 value_set_si(M
->p
[0][0], 0);
900 Polyhedron
*para
= AddConstraints(M
->p
[0], 1, P
,
902 POL_ENSURE_VERTICES(para
);
904 Polyhedron_Free(para
);
907 Polyhedron
*pos
, *neg
;
908 value_set_si(M
->p
[0][0], 1);
909 value_decrement(M
->p
[0][P
->Dimension
+1],
910 M
->p
[0][P
->Dimension
+1]);
911 neg
= AddConstraints(M
->p
[0], 1, P
, options
->MaxRays
);
913 Vector_Scale(M
->p
[0]+1, M
->p
[0]+1, f
,
915 value_decrement(M
->p
[0][P
->Dimension
+1],
916 M
->p
[0][P
->Dimension
+1]);
917 value_decrement(M
->p
[0][P
->Dimension
+1],
918 M
->p
[0][P
->Dimension
+1]);
919 pos
= AddConstraints(M
->p
[0], 1, P
, options
->MaxRays
);
920 POL_ENSURE_VERTICES(neg
);
921 POL_ENSURE_VERTICES(pos
);
922 if (emptyQ(neg
) && emptyQ(pos
)) {
923 Polyhedron_Free(para
);
924 Polyhedron_Free(pos
);
925 Polyhedron_Free(neg
);
929 fprintf(stderr
, "\nER: Order\n");
930 #endif /* DEBUG_ER */
931 EP
= barvinok_enumerate_e_with_options(para
, exist
, nparam
,
935 E
= barvinok_enumerate_e_with_options(pos
, exist
, nparam
,
941 E
= barvinok_enumerate_e_with_options(neg
, exist
, nparam
,
946 Polyhedron_Free(para
);
947 Polyhedron_Free(pos
);
948 Polyhedron_Free(neg
);
953 } END_FORALL_PVertex_in_ParamPolyhedron
;
956 } END_FORALL_PVertex_in_ParamPolyhedron
;
959 /* Search for vertex coordinate to split on */
960 /* First look for one independent of the parameters */
961 FORALL_PVertex_in_ParamPolyhedron(V
, last
, PP
) {
962 for (int i
= 0; i
< exist
; ++i
) {
964 for (j
= 0; j
< nparam
; ++j
)
965 if (value_notzero_p(V
->Vertex
->p
[i
][j
]))
969 value_set_si(M
->p
[0][0], 1);
970 Vector_Set(M
->p
[0]+1, 0, nvar
+exist
);
971 Vector_Copy(V
->Vertex
->p
[i
],
972 M
->p
[0] + 1 + nvar
+ exist
, nparam
+1);
973 value_oppose(M
->p
[0][1+nvar
+i
],
974 V
->Vertex
->p
[i
][nparam
+1]);
976 Polyhedron
*pos
, *neg
;
977 value_set_si(M
->p
[0][0], 1);
978 value_decrement(M
->p
[0][P
->Dimension
+1],
979 M
->p
[0][P
->Dimension
+1]);
980 neg
= AddConstraints(M
->p
[0], 1, P
, options
->MaxRays
);
982 Vector_Scale(M
->p
[0]+1, M
->p
[0]+1, f
,
984 value_decrement(M
->p
[0][P
->Dimension
+1],
985 M
->p
[0][P
->Dimension
+1]);
986 value_decrement(M
->p
[0][P
->Dimension
+1],
987 M
->p
[0][P
->Dimension
+1]);
988 pos
= AddConstraints(M
->p
[0], 1, P
, options
->MaxRays
);
989 POL_ENSURE_VERTICES(neg
);
990 POL_ENSURE_VERTICES(pos
);
991 if (emptyQ(neg
) || emptyQ(pos
)) {
992 Polyhedron_Free(pos
);
993 Polyhedron_Free(neg
);
996 Polyhedron_Free(pos
);
997 value_increment(M
->p
[0][P
->Dimension
+1],
998 M
->p
[0][P
->Dimension
+1]);
999 pos
= AddConstraints(M
->p
[0], 1, P
, options
->MaxRays
);
1001 fprintf(stderr
, "\nER: Vertex\n");
1002 #endif /* DEBUG_ER */
1004 EP
= enumerate_or(pos
, exist
, nparam
, options
);
1009 } END_FORALL_PVertex_in_ParamPolyhedron
;
1013 /* Search for vertex coordinate to split on */
1014 /* Now look for one that depends on the parameters */
1015 FORALL_PVertex_in_ParamPolyhedron(V
, last
, PP
) {
1016 for (int i
= 0; i
< exist
; ++i
) {
1017 value_set_si(M
->p
[0][0], 1);
1018 Vector_Set(M
->p
[0]+1, 0, nvar
+exist
);
1019 Vector_Copy(V
->Vertex
->p
[i
],
1020 M
->p
[0] + 1 + nvar
+ exist
, nparam
+1);
1021 value_oppose(M
->p
[0][1+nvar
+i
],
1022 V
->Vertex
->p
[i
][nparam
+1]);
1024 Polyhedron
*pos
, *neg
;
1025 value_set_si(M
->p
[0][0], 1);
1026 value_decrement(M
->p
[0][P
->Dimension
+1],
1027 M
->p
[0][P
->Dimension
+1]);
1028 neg
= AddConstraints(M
->p
[0], 1, P
, options
->MaxRays
);
1029 value_set_si(f
, -1);
1030 Vector_Scale(M
->p
[0]+1, M
->p
[0]+1, f
,
1032 value_decrement(M
->p
[0][P
->Dimension
+1],
1033 M
->p
[0][P
->Dimension
+1]);
1034 value_decrement(M
->p
[0][P
->Dimension
+1],
1035 M
->p
[0][P
->Dimension
+1]);
1036 pos
= AddConstraints(M
->p
[0], 1, P
, options
->MaxRays
);
1037 POL_ENSURE_VERTICES(neg
);
1038 POL_ENSURE_VERTICES(pos
);
1039 if (emptyQ(neg
) || emptyQ(pos
)) {
1040 Polyhedron_Free(pos
);
1041 Polyhedron_Free(neg
);
1044 Polyhedron_Free(pos
);
1045 value_increment(M
->p
[0][P
->Dimension
+1],
1046 M
->p
[0][P
->Dimension
+1]);
1047 pos
= AddConstraints(M
->p
[0], 1, P
, options
->MaxRays
);
1049 fprintf(stderr
, "\nER: ParamVertex\n");
1050 #endif /* DEBUG_ER */
1052 EP
= enumerate_or(pos
, exist
, nparam
, options
);
1057 } END_FORALL_PVertex_in_ParamPolyhedron
;
1065 Param_Polyhedron_Free(PP
);
1071 evalue
*barvinok_enumerate_isl(Polyhedron
*P
,
1072 unsigned exist
, unsigned nparam
, struct barvinok_options
*options
)
1074 isl_ctx
*ctx
= isl_ctx_alloc();
1076 isl_basic_set
*bset
;
1078 evalue
*EP
= evalue_zero();
1079 Polyhedron
*D
, *Q
, *N
;
1080 Polyhedron
*U
= Universe_Polyhedron(nparam
);
1082 dims
= isl_space_set_alloc(ctx
, nparam
, P
->Dimension
- nparam
- exist
);
1083 bset
= isl_basic_set_new_from_polylib(P
, dims
);
1085 set
= isl_basic_set_compute_divs(bset
);
1087 D
= isl_set_to_polylib(set
);
1088 for (Q
= D
; Q
; Q
= N
) {
1092 E
= barvinok_enumerate_with_options(Q
, U
, options
);
1105 static bool is_single(Value
*row
, int pos
, int len
)
1107 return First_Non_Zero(row
, pos
) == -1 &&
1108 First_Non_Zero(row
+pos
+1, len
-pos
-1) == -1;
1111 static evalue
* barvinok_enumerate_e_r(Polyhedron
*P
,
1112 unsigned exist
, unsigned nparam
, barvinok_options
*options
);
1115 static int er_level
= 0;
1117 evalue
* barvinok_enumerate_e_with_options(Polyhedron
*P
,
1118 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
1120 fprintf(stderr
, "\nER: level %i\n", er_level
);
1122 Polyhedron_PrintConstraints(stderr
, P_VALUE_FMT
, P
);
1123 fprintf(stderr
, "\nE %d\nP %d\n", exist
, nparam
);
1125 P
= DomainConstraintSimplify(Polyhedron_Copy(P
), options
->MaxRays
);
1126 evalue
*EP
= barvinok_enumerate_e_r(P
, exist
, nparam
, options
);
1132 evalue
* barvinok_enumerate_e_with_options(Polyhedron
*P
,
1133 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
1135 P
= DomainConstraintSimplify(Polyhedron_Copy(P
), options
->MaxRays
);
1136 evalue
*EP
= barvinok_enumerate_e_r(P
, exist
, nparam
, options
);
1142 evalue
* barvinok_enumerate_e(Polyhedron
*P
, unsigned exist
, unsigned nparam
,
1146 barvinok_options
*options
= barvinok_options_new_with_defaults();
1147 options
->MaxRays
= MaxRays
;
1148 E
= barvinok_enumerate_e_with_options(P
, exist
, nparam
, options
);
1149 barvinok_options_free(options
);
1153 static evalue
*universal_zero(unsigned nparam
)
1157 eres
= ALLOC(evalue
);
1158 value_init(eres
->d
);
1159 value_set_si(eres
->d
, 0);
1160 eres
->x
.p
= new_enode(partition
, 2, nparam
);
1161 EVALUE_SET_DOMAIN(eres
->x
.p
->arr
[0], Universe_Polyhedron(nparam
));
1162 value_set_si(eres
->x
.p
->arr
[1].d
, 1);
1163 value_init(eres
->x
.p
->arr
[1].x
.n
);
1168 static evalue
* barvinok_enumerate_e_r(Polyhedron
*P
,
1169 unsigned exist
, unsigned nparam
, barvinok_options
*options
)
1172 Polyhedron
*U
= Universe_Polyhedron(nparam
);
1173 evalue
*EP
= barvinok_enumerate_with_options(P
, U
, options
);
1174 //char *param_name[] = {"P", "Q", "R", "S", "T" };
1175 //print_evalue(stdout, EP, param_name);
1180 int nvar
= P
->Dimension
- exist
- nparam
;
1181 int len
= P
->Dimension
+ 2;
1184 POL_ENSURE_FACETS(P
);
1185 POL_ENSURE_VERTICES(P
);
1188 return evalue_zero();
1190 if (nvar
== 0 && nparam
== 0) {
1191 evalue
*EP
= universal_zero(nparam
);
1192 barvinok_count_with_options(P
, &EP
->x
.p
->arr
[1].x
.n
, options
);
1193 if (value_pos_p(EP
->x
.p
->arr
[1].x
.n
))
1194 value_set_si(EP
->x
.p
->arr
[1].x
.n
, 1);
1199 for (r
= 0; r
< P
->NbRays
; ++r
)
1200 if (value_zero_p(P
->Ray
[r
][0]) ||
1201 value_zero_p(P
->Ray
[r
][P
->Dimension
+1])) {
1203 for (i
= 0; i
< nvar
; ++i
)
1204 if (value_notzero_p(P
->Ray
[r
][i
+1]))
1208 for (i
= nvar
+ exist
; i
< nvar
+ exist
+ nparam
; ++i
)
1209 if (value_notzero_p(P
->Ray
[r
][i
+1]))
1211 if (i
>= nvar
+ exist
+ nparam
)
1214 if (r
< P
->NbRays
) {
1215 evalue
*EP
= universal_zero(nparam
);
1216 value_set_si(EP
->x
.p
->arr
[1].x
.n
, -1);
1221 for (r
= 0; r
< P
->NbEq
; ++r
)
1222 if ((first
= First_Non_Zero(P
->Constraint
[r
]+1+nvar
, exist
)) != -1)
1225 if (First_Non_Zero(P
->Constraint
[r
]+1+nvar
+first
+1,
1226 exist
-first
-1) != -1) {
1227 Polyhedron
*T
= rotate_along(P
, r
, nvar
, exist
, options
->MaxRays
);
1229 fprintf(stderr
, "\nER: Equality\n");
1230 #endif /* DEBUG_ER */
1231 evalue
*EP
= barvinok_enumerate_e_with_options(T
, exist
-1, nparam
,
1237 fprintf(stderr
, "\nER: Fixed\n");
1238 #endif /* DEBUG_ER */
1240 return barvinok_enumerate_e_with_options(P
, exist
-1, nparam
,
1243 Polyhedron
*T
= Polyhedron_Copy(P
);
1244 Polyhedron_ExchangeColumns(T
, nvar
+1, nvar
+1+first
);
1245 evalue
*EP
= barvinok_enumerate_e_with_options(T
, exist
-1, nparam
,
1253 Vector
*row
= Vector_Alloc(len
);
1254 value_set_si(row
->p
[0], 1);
1259 enum constraint
* info
= new constraint
[exist
];
1260 for (int i
= 0; i
< exist
; ++i
) {
1262 for (int l
= P
->NbEq
; l
< P
->NbConstraints
; ++l
) {
1263 if (value_negz_p(P
->Constraint
[l
][nvar
+i
+1]))
1265 bool l_parallel
= is_single(P
->Constraint
[l
]+nvar
+1, i
, exist
);
1266 for (int u
= P
->NbEq
; u
< P
->NbConstraints
; ++u
) {
1267 if (value_posz_p(P
->Constraint
[u
][nvar
+i
+1]))
1269 bool lu_parallel
= l_parallel
||
1270 is_single(P
->Constraint
[u
]+nvar
+1, i
, exist
);
1271 value_oppose(f
, P
->Constraint
[u
][nvar
+i
+1]);
1272 Vector_Combine(P
->Constraint
[l
]+1, P
->Constraint
[u
]+1, row
->p
+1,
1273 f
, P
->Constraint
[l
][nvar
+i
+1], len
-1);
1274 if (!(info
[i
] & INDEPENDENT
)) {
1276 for (j
= 0; j
< exist
; ++j
)
1277 if (j
!= i
&& value_notzero_p(row
->p
[nvar
+j
+1]))
1280 //printf("independent: i: %d, l: %d, u: %d\n", i, l, u);
1281 info
[i
] = (constraint
)(info
[i
] | INDEPENDENT
);
1284 if (info
[i
] & ALL_POS
) {
1285 value_addto(row
->p
[len
-1], row
->p
[len
-1],
1286 P
->Constraint
[l
][nvar
+i
+1]);
1287 value_addto(row
->p
[len
-1], row
->p
[len
-1], f
);
1288 value_multiply(f
, f
, P
->Constraint
[l
][nvar
+i
+1]);
1289 value_subtract(row
->p
[len
-1], row
->p
[len
-1], f
);
1290 value_decrement(row
->p
[len
-1], row
->p
[len
-1]);
1291 ConstraintSimplify(row
->p
, row
->p
, len
, &f
);
1292 value_set_si(f
, -1);
1293 Vector_Scale(row
->p
+1, row
->p
+1, f
, len
-1);
1294 value_decrement(row
->p
[len
-1], row
->p
[len
-1]);
1295 Polyhedron
*T
= AddConstraints(row
->p
, 1, P
, options
->MaxRays
);
1296 POL_ENSURE_VERTICES(T
);
1298 //printf("not all_pos: i: %d, l: %d, u: %d\n", i, l, u);
1299 info
[i
] = (constraint
)(info
[i
] ^ ALL_POS
);
1301 //puts("pos remainder");
1302 //Polyhedron_Print(stdout, P_VALUE_FMT, T);
1305 if (!(info
[i
] & ONE_NEG
)) {
1307 negative_test_constraint(P
->Constraint
[l
],
1309 row
->p
, nvar
+i
, len
, &f
);
1310 oppose_constraint(row
->p
, len
, &f
);
1311 Polyhedron
*T
= AddConstraints(row
->p
, 1, P
,
1313 POL_ENSURE_VERTICES(T
);
1315 //printf("one_neg i: %d, l: %d, u: %d\n", i, l, u);
1316 info
[i
] = (constraint
)(info
[i
] | ONE_NEG
);
1318 //puts("neg remainder");
1319 //Polyhedron_Print(stdout, P_VALUE_FMT, T);
1321 } else if (!(info
[i
] & ROT_NEG
)) {
1322 if (parallel_constraints(P
->Constraint
[l
],
1324 row
->p
, nvar
, exist
)) {
1325 negative_test_constraint7(P
->Constraint
[l
],
1327 row
->p
, nvar
, exist
,
1329 oppose_constraint(row
->p
, len
, &f
);
1330 Polyhedron
*T
= AddConstraints(row
->p
, 1, P
,
1332 POL_ENSURE_VERTICES(T
);
1334 // printf("rot_neg i: %d, l: %d, u: %d\n", i, l, u);
1335 info
[i
] = (constraint
)(info
[i
] | ROT_NEG
);
1338 //puts("neg remainder");
1339 //Polyhedron_Print(stdout, P_VALUE_FMT, T);
1344 if (!(info
[i
] & ALL_POS
) && (info
[i
] & (ONE_NEG
| ROT_NEG
)))
1348 if (info
[i
] & ALL_POS
)
1355 for (int i = 0; i < exist; ++i)
1356 printf("%i: %i\n", i, info[i]);
1358 for (int i
= 0; i
< exist
; ++i
)
1359 if (info
[i
] & ALL_POS
) {
1361 fprintf(stderr
, "\nER: Positive\n");
1362 #endif /* DEBUG_ER */
1364 // Maybe we should chew off some of the fat here
1365 Matrix
*M
= Matrix_Alloc(P
->Dimension
, P
->Dimension
+1);
1366 for (int j
= 0; j
< P
->Dimension
; ++j
)
1367 value_set_si(M
->p
[j
][j
+ (j
>= i
+nvar
)], 1);
1368 Polyhedron
*T
= Polyhedron_Image(P
, M
, options
->MaxRays
);
1370 evalue
*EP
= barvinok_enumerate_e_with_options(T
, exist
-1, nparam
,
1378 for (int i
= 0; i
< exist
; ++i
)
1379 if (info
[i
] & ONE_NEG
) {
1381 fprintf(stderr
, "\nER: Negative\n");
1382 #endif /* DEBUG_ER */
1387 return barvinok_enumerate_e_with_options(P
, exist
-1, nparam
,
1390 Polyhedron
*T
= Polyhedron_Copy(P
);
1391 Polyhedron_ExchangeColumns(T
, nvar
+1, nvar
+1+i
);
1392 evalue
*EP
= barvinok_enumerate_e_with_options(T
, exist
-1, nparam
,
1398 for (int i
= 0; i
< exist
; ++i
)
1399 if (info
[i
] & ROT_NEG
) {
1401 fprintf(stderr
, "\nER: Rotate\n");
1402 #endif /* DEBUG_ER */
1406 Polyhedron
*T
= rotate_along(P
, r
, nvar
, exist
, options
->MaxRays
);
1407 evalue
*EP
= barvinok_enumerate_e_with_options(T
, exist
-1, nparam
,
1412 for (int i
= 0; i
< exist
; ++i
)
1413 if (info
[i
] & INDEPENDENT
) {
1414 Polyhedron
*pos
, *neg
;
1416 /* Find constraint again and split off negative part */
1418 if (SplitOnVar(P
, i
, nvar
, exist
, options
->MaxRays
,
1419 row
, f
, true, &pos
, &neg
)) {
1421 fprintf(stderr
, "\nER: Split\n");
1422 #endif /* DEBUG_ER */
1425 barvinok_enumerate_e_with_options(neg
, exist
-1, nparam
, options
);
1427 barvinok_enumerate_e_with_options(pos
, exist
, nparam
, options
);
1430 Polyhedron_Free(neg
);
1431 Polyhedron_Free(pos
);
1445 EP
= enumerate_line(P
, exist
, nparam
, options
);
1449 EP
= barvinok_enumerate_isl(P
, exist
, nparam
, options
);
1453 EP
= enumerate_redundant_ray(P
, exist
, nparam
, options
);
1457 EP
= enumerate_sure(P
, exist
, nparam
, options
);
1461 EP
= enumerate_ray(P
, exist
, nparam
, options
);
1465 EP
= enumerate_sure2(P
, exist
, nparam
, options
);
1469 F
= unfringe(P
, options
->MaxRays
);
1470 if (!PolyhedronIncludes(F
, P
)) {
1472 fprintf(stderr
, "\nER: Fringed\n");
1473 #endif /* DEBUG_ER */
1474 EP
= barvinok_enumerate_e_with_options(F
, exist
, nparam
, options
);
1481 EP
= enumerate_vd(&P
, exist
, nparam
, options
);
1486 EP
= enumerate_sum(P
, exist
, nparam
, options
);
1493 Polyhedron
*pos
, *neg
;
1494 for (i
= 0; i
< exist
; ++i
)
1495 if (SplitOnVar(P
, i
, nvar
, exist
, options
->MaxRays
,
1496 row
, f
, false, &pos
, &neg
))
1502 EP
= enumerate_or(pos
, exist
, nparam
, options
);