2 * Copyright 2008-2009 Katholieke Universiteit Leuven
4 * Use of this software is governed by the GNU LGPLv2.1 license
6 * Written by Sven Verdoolaege, K.U.Leuven, Departement
7 * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
11 #include "isl_equalities.h"
14 #include <isl_mat_private.h>
16 /* The input of this program is the same as that of the "polytope_scan"
17 * program from the barvinok distribution.
19 * Constraints of set is PolyLib format.
21 * The input set is assumed to be bounded.
25 struct isl_scan_callback callback;
26 struct isl_mat *samples;
29 static int scan_samples_add_sample(struct isl_scan_callback *cb,
30 __isl_take isl_vec *sample)
32 struct scan_samples *ss = (struct scan_samples *)cb;
34 ss->samples = isl_mat_extend(ss->samples, ss->samples->n_row + 1,
39 isl_seq_cpy(ss->samples->row[ss->samples->n_row - 1],
40 sample->el, sample->size);
49 static struct isl_mat *isl_basic_set_scan_samples(struct isl_basic_set *bset)
52 struct scan_samples ss;
54 dim = isl_basic_set_total_dim(bset);
55 ss.callback.add = scan_samples_add_sample;
56 ss.samples = isl_mat_alloc(bset->ctx, 0, 1 + dim);
60 if (isl_basic_set_scan(bset, &ss.callback) < 0) {
61 isl_mat_free(ss.samples);
67 isl_basic_set_free(bset);
71 static struct isl_mat *isl_basic_set_samples(struct isl_basic_set *bset)
74 struct isl_mat *samples;
80 return isl_basic_set_scan_samples(bset);
82 bset = isl_basic_set_remove_equalities(bset, &T, NULL);
83 samples = isl_basic_set_scan_samples(bset);
84 return isl_mat_product(samples, isl_mat_transpose(T));
87 int main(int argc, char **argv)
89 struct isl_ctx *ctx = isl_ctx_alloc();
90 struct isl_basic_set *bset;
91 struct isl_mat *samples;
93 bset = isl_basic_set_read_from_file(ctx, stdin, 0);
94 samples = isl_basic_set_samples(bset);
95 isl_mat_dump(samples, stdout, 0);
96 isl_mat_free(samples);