From dcc367026fe91bd78ba886ede876d0ddc762c410 Mon Sep 17 00:00:00 2001 From: skimo Date: Tue, 5 Oct 2004 11:08:01 +0000 Subject: [PATCH] add collect_polytopes2.c --- barvinok_enumerate_e.c | 12 ++++++++++-- collect_polytopes2.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 collect_polytopes2.c diff --git a/barvinok_enumerate_e.c b/barvinok_enumerate_e.c index d9f93f4..7fc4eba 100644 --- a/barvinok_enumerate_e.c +++ b/barvinok_enumerate_e.c @@ -28,6 +28,7 @@ struct option options[] = { { "pip", no_argument, 0, 'p' }, { "convert", no_argument, 0, 'c' }, + { "floor", no_argument, 0, 'f' }, { "range", no_argument, 0, 'r' }, { 0, 0, 0, 0 } }; @@ -45,12 +46,16 @@ int main(int argc, char **argv) int range = 0; int convert = 0; int pip = 0; + int floor = 0; - while ((c = getopt_long(argc, argv, "pcr", options, &ind)) != -1) { + while ((c = getopt_long(argc, argv, "pfcr", options, &ind)) != -1) { switch (c) { case 'p': pip = 1; break; + case 'f': + floor = 1; + break; case 'c': convert = 1; break; @@ -84,7 +89,10 @@ int main(int argc, char **argv) if (range) evalue_range_reduction(EP); print_evalue(stdout, EP, param_name); - if (convert) { + if (floor) { + evalue_frac2floor(EP); + print_evalue(stdout, EP, param_name); + } else if (convert) { evalue_mod2table(EP, nparam); print_evalue(stdout, EP, param_name); } diff --git a/collect_polytopes2.c b/collect_polytopes2.c new file mode 100644 index 0000000..f5ff2b4 --- /dev/null +++ b/collect_polytopes2.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include +#include +#include +#include "ev_operations.h" +#include "barvinok.h" + +/* gcc -shared -g collect_polytopes2.c -rdynamic -o libcollect2.so -ldl -lc -lgmp */ + +evalue* barvinok_enumerate_ev(Polyhedron *P, Polyhedron* C, unsigned MaxRays) +{ + static evalue *(*orig)(Polyhedron *, Polyhedron *c, unsigned) = NULL; + static char *prefix = NULL; + evalue *res; + static int counter = 0; + + if (!orig) { + void *handle = dlopen("libbarvinok.so", RTLD_LAZY); + assert(handle); + orig = dlsym(handle, "barvinok_enumerate_ev"); + assert(orig); + dlclose(handle); + + prefix = getenv("POLYTOPE_PREFIX"); + if (prefix) + prefix = strdup(prefix); + } + + if (prefix) { + char path[PATH_MAX]; + FILE *f; + int i, j; + unsigned nr, nc; + + snprintf(path, PATH_MAX, "%s%05d", prefix, counter++); + f = fopen(path, "w"); + fprintf(f, "%d %d\n", nr=P->NbConstraints, nc=P->Dimension+2); + for (i=0; i < nr; i++) { + for (j=0; j < nc; j++) { + value_print(f," "P_VALUE_FMT" ", P->Constraint[i][j]); + } + fprintf(f, "\n"); + } + fprintf(f, "\n0 %d\n", C->Dimension+2); + fclose(f); + } + + res = orig(P, C, MaxRays); + + return res; +} -- 2.11.4.GIT