2 * Copyright 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 #define xCAT(A,B) A ## B
11 #define CAT(A,B) xCAT(A,B)
13 #define TYPE CAT(isl_,BASE)
14 #define xFN(TYPE,NAME) TYPE ## _ ## NAME
15 #define FN(TYPE,NAME) xFN(TYPE,NAME)
20 #define ARG1 isl_multi_pw_aff
25 #include "isl_align_params_templ.c"
27 /* Compute the pullback of "mpa" by the function represented by "fn".
28 * In other words, plug in "fn" in "mpa".
30 * If "mpa" has an explicit domain, then it is this domain
31 * that needs to undergo a pullback, i.e., a preimage.
33 __isl_give isl_multi_pw_aff
*FN(isl_multi_pw_aff_pullback
,BASE
)(
34 __isl_take isl_multi_pw_aff
*mpa
, __isl_take TYPE
*fn
)
38 isl_space
*space
= NULL
;
40 FN(isl_multi_pw_aff_align_params
,BASE
)(&mpa
, &fn
);
41 mpa
= isl_multi_pw_aff_cow(mpa
);
42 n
= isl_multi_pw_aff_size(mpa
);
46 space
= isl_space_join(FN(TYPE
,get_space
)(fn
),
47 isl_multi_pw_aff_get_space(mpa
));
49 for (i
= 0; i
< n
; ++i
) {
52 pa
= isl_multi_pw_aff_take_at(mpa
, i
);
53 pa
= FN(isl_pw_aff_pullback
,BASE
)(pa
, FN(TYPE
,copy
)(fn
));
54 mpa
= isl_multi_pw_aff_restore_at(mpa
, i
, pa
);
58 if (isl_multi_pw_aff_has_explicit_domain(mpa
)) {
59 mpa
->u
.dom
= FN(isl_set_preimage
,BASE
)(mpa
->u
.dom
,
66 isl_multi_pw_aff_restore_space(mpa
, space
);
69 isl_space_free(space
);
70 isl_multi_pw_aff_free(mpa
);