+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ *
+ * Use of this software is governed by the GNU LGPLv2.1 license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ */
+
#include "isl_ctx.h"
#include "isl_seq.h"
#include "isl_set.h"
static struct isl_vec *outside_point(struct isl_tab *tab, isl_int *eq, int up)
{
struct isl_ctx *ctx;
- struct isl_vec *sample;
+ struct isl_vec *sample = NULL;
struct isl_tab_undo *snap;
unsigned dim;
int k;
return NULL;
isl_int_set_si(sample->el[0], 1);
isl_seq_combine(sample->el + 1,
- ctx->one, tab->bset->sample->el + 1,
+ ctx->one, tab->bmap->sample->el + 1,
up ? ctx->one : ctx->negone, eq + 1, dim);
- if (isl_basic_set_contains(tab->bset, sample))
+ if (isl_basic_map_contains(tab->bmap, sample))
return sample;
isl_vec_free(sample);
sample = NULL;
if (isl_tab_extend_cons(tab, 1) < 0)
goto error;
- tab = isl_tab_add_ineq(tab, eq);
+ if (isl_tab_add_ineq(tab, eq) < 0)
+ goto error;
sample = isl_tab_sample(tab);
tab = isl_tab_from_basic_set(bset);
if (!tab)
goto error;
- tab->bset = isl_basic_set_copy(bset);
+ if (tab->empty) {
+ isl_tab_free(tab);
+ isl_vec_free(sample);
+ return isl_basic_set_set_to_empty(bset);
+ }
+ if (isl_tab_track_bset(tab, isl_basic_set_copy(bset)) < 0)
+ goto error;
if (!sample) {
struct isl_tab_undo *snap;
sample = isl_tab_sample(tab);
if (isl_tab_rollback(tab, snap) < 0)
goto error;
- isl_vec_free(tab->bset->sample);
- tab->bset->sample = isl_vec_copy(sample);
+ isl_vec_free(tab->bmap->sample);
+ tab->bmap->sample = isl_vec_copy(sample);
}
if (!sample)
isl_mat_free(tab->basis);
tab->basis = NULL;
- isl_assert(tab->mat->ctx, tab->bset, goto error);
+ isl_assert(tab->mat->ctx, tab->bmap, goto error);
isl_assert(tab->mat->ctx, tab->samples, goto error);
isl_assert(tab->mat->ctx, tab->samples->n_col == 1 + tab->n_var, goto error);
isl_assert(tab->mat->ctx, tab->n_sample > tab->n_outside, goto error);
isl_seq_cpy(sample->el, tab->samples->row[tab->n_outside], sample->size);
- isl_vec_free(tab->bset->sample);
- tab->bset->sample = isl_vec_copy(sample);
+ isl_vec_free(tab->bmap->sample);
+ tab->bmap->sample = isl_vec_copy(sample);
if (tab->n_unbounded == 0)
hull = isl_basic_set_from_vec(isl_vec_copy(sample));