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
)
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
));
40 isl_space_free(space
);
44 space
= isl_space_domain(space
);
45 ls
= isl_local_space_from_space(space
);
47 for (i
= 0; i
< n
; ++i
) {
49 el
= FN(EL
,var_on_domain
)(isl_local_space_copy(ls
),
51 multi
= FN(FN(MULTI(BASE
),set
),BASE
)(multi
, i
, el
);
54 isl_local_space_free(ls
);
58 isl_space_free(space
);