From 41762f351128fd78061ea297534905816c76b601 Mon Sep 17 00:00:00 2001 From: skimo Date: Sat, 17 Jul 2004 16:52:08 +0000 Subject: [PATCH] provide evalue to enumeration conversion --- barvinok.cc | 19 +------------------ ev_operations.c | 26 ++++++++++++++++++++++++++ ev_operations.h | 1 + 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/barvinok.cc b/barvinok.cc index 1cd92c6..e5e26ee 100644 --- a/barvinok.cc +++ b/barvinok.cc @@ -1665,26 +1665,9 @@ out: Enumeration* barvinok_enumerate(Polyhedron *P, Polyhedron* C, unsigned MaxRays) { - Enumeration *en, *res = NULL; evalue *EP = barvinok_enumerate_ev(P, C, MaxRays); - if (EVALUE_IS_ZERO(*EP)) { - free(EP); - return res; - } - - for (int i = 0; i < EP->x.p->size/2; ++i) { - en = (Enumeration *)malloc(sizeof(Enumeration)); - en->next = res; - res = en; - res->ValidityDomain = EVALUE_DOMAIN(EP->x.p->arr[2*i]); - value_clear(EP->x.p->arr[2*i].d); - res->EP = EP->x.p->arr[2*i+1]; - } - free(EP->x.p); - value_clear(EP->d); - free(EP); - return res; + return partition2enumeration(EP); } static void SwapColumns(Value **V, int n, int i, int j) diff --git a/ev_operations.c b/ev_operations.c index 5512dcf..5b6a88d 100644 --- a/ev_operations.c +++ b/ev_operations.c @@ -2526,3 +2526,29 @@ void evalue_range_reduction(evalue *e) } } } + +/* Frees EP + */ +Enumeration* partition2enumeration(evalue *EP) +{ + int i; + Enumeration *en, *res = NULL; + + if (EVALUE_IS_ZERO(*EP)) { + free(EP); + return res; + } + + for (i = 0; i < EP->x.p->size/2; ++i) { + en = (Enumeration *)malloc(sizeof(Enumeration)); + en->next = res; + res = en; + res->ValidityDomain = EVALUE_DOMAIN(EP->x.p->arr[2*i]); + value_clear(EP->x.p->arr[2*i].d); + res->EP = EP->x.p->arr[2*i+1]; + } + free(EP->x.p); + value_clear(EP->d); + free(EP); + return res; +} diff --git a/ev_operations.h b/ev_operations.h index d6505b7..de28714 100644 --- a/ev_operations.h +++ b/ev_operations.h @@ -88,5 +88,6 @@ void evalue_combine(evalue *e); void evalue_range_reduction(evalue *e); size_t evalue_size(evalue *e); size_t domain_size(Polyhedron *D); +Enumeration* partition2enumeration(evalue *EP); #endif -- 2.11.4.GIT