isl_test.c: test_coalesce_special2: extract out test_coalesce_union
[isl.git] / isl_multi_zero_templ.c
blobdee3a8fb2646d29bdca30a26f2dc76f5887276e5
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 /* Construct a multi expression in the given space with value zero in
16 * each of the output dimensions.
18 __isl_give MULTI(BASE) *FN(MULTI(BASE),zero)(__isl_take isl_space *space)
20 isl_size n;
21 MULTI(BASE) *multi;
23 n = isl_space_dim(space , isl_dim_out);
24 if (n < 0)
25 goto error;
27 multi = FN(MULTI(BASE),alloc)(isl_space_copy(space));
29 if (!n)
30 isl_space_free(space);
31 else {
32 int i;
33 isl_local_space *ls;
34 EL *el;
36 space = isl_space_domain(space);
37 ls = isl_local_space_from_space(space);
38 el = FN(EL,zero_on_domain)(ls);
40 for (i = 0; i < n; ++i)
41 multi = FN(FN(MULTI(BASE),set),BASE)(multi, i,
42 FN(EL,copy)(el));
44 FN(EL,free)(el);
47 return multi;
48 error:
49 isl_space_free(space);
50 return NULL;
53 #include "isl_multi_zero_space_templ.c"