static __isl_give isl_mat *isl_basic_set_scan_samples( __isl_take isl_basic_set *bset) { isl_ctx *ctx; isl_size dim; struct scan_samples ss; ctx = isl_basic_set_get_ctx(bset); dim = isl_basic_set_dim(bset, isl_dim_all); if (dim < 0) goto error; ss.callback.add = scan_samples_add_sample; ss.samples = isl_mat_alloc(ctx, 0, 1 + dim); if (!ss.samples) goto error; if (isl_basic_set_scan(bset, &ss.callback) < 0) { isl_mat_free(ss.samples); return NULL; } return ss.samples; error: isl_basic_set_free(bset); return NULL; }
int isl_basic_set_count_upto(__isl_keep isl_basic_set *bset, isl_int max, isl_int *count) { struct isl_counter cnt = { { &increment_counter } }; if (!bset) return -1; isl_int_init(cnt.count); isl_int_init(cnt.max); isl_int_set_si(cnt.count, 0); isl_int_set(cnt.max, max); if (isl_basic_set_scan(isl_basic_set_copy(bset), &cnt.callback) < 0 && isl_int_lt(cnt.count, cnt.max)) goto error; isl_int_set(*count, cnt.count); isl_int_clear(cnt.max); isl_int_clear(cnt.count); return 0; error: isl_int_clear(cnt.count); return -1; }
int isl_set_foreach_point(__isl_keep isl_set *set, int (*fn)(__isl_take isl_point *pnt, void *user), void *user) { struct isl_foreach_point fp = { { &foreach_point }, fn, user }; int i; if (!set) return -1; fp.dim = isl_set_get_dim(set); if (!fp.dim) return -1; set = isl_set_copy(set); set = isl_set_cow(set); set = isl_set_make_disjoint(set); set = isl_set_compute_divs(set); if (!set) goto error; for (i = 0; i < set->n; ++i) if (isl_basic_set_scan(isl_basic_set_copy(set->p[i]), &fp.callback) < 0) goto error; isl_set_free(set); isl_dim_free(fp.dim); return 0; error: isl_set_free(set); isl_dim_free(fp.dim); return -1; }
static struct isl_mat *isl_basic_set_scan_samples(struct isl_basic_set *bset) { isl_ctx *ctx; unsigned dim; struct scan_samples ss; ctx = isl_basic_set_get_ctx(bset); dim = isl_basic_set_total_dim(bset); ss.callback.add = scan_samples_add_sample; ss.samples = isl_mat_alloc(ctx, 0, 1 + dim); if (!ss.samples) goto error; if (isl_basic_set_scan(bset, &ss.callback) < 0) { isl_mat_free(ss.samples); return NULL; } return ss.samples; error: isl_basic_set_free(bset); return NULL; }
int isl_set_scan(__isl_take isl_set *set, struct isl_scan_callback *callback) { int i; if (!set || !callback) goto error; set = isl_set_cow(set); set = isl_set_make_disjoint(set); set = isl_set_compute_divs(set); if (!set) goto error; for (i = 0; i < set->n; ++i) if (isl_basic_set_scan(isl_basic_set_copy(set->p[i]), callback) < 0) goto error; isl_set_free(set); return 0; error: isl_set_free(set); return -1; }