barvinok.cc: ienumerator::ienumerator: drop redundant argument
[barvinok.git] / sample.c
blob086add5222dd0d731f2da27d590ea98f7a1ce1aa
1 #include <assert.h>
2 #include <isl/val_gmp.h>
3 #include <isl_set_polylib.h>
4 #include <barvinok/sample.h>
6 Vector *Polyhedron_Sample(Polyhedron *P, struct barvinok_options *options)
8 int i;
9 isl_ctx *ctx = isl_ctx_alloc();
10 isl_space *dim;
11 int nvar = P->Dimension;
12 isl_basic_set *bset;
13 isl_point *pnt;
14 Vector *sample = NULL;
16 dim = isl_space_set_alloc(ctx, 0, nvar);
17 bset = isl_basic_set_new_from_polylib(P, dim);
18 pnt = isl_basic_set_sample_point(bset);
20 if (!isl_point_is_void(pnt)) {
21 isl_val *v;
23 sample = Vector_Alloc(1 + nvar);
24 assert(sample);
25 for (i = 0; i < nvar; ++i) {
26 v = isl_point_get_coordinate_val(pnt, isl_dim_set, i);
27 isl_val_get_num_gmp(v, sample->p[i]);
28 isl_val_free(v);
30 value_set_si(sample->p[nvar], 1);
33 isl_point_free(pnt);
35 isl_ctx_free(ctx);
37 return sample;