iscc: recover from errors during AST generation again
[barvinok/uuh.git] / omega_interface / count.cc
blob511c18212be89a07bfcca8597360b1df31626a45
1 #include <vector>
2 #include <assert.h>
3 #include <barvinok/barvinok.h>
4 #include <barvinok/util.h>
5 #include <omega.h>
6 #include "omega_interface/convert.h"
7 #include "normalization.h"
8 #include "count.h"
9 #include "config.h"
11 #include <iostream>
12 using namespace std;
14 #define ALLOC(t,p) p = (t*)malloc(sizeof(*p))
16 #ifdef USE_PARKER
18 #include "parker/count_solutions.h"
21 * Use parker's method to compute the number of integer points in D.
22 * Since this method assumes all variables are non-negative,
23 * we have to transform the input polytope first.
25 evalue *barvinok_enumerate_parker(Polyhedron *D,
26 unsigned nvar, unsigned nparam,
27 unsigned MaxRays)
29 Polyhedron *R;
30 evalue *res;
32 if (nparam != 0) {
33 fprintf(stderr, "parker method doesn't support parameters\n");
34 return NULL;
36 R = skew_to_positive_orthant(D, nvar, MaxRays);
37 Relation r = Domain2relation(R, nvar, 0, NULL);
38 Polyhedron_Free(R);
39 double d = count_solutions(r);
40 ALLOC(evalue, res);
41 value_init(res->d);
42 value_set_si(res->d, 0);
43 res->x.p = new_enode(::partition, 2, 0);
44 EVALUE_SET_DOMAIN(res->x.p->arr[0], Universe_Polyhedron(0));
45 value_set_si(res->x.p->arr[1].d, 1);
46 value_init(res->x.p->arr[1].x.n);
47 value_set_double(res->x.p->arr[1].x.n, d);
48 return res;
51 #else
53 evalue *barvinok_enumerate_parker(Polyhedron *D,
54 unsigned nvar, unsigned nparam,
55 unsigned MaxRays)
57 fprintf(stderr, "support for parker method not compiled in\n");
58 return NULL;
61 #endif