*counter: avoid recomputation of denominators when checking for zeros
[barvinok.git] / count_domain.c
blob7c2b0f275df098ffd20cebb579a5fce30174400e
1 #include <assert.h>
2 #include <dlfcn.h>
3 #include <barvinok/evalue.h>
4 #include <barvinok/barvinok.h>
6 /* gcc -shared count_domain.c -rdynamic -o libcount.so -ldl -lc */
8 evalue* barvinok_enumerate_ev(Polyhedron *P, Polyhedron* C, unsigned MaxRays)
10 static evalue *(*orig)(Polyhedron *, Polyhedron *c, unsigned) = NULL;
11 evalue *res;
12 int c;
14 if (!orig) {
15 void *handle = dlopen("libbarvinok.so", RTLD_LAZY);
16 assert(handle);
17 orig = dlsym(handle, "barvinok_enumerate_ev");
18 assert(orig);
19 dlclose(handle);
22 res = orig(P, C, MaxRays);
24 c = value_notzero_p(res->d) ? 0
25 : res->x.p->type == partition ? res->x.p->size/2 : 1;
26 fprintf(stderr, "COUNT: %d %d %d %d\n", P->Dimension,
27 C->Dimension, c, P->Dimension - P->NbEq/*, domain_size(P)*/);
29 return res;