37template <
typename A1,
typename R,
typename T>
44template <
typename A1,
typename R,
typename T>
54template <
typename A1,
typename A2,
typename R,
typename T>
61template <
typename A1,
typename A2,
typename R,
typename T>
97template <
typename T,
typename std::decay<
decltype(
98 std::declval<T>().is_equal(std::declval<T>()))>
::type =
true>
101 return a.is_equal(
b);
103template <
typename T,
typename std::decay<
decltype(
104 std::declval<T>().plain_is_equal(std::declval<T>()))>
::type =
true>
107 return a.plain_is_equal(
b);
112#define THROW_INVALID(msg) \
113 isl::exception::throw_error(isl_error_invalid, msg, __FILE__, __LINE__)
119template <
typename R,
typename T>
121 const std::vector<unary> &
tests)
127 std::ostringstream ss;
132 ss <<
name <<
"(" <<
test.arg <<
") =\n"
144template <
typename R,
typename T,
typename A1>
146 const std::vector<binary> &
tests)
153 std::ostringstream ss;
158 ss <<
name <<
"(" <<
test.arg1 <<
", " <<
test.arg2 <<
") =\n"
170template <
typename R,
typename T,
typename A1,
typename A2>
172 const std::string &
name,
const std::vector<ternary> &
tests)
180 std::ostringstream ss;
185 ss <<
name <<
"(" <<
test.arg1 <<
", " <<
test.arg2 <<
", "
186 <<
test.arg3 <<
") =\n"
197#define C(FN, ...) test(ctx, FN, #FN, __VA_ARGS__)
204 {
"{ A[] -> B[] }",
"{ A[] }" },
205 {
"{ A[C[] -> D[]] -> B[E[] -> F[]] }",
"{ A[C[] -> D[]] }" },
209 {
"{ A[] -> B[] }",
"{ B[] }" },
210 {
"{ A[C[] -> D[]] -> B[E[] -> F[]] }",
"{ B[E[] -> F[]] }" },
214 {
"{ A[] -> B[] }",
"{ : }" },
215 {
"{ A[C[] -> D[]] -> B[E[] -> F[]] }",
"{ : }" },
224 {
"[n] -> { [] : n >= 0 } ",
225 "[n] -> { [] : n >= 0 } " },
234 {
"{ B[i,j] : 0 <= i < 10 and 0 <= j < 100 }",
235 "{ A[j,i] -> B[i,j] }",
236 "{ A[j,i] : 0 <= i < 10 and 0 <= j < 100 }" },
237 {
"{ rat: B[i,j] : 0 <= i, j and 3 i + 5 j <= 100 }",
238 "{ A[a,b] -> B[a/2,b/6] }",
239 "{ rat: A[a,b] : 0 <= a, b and 9 a + 5 b <= 600 }" },
240 {
"{ B[i,j] : 0 <= i, j and 3 i + 5 j <= 100 }",
241 "{ A[a,b] -> B[a/2,b/6] }",
242 "{ A[a,b] : 0 <= a, b and 9 a + 5 b <= 600 and "
243 "exists i,j : a = 2 i and b = 6 j }" },
244 {
"[n] -> { S[i] : 0 <= i <= 100 }",
"[n] -> { S[n] }",
245 "[n] -> { : 0 <= n <= 100 }" },
246 {
"{ B[i] : 0 <= i < 100 and exists a : i = 4 a }",
248 "{ A[a] : 0 <= a < 50 and exists b : a = 2 b }" },
249 {
"{ B[i] : 0 <= i < 100 and exists a : i = 4 a }",
250 "{ A[a] -> B[([a/2])] }",
251 "{ A[a] : 0 <= a < 200 and exists b : [a/2] = 4 b }" },
252 {
"{ B[i,j,k] : 0 <= i,j,k <= 100 }",
253 "{ A[a] -> B[a,a,a/3] }",
254 "{ A[a] : 0 <= a <= 100 and exists b : a = 3 b }" },
255 {
"{ B[i,j] : j = [(i)/2] } ",
"{ A[i,j] -> B[i/3,j] }",
256 "{ A[i,j] : j = [(i)/6] and exists a : i = 3 a }" },
260 {
"{ B[i,j] -> C[2i + 3j] : 0 <= i < 10 and 0 <= j < 100 }",
261 "{ A[j,i] -> B[i,j] }",
262 "{ A[j,i] -> C[2i + 3j] : 0 <= i < 10 and 0 <= j < 100 }" },
263 {
"{ B[i] -> C[i]; D[i] -> E[i] }",
264 "{ A[i] -> B[i + 1] }",
265 "{ A[i] -> C[i + 1] }" },
266 {
"{ B[i] -> C[i]; B[i] -> E[i] }",
267 "{ A[i] -> B[i + 1] }",
268 "{ A[i] -> C[i + 1]; A[i] -> E[i + 1] }" },
269 {
"{ B[i] -> C[([i/2])] }",
271 "{ A[i] -> C[i] }" },
272 {
"{ B[i,j] -> C[([i/2]), ([(i+j)/3])] }",
273 "{ A[i] -> B[([i/5]), ([i/7])] }",
274 "{ A[i] -> C[([([i/5])/2]), ([(([i/5])+([i/7]))/3])] }" },
275 {
"[N] -> { B[i] -> C[([N/2]), i, ([N/3])] }",
276 "[N] -> { A[] -> B[([N/5])] }",
277 "[N] -> { A[] -> C[([N/2]), ([N/5]), ([N/3])] }" },
278 {
"{ B[i] -> C[i] : exists a : i = 5 a }",
280 "{ A[i] -> C[2i] : exists a : 2i = 5 a }" },
281 {
"{ B[i] -> C[i] : exists a : i = 2 a; "
282 "B[i] -> D[i] : exists a : i = 2 a + 1 }",
284 "{ A[i] -> C[2i] }" },
285 {
"{ A[i] -> B[i] }",
"{ C[i] -> A[(i + floor(i/3))/2] }",
286 "{ C[i] -> B[j] : 2j = i + floor(i/3) }" },
290 {
"[M] -> { A[a] -> B[a] }",
"[M] -> { C[] -> B[floor(M/2)] }",
291 "[M] -> { A[floor(M/2)] -> C[] }" },
300 {
"{ [i] -> [i + 1] }",
"23",
301 "{ [i] -> [i + 23] }" },
302 {
"{ [a = 0:1, b = 0:15, c = 0:1, d = 0:1, 0] -> [a, b, c, d, 1]; "
303 "[a = 0:1, b = 0:15, c = 0:1, 0, 1] -> [a, b, c, 1, 0]; "
304 "[a = 0:1, b = 0:15, 0, 1, 1] -> [a, b, 1, 0, 0]; "
305 "[a = 0:1, b = 0:14, 1, 1, 1] -> [a, 1 + b, 0, 0, 0]; "
306 "[0, 15, 1, 1, 1] -> [1, 0, 0, 0, 0] }",
308 "{ [0, b = 0:15, c = 0:1, d = 0:1, e = 0:1] -> [1, b, c, d, e] }" },
316 C(&isl::union_map::intersect_domain_wrapped_domain, {
317 {
"{ [A[x] -> B[y]] -> C[z]; [D[x] -> A[y]] -> E[z] }",
319 "{ [A[0] -> B[y]] -> C[z] }" },
320 {
"{ C[z] -> [A[x] -> B[y]]; E[z] -> [D[x] -> A[y]] }",
325 C(&isl::union_map::intersect_range_wrapped_domain, {
326 {
"{ [A[x] -> B[y]] -> C[z]; [D[x] -> A[y]] -> E[z] }",
329 {
"{ C[z] -> [A[x] -> B[y]]; E[z] -> [D[x] -> A[y]] }",
331 "{ C[z] -> [A[0] -> B[y]] }" },
339 C(&isl::pw_aff::gist_params, {
340 {
"[N] -> { D[x] -> [x] : N >= 0; D[x] -> [0] : N < 0 }",
341 "[N] -> { : N >= 0 }",
342 "[N] -> { D[x] -> [x] }" },
350 C(arg<isl::id>(&isl::union_map::project_out_param), {
351 {
"[N] -> { D[i] -> A[0:N-1]; D[i] -> B[i] }",
"N",
352 "{ D[i] -> A[0:]; D[i] -> B[i] }" },
353 {
"[N] -> { D[i] -> A[0:N-1]; D[i] -> B[i] }",
"M",
354 "[N] -> { D[i] -> A[0:N-1]; D[i] -> B[i] }" },
357 C(arg<isl::id_list>(&isl::union_map::project_out_param), {
358 {
"[M, N, O] -> { D[i] -> A[j] : i <= j < M, N, O }",
"(M, N)",
359 "[O] -> { D[i] -> A[j] : i <= j < O }" },
368 {
"{ A[a] -> B[a, a + 1, a - 1] : a >= 0 }",
"{ B[2, 7, 0] }",
369 "{ A[a] -> B[2a, 7a + 7, 0] : a >= 0 }" },
372 {
"{ A[a] -> B[1, a - 1] : a >= 0 }",
"{ B[1/2, 7] }",
373 "{ A[a] -> B[1/2, 7a - 7] : a >= 0 }" },
377 {
"{ A[a] -> B[a, a + 1] : a >= 0 }",
"{ B[2, 7] }",
378 "{ A[a] -> B[a/2, (a + 1)/7] : a >= 0 }" },
381 {
"{ A[a] -> B[a, a - 1] : a >= 0 }",
"{ B[2, 1/7] }",
382 "{ A[a] -> B[a/2, 7a - 7] : a >= 0 }" },
390 C((arg<isl::id, isl::id>(&isl::id_to_id::set)), {
393 {
"{ a: b }",
"a",
"b",
395 {
"{ a: c }",
"a",
"b",
397 {
"{ a: b }",
"b",
"a",
399 {
"{ a: b }",
"b",
"a",
423 int ret = EXIT_SUCCESS;
427 options = isl_options_new_with_defaults();
433 for (
const auto &
f :
tests) {
434 std::cout <<
f.first <<
"\n";
437 }
catch (
const isl::exception &e) {
438 std::cerr << e.what() <<
"\n";
isl::union_map fixed_power(const isl::val &exp) const
isl::multi_pw_aff scale_down(const isl::multi_val &mv) const
isl::multi_pw_aff scale(const isl::multi_val &mv) const
isl::set preimage(isl::multi_aff ma) const
isl::space params() const
isl::space domain() const
isl::union_map preimage_domain(isl::multi_aff ma) const
isl::union_map preimage_range(isl::multi_aff ma) const
isl_ctx * isl_ctx_alloc_with_options(struct isl_args *args, __isl_take void *opt)
void isl_ctx_free(isl_ctx *ctx)
isl_stat isl_stat(* fn)(__isl_take ISL_KEY *key, __isl_take ISL_VAL *val, void *user)
isl_bool isl_bool(* test)(__isl_keep ISL_KEY *key, __isl_keep ISL_VAL *val, void *user)
static void test_preimage(isl::ctx ctx)
R(T::*)(A1, A2) const ternary_fn
static void test_id_to_id(isl::ctx ctx)
R(T::*)(A1) const binary_fn
static void test_project(isl::ctx ctx)
#define THROW_INVALID(msg)
static void test_gist(isl::ctx ctx)
static std::vector< std::pair< const char *, void(*)(isl::ctx)> > tests
static void test_intersect(isl::ctx ctx)
static bool is_equal(const T &a, const T &b)
static void test_scale(isl::ctx ctx)
static void test_space(isl::ctx ctx)
static void test_conversion(isl::ctx ctx)
static void test_fixed_power(isl::ctx ctx)