isl_val_is_pos: use isl_bool_ok
[isl.git] / isl_multi_identity_templ.c
blob59ad58c43bc88a6e9fa6c2b87c06bda16282b1ed
1 /*
2 * Copyright 2012 Ecole Normale Superieure
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege,
7 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
8 */
10 #include <isl/space.h>
11 #include <isl/local_space.h>
13 #include <isl_multi_macro.h>
15 /* Create a multi expression in the given space that maps each
16 * input dimension to the corresponding output dimension.
18 __isl_give MULTI(BASE) *FN(MULTI(BASE),identity)(__isl_take isl_space *space)
20 int i, n;
21 isl_local_space *ls;
22 MULTI(BASE) *multi;
24 if (!space)
25 return NULL;
27 if (isl_space_is_set(space))
28 isl_die(isl_space_get_ctx(space), isl_error_invalid,
29 "expecting map space", goto error);
31 n = isl_space_dim(space, isl_dim_out);
32 if (n != isl_space_dim(space, isl_dim_in))
33 isl_die(isl_space_get_ctx(space), isl_error_invalid,
34 "number of input and output dimensions needs to be "
35 "the same", goto error);
37 multi = FN(MULTI(BASE),alloc)(isl_space_copy(space));
39 if (!n) {
40 isl_space_free(space);
41 return multi;
44 space = isl_space_domain(space);
45 ls = isl_local_space_from_space(space);
47 for (i = 0; i < n; ++i) {
48 EL *el;
49 el = FN(EL,var_on_domain)(isl_local_space_copy(ls),
50 isl_dim_set, i);
51 multi = FN(FN(MULTI(BASE),set),BASE)(multi, i, el);
54 isl_local_space_free(ls);
56 return multi;
57 error:
58 isl_space_free(space);
59 return NULL;