Polly 20.0.0git
isl_pw_pullback_templ.c
Go to the documentation of this file.
1/*
2 * Copyright 2012 Ecole Normale Superieure
3 *
4 * Use of this software is governed by the MIT license
5 *
6 * Written by Sven Verdoolaege,
7 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
8 */
9
10#include <isl_pw_macro.h>
11
12#undef SUFFIX
13#define SUFFIX multi_aff
14#undef ARG1
15#define ARG1 PW
16#undef ARG2
17#define ARG2 isl_multi_aff
18
19static
21
22#undef SUFFIX
23#define SUFFIX pw_multi_aff
24#undef ARG1
25#define ARG1 PW
26#undef ARG2
27#define ARG2 isl_pw_multi_aff
28
29static
31
32/* Compute the pullback of "pw" by the function represented by "ma".
33 * In other words, plug in "ma" in "pw".
34 */
35__isl_give PW *FN(PW,pullback_multi_aff)(__isl_take PW *pw,
37{
38 int i;
39 isl_size n;
40 isl_space *space = NULL;
41
42 FN(PW,align_params_multi_aff)(&pw, &ma);
44 n = FN(PW,n_piece)(pw);
45 if (n < 0 || !ma)
46 goto error;
47
48 space = isl_space_join(isl_multi_aff_get_space(ma),
49 FN(PW,get_space)(pw));
50
51 for (i = 0; i < n; ++i) {
53 EL *el;
54
55 domain = FN(PW,take_domain_at)(pw, i);
57 isl_multi_aff_copy(ma));
58 pw = FN(PW,restore_domain_at)(pw, i, domain);
59 el = FN(PW,take_base_at)(pw, i);
60 el = FN(EL,pullback_multi_aff)(el, isl_multi_aff_copy(ma));
61 pw = FN(PW,restore_base_at)(pw, i, el);
62 }
63
64 pw = FN(PW,reset_space)(pw, space);
65 isl_multi_aff_free(ma);
66 return pw;
67error:
68 isl_space_free(space);
69 isl_multi_aff_free(ma);
70 FN(PW,free)(pw);
71 return NULL;
72}
73
74/* Compute the pullback of "pw" by the function represented by "pma".
75 * In other words, plug in "pma" in "pw".
76 */
77static __isl_give PW *FN(PW,pullback_pw_multi_aff_aligned)(__isl_take PW *pw,
79{
80 int i;
81 PW *res;
82
83 if (!pma)
84 goto error;
85
86 if (pma->n == 0) {
87 isl_space *space;
89 FN(PW,get_space)(pw));
91 res = FN(PW,empty)(space);
92 FN(PW,free)(pw);
93 return res;
94 }
95
96 res = FN(PW,pullback_multi_aff)(FN(PW,copy)(pw),
97 isl_multi_aff_copy(pma->p[0].maff));
98 res = FN(PW,intersect_domain)(res, isl_set_copy(pma->p[0].set));
99
100 for (i = 1; i < pma->n; ++i) {
101 PW *res_i;
102
103 res_i = FN(PW,pullback_multi_aff)(FN(PW,copy)(pw),
104 isl_multi_aff_copy(pma->p[i].maff));
105 res_i = FN(PW,intersect_domain)(res_i,
106 isl_set_copy(pma->p[i].set));
107 res = FN(PW,add_disjoint)(res, res_i);
108 }
109
111 FN(PW,free)(pw);
112 return res;
113error:
115 FN(PW,free)(pw);
116 return NULL;
117}
118
119__isl_give PW *FN(PW,pullback_pw_multi_aff)(__isl_take PW *pw,
121{
122 FN(PW,align_params_pw_multi_aff)(&pw, &pma);
123 return FN(PW,pullback_pw_multi_aff_aligned)(pw, pma);
124}
__isl_export __isl_give isl_space * isl_pw_multi_aff_get_space(__isl_keep isl_pw_multi_aff *pma)
__isl_null isl_pw_multi_aff * isl_pw_multi_aff_free(__isl_take isl_pw_multi_aff *pma)
struct isl_multi_aff isl_multi_aff
Definition: aff_type.h:29
#define FN(TYPE, NAME)
#define __isl_take
Definition: ctx.h:22
#define __isl_give
Definition: ctx.h:19
int isl_size
Definition: ctx.h:96
#define PW
Definition: isl_aff.c:4582
__isl_give isl_multi_aff * isl_multi_aff_align_divs(__isl_take isl_multi_aff *maff)
Definition: isl_aff.c:6139
#define EL
const char * ma
Definition: isl_test.c:7535
const char * pma
Definition: isl_test.c:3169
const char * res
Definition: isl_test.c:775
struct isl_set isl_set
Definition: map_type.h:26
__isl_overload __isl_give isl_set * isl_set_preimage_multi_aff(__isl_take isl_set *set, __isl_take isl_multi_aff *ma)
Definition: isl_map.c:14045
__isl_give isl_set * isl_set_copy(__isl_keep isl_set *set)
Definition: isl_map.c:1470
__isl_null isl_space * isl_space_free(__isl_take isl_space *space)
Definition: isl_space.c:445
__isl_give isl_space * isl_space_join(__isl_take isl_space *left, __isl_take isl_space *right)
Definition: isl_space.c:1504
static Signature domain
n
Definition: youcefn.c:8