X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=isl_scan.c;h=bc239c8f11f11a2d23481cbcb6dd8b99d94a82b1;hb=ca90b151a05f17ccc1c3215ff24dc5d7b9198ff4;hp=c8eba377c8a2b89486f4acfb8c16b6e784fc00b0;hpb=d32aba8b9178a16b1f65c392cefbdc8312504890;p=platform%2Fupstream%2Fisl.git diff --git a/isl_scan.c b/isl_scan.c index c8eba37..bc239c8 100644 --- a/isl_scan.c +++ b/isl_scan.c @@ -1,17 +1,18 @@ /* * Copyright 2008-2009 Katholieke Universiteit Leuven * - * Use of this software is governed by the GNU LGPLv2.1 license + * Use of this software is governed by the MIT license * * Written by Sven Verdoolaege, K.U.Leuven, Departement * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium */ +#include +#include #include "isl_basis_reduction.h" #include "isl_scan.h" -#include "isl_seq.h" +#include #include "isl_tab.h" -#include struct isl_counter { struct isl_scan_callback callback; @@ -78,7 +79,7 @@ static int scan_0D(struct isl_basic_set *bset, return callback->add(callback, sample); } -/* Look for all integer points in "bset", which is assumed to be unbounded, +/* Look for all integer points in "bset", which is assumed to be bounded, * and call callback->add on each of them. * * We first compute a reduced basis for the set and then scan @@ -123,7 +124,7 @@ int isl_basic_set_scan(struct isl_basic_set *bset, if (!min || !max || !snap) goto error; - tab = isl_tab_from_basic_set(bset); + tab = isl_tab_from_basic_set(bset, 0); if (!tab) goto error; if (isl_tab_extend_cons(tab, dim + 1) < 0) @@ -242,6 +243,33 @@ error: return -1; } +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_count_upto(__isl_keep isl_set *set, isl_int max, isl_int *count) { struct isl_counter cnt = { { &increment_counter } };