2 * Copyright 2012-2013 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
10 #include <isl/space.h>
17 /* Construct an isl_multi_val living in "space" with all values equal to "val".
19 __isl_give isl_multi_val
*ppcg_multi_val_from_int(__isl_take isl_space
*space
,
30 ctx
= isl_space_get_ctx(space
);
31 n
= isl_space_dim(space
, isl_dim_set
);
32 mv
= isl_multi_val_zero(space
);
33 v
= isl_val_int_from_si(ctx
, val
);
34 for (i
= 0; i
< n
; ++i
)
35 mv
= isl_multi_val_set_val(mv
, i
, isl_val_copy(v
));
41 /* Construct an isl_multi_val living in "space" with values specified
42 * by "list". "list" is assumed to have at least as many entries
43 * as the set dimension of "space".
45 __isl_give isl_multi_val
*ppcg_multi_val_from_int_list(
46 __isl_take isl_space
*space
, int *list
)
55 ctx
= isl_space_get_ctx(space
);
56 n
= isl_space_dim(space
, isl_dim_set
);
57 mv
= isl_multi_val_zero(space
);
58 for (i
= 0; i
< n
; ++i
) {
61 v
= isl_val_int_from_si(ctx
, list
[i
]);
62 mv
= isl_multi_val_set_val(mv
, i
, v
);
68 /* Compute the size of a bounding box around the origin and "set",
69 * where "set" is assumed to contain only non-negative elements.
70 * In particular, compute the maximal value of "set" in each direction
73 __isl_give isl_multi_pw_aff
*ppcg_size_from_extent(__isl_take isl_set
*set
)
76 isl_multi_pw_aff
*mpa
;
78 n
= isl_set_dim(set
, isl_dim_set
);
79 mpa
= isl_multi_pw_aff_zero(isl_set_get_space(set
));
80 for (i
= 0; i
< n
; ++i
) {
85 if (!isl_set_dim_has_upper_bound(set
, isl_dim_set
, i
)) {
87 name
= isl_set_get_tuple_name(set
);
90 fprintf(stderr
, "unable to determine extent of '%s' "
91 "in dimension %d\n", name
, i
);
92 set
= isl_set_free(set
);
94 bound
= isl_set_dim_max(isl_set_copy(set
), i
);
96 space
= isl_pw_aff_get_domain_space(bound
);
97 one
= isl_aff_zero_on_domain(isl_local_space_from_space(space
));
98 one
= isl_aff_add_constant_si(one
, 1);
99 bound
= isl_pw_aff_add(bound
, isl_pw_aff_from_aff(one
));
100 mpa
= isl_multi_pw_aff_set_pw_aff(mpa
, i
, bound
);