+/*
+ * 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_mat.h"
#include "isl_vec.h"
+#include "isl_seq.h"
#include "isl_piplib.h"
#include "isl_sample_piplib.h"
-struct isl_vec *isl_pip_basic_set_sample(struct isl_ctx *ctx,
- struct isl_basic_set *bset)
+struct isl_vec *isl_pip_basic_set_sample(struct isl_basic_set *bset)
{
PipOptions *options = NULL;
PipMatrix *domain = NULL;
PipQuast *sol = NULL;
- struct isl_basic_map *bmap = (struct isl_basic_map *)bset;
struct isl_vec *vec = NULL;
unsigned dim;
+ struct isl_ctx *ctx;
- if (!bmap)
+ if (!bset)
goto error;
- dim = bmap->nparam + bmap->n_in + bmap->n_out;
- domain = isl_basic_map_to_pip(bmap, 0, 0, 0);
+ ctx = bset->ctx;
+ isl_assert(ctx, isl_basic_set_n_param(bset) == 0, goto error);
+ isl_assert(ctx, bset->n_div == 0, goto error);
+ dim = isl_basic_set_n_dim(bset);
+ domain = isl_basic_map_to_pip((struct isl_basic_map *)bset, 0, 0, 0);
if (!domain)
goto error;
options = pip_options_init();
if (!options)
goto error;
- options->Simplify = 1;
- options->Urs_unknowns = -1;
sol = pip_solve(domain, NULL, -1, options);
if (!sol)
goto error;
for (i = 0, l = sol->list; l && i < dim; ++i, l = l->next) {
isl_seq_cpy_from_pip(&vec->block.data[1+i],
&l->vector->the_vector[0], 1);
- if (entier_zero_p(l->vector->the_deno[0]))
- isl_int_set_si(vec->block.data[0], 0);
+ isl_assert(ctx, !entier_zero_p(l->vector->the_deno[0]),
+ goto error);
}
- if (i != dim)
- goto error;
+ isl_assert(ctx, i == dim, goto error);
}
pip_quast_free(sol);
pip_options_free(options);
pip_matrix_free(domain);
- isl_basic_map_free(ctx, bmap);
+ isl_basic_set_free(bset);
return vec;
error:
- isl_vec_free(ctx, vec);
- isl_basic_map_free(ctx, bmap);
+ isl_vec_free(vec);
+ isl_basic_set_free(bset);
if (sol)
pip_quast_free(sol);
if (domain)