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
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
)
28 if (isl_space_is_set(space
))
29 isl_die(isl_space_get_ctx(space
), isl_error_invalid
,
30 "expecting map space", goto error
);
32 n_in
= isl_space_dim(space
, isl_dim_in
);
33 n_out
= isl_space_dim(space
, isl_dim_out
);
34 if (n_in
< 0 || n_out
< 0)
37 isl_die(isl_space_get_ctx(space
), isl_error_invalid
,
38 "number of input and output dimensions needs to be "
39 "the same", goto error
);
41 multi
= FN(MULTI(BASE
),alloc
)(isl_space_copy(space
));
44 isl_space_free(space
);
48 space
= isl_space_domain(space
);
49 ls
= isl_local_space_from_space(space
);
51 for (i
= 0; i
< n_out
; ++i
) {
53 el
= FN(EL
,var_on_domain
)(isl_local_space_copy(ls
),
55 multi
= FN(FN(MULTI(BASE
),set
),BASE
)(multi
, i
, el
);
58 isl_local_space_free(ls
);
62 isl_space_free(space
);
66 /* Create a multi expression that maps elements in the given space
69 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),identity_on_domain_space
)(
70 __isl_take isl_space
*space
)
72 return FN(MULTI(BASE
),identity
)(isl_space_map_from_set(space
));
75 /* This function performs the same operation as
76 * isl_multi_*_identity_on_domain_space,
77 * but is considered as a function on an isl_space when exported.
79 __isl_give
MULTI(BASE
) *FN(FN(isl_space_identity_multi
,BASE
),on_domain
)(
80 __isl_take isl_space
*space
)
82 return FN(MULTI(BASE
),identity_on_domain_space
)(space
);
85 /* Create a multi expression in the same space as "multi" that maps each
86 * input dimension to the corresponding output dimension.
88 __isl_give
MULTI(BASE
) *FN(FN(MULTI(BASE
),identity_multi
),BASE
)(
89 __isl_take
MULTI(BASE
) *multi
)
93 space
= FN(MULTI(BASE
),get_space
)(multi
);
94 FN(MULTI(BASE
),free
)(multi
);
95 return FN(MULTI(BASE
),identity
)(space
);