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"
15 /* The input of this program is the same as that of the "polytope_scan"
16 * program from the barvinok distribution.
18 * Constraints of set is PolyLib format.
20 * The input set is assumed to be bounded.
24 struct isl_scan_callback callback;
25 struct isl_mat *samples;
28 static int scan_samples_add_sample(struct isl_scan_callback *cb,
29 __isl_take isl_vec *sample)
31 struct scan_samples *ss = (struct scan_samples *)cb;
33 ss->samples = isl_mat_extend(ss->samples, ss->samples->n_row + 1,
38 isl_seq_cpy(ss->samples->row[ss->samples->n_row - 1],
39 sample->el, sample->size);
48 static struct isl_mat *isl_basic_set_scan_samples(struct isl_basic_set *bset)
51 struct scan_samples ss;
53 dim = isl_basic_set_total_dim(bset);
54 ss.callback.add = scan_samples_add_sample;
55 ss.samples = isl_mat_alloc(bset->ctx, 0, 1 + dim);
59 if (isl_basic_set_scan(bset, &ss.callback) < 0) {
60 isl_mat_free(ss.samples);
66 isl_basic_set_free(bset);
70 static struct isl_mat *isl_basic_set_samples(struct isl_basic_set *bset)
73 struct isl_mat *samples;
76 return isl_basic_set_scan_samples(bset);
78 bset = isl_basic_set_remove_equalities(bset, &T, NULL);
79 samples = isl_basic_set_scan_samples(bset);
80 return isl_mat_product(samples, isl_mat_transpose(T));
83 int main(int argc, char **argv)
85 struct isl_ctx *ctx = isl_ctx_alloc();
86 struct isl_basic_set *bset;
87 struct isl_mat *samples;
89 bset = isl_basic_set_read_from_file(ctx, stdin, 0);
90 samples = isl_basic_set_samples(bset);
91 isl_mat_dump(samples, stdout, 0);
92 isl_mat_free(samples);