update isl-polylib for fix in header file
[barvinok.git] / sample.c
blob6e715f73d17e64f14ea71a811a971722bdc5dfc5
1 #include <assert.h>
2 #include <isl_set_polylib.h>
3 #include <barvinok/sample.h>
5 Vector *Polyhedron_Sample(Polyhedron *P, struct barvinok_options *options)
7 int i;
8 isl_ctx *ctx = isl_ctx_alloc();
9 isl_dim *dim;
10 int nvar = P->Dimension;
11 isl_basic_set *bset;
12 isl_point *pnt;
13 Vector *sample = NULL;
15 dim = isl_dim_set_alloc(ctx, 0, nvar);
16 bset = isl_basic_set_new_from_polylib(P, dim);
17 pnt = isl_basic_set_sample_point(bset);
19 if (!isl_point_is_void(pnt)) {
20 isl_int v;
22 isl_int_init(v);
23 sample = Vector_Alloc(1 + nvar);
24 assert(sample);
25 for (i = 0; i < nvar; ++i) {
26 isl_point_get_coordinate(pnt, isl_dim_set, i, &v);
27 isl_int_get_gmp(v, sample->p[i]);
29 value_set_si(sample->p[nvar], 1);
30 isl_int_clear(v);
33 isl_point_free(pnt);
35 isl_ctx_free(ctx);
37 return sample;