From 6eab0709d5d12e25f5ae29ccc27a797b3035b808 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 25 Sep 2009 12:57:10 +0200 Subject: [PATCH] basis_reduction_tab.c: use isl_tab_product to construct product tableau Before, we would manually construct a tableau for the Cartesian product of a set with itself. Now, we first create a tableau for the set and then construct the product tableau. This should be more efficient and allows us to refactor the code to pass in a tableau instead of a set. --- basis_reduction_tab.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/basis_reduction_tab.c b/basis_reduction_tab.c index c4075a7..afe51fe 100644 --- a/basis_reduction_tab.c +++ b/basis_reduction_tab.c @@ -64,26 +64,20 @@ static struct isl_tab *gbr_tab(struct isl_basic_set *bset, int i, j; unsigned dim; struct isl_tab *tab; + struct isl_tab *prod; if (!bset || !row) return NULL; dim = isl_basic_set_total_dim(bset); - tab = isl_tab_alloc(bset->ctx, 2 * bset->n_ineq + 3 * dim + 1, 2 * dim, 0); - - for (i = 0; i < 2; ++i) { - isl_seq_clr(row->el + 1 + (1 - i) * dim, dim); - for (j = 0; j < bset->n_ineq; ++j) { - isl_int_set(row->el[0], bset->ineq[j][0]); - isl_seq_cpy(row->el + 1 + i * dim, - bset->ineq[j] + 1, dim); - tab = isl_tab_add_ineq(tab, row->el); - if (!tab || tab->empty) - return tab; - } + tab = isl_tab_from_basic_set(bset); + prod = isl_tab_product(tab, tab); + isl_tab_free(tab); + if (isl_tab_extend_cons(prod, 3 * dim + 1) < 0) { + isl_tab_free(prod); + return NULL; } - - return tab; + return prod; } static struct tab_lp *init_lp(struct isl_basic_set *bset) -- 2.7.4