1 | #include <stdio.h> |
2 | #include <isl_int.h> |
3 | #include <isl/map.h> |
4 | #include <isl/mat.h> |
5 | #include <isl_morph.h> |
6 | #include <isl/polynomial.h> |
7 | #include <isl_reordering.h> |
8 | #include "isl_list_private.h" |
9 | |
10 | struct isl_poly { |
11 | int ref; |
12 | struct isl_ctx *ctx; |
13 | |
14 | int var; |
15 | }; |
16 | typedef struct isl_poly isl_poly; |
17 | |
18 | struct isl_poly_cst { |
19 | struct isl_poly poly; |
20 | isl_int n; |
21 | isl_int d; |
22 | }; |
23 | typedef struct isl_poly_cst isl_poly_cst; |
24 | |
25 | struct isl_poly_rec { |
26 | struct isl_poly poly; |
27 | int n; |
28 | |
29 | size_t size; |
30 | isl_poly *p[]; |
31 | }; |
32 | typedef struct isl_poly_rec isl_poly_rec; |
33 | |
34 | /* dim represents the domain space. |
35 | */ |
36 | struct isl_qpolynomial { |
37 | int ref; |
38 | |
39 | isl_space *dim; |
40 | struct isl_mat *div; |
41 | isl_poly *poly; |
42 | }; |
43 | |
44 | #undef EL |
45 | #define EL isl_qpolynomial |
46 | |
47 | #include <isl_list_templ.h> |
48 | |
49 | struct isl_term { |
50 | int ref; |
51 | |
52 | isl_int n; |
53 | isl_int d; |
54 | |
55 | isl_space *dim; |
56 | struct isl_mat *div; |
57 | |
58 | int pow[1]; |
59 | }; |
60 | |
61 | struct isl_pw_qpolynomial_piece { |
62 | struct isl_set *set; |
63 | struct isl_qpolynomial *qp; |
64 | }; |
65 | |
66 | struct isl_pw_qpolynomial { |
67 | int ref; |
68 | |
69 | isl_space *dim; |
70 | |
71 | int n; |
72 | |
73 | size_t size; |
74 | struct isl_pw_qpolynomial_piece p[1]; |
75 | }; |
76 | |
77 | #undef PW |
78 | #define PW isl_pw_qpolynomial |
79 | |
80 | #include <isl_pw_templ.h> |
81 | |
82 | #undef EL |
83 | #define EL isl_pw_qpolynomial |
84 | |
85 | #include <isl_list_templ.h> |
86 | |
87 | /* dim represents the domain space. |
88 | */ |
89 | struct isl_qpolynomial_fold { |
90 | int ref; |
91 | |
92 | enum isl_fold type; |
93 | isl_space *dim; |
94 | |
95 | isl_qpolynomial_list *list; |
96 | }; |
97 | |
98 | struct isl_pw_qpolynomial_fold_piece { |
99 | struct isl_set *set; |
100 | struct isl_qpolynomial_fold *fold; |
101 | }; |
102 | |
103 | struct isl_pw_qpolynomial_fold { |
104 | int ref; |
105 | |
106 | enum isl_fold type; |
107 | isl_space *dim; |
108 | |
109 | int n; |
110 | |
111 | size_t size; |
112 | struct isl_pw_qpolynomial_fold_piece p[1]; |
113 | }; |
114 | |
115 | #undef PW |
116 | #define PW isl_pw_qpolynomial_fold |
117 | |
118 | #include <isl_pw_templ.h> |
119 | |
120 | #undef EL |
121 | #define EL isl_pw_qpolynomial_fold |
122 | |
123 | #include <isl_list_templ.h> |
124 | |
125 | void isl_term_get_num(__isl_keep isl_term *term, isl_int *n); |
126 | |
127 | __isl_give isl_poly *isl_poly_zero(struct isl_ctx *ctx); |
128 | __isl_give isl_poly *isl_poly_copy(__isl_keep isl_poly *poly); |
129 | __isl_give isl_poly *isl_poly_cow(__isl_take isl_poly *poly); |
130 | __isl_give isl_poly *isl_poly_dup(__isl_keep isl_poly *poly); |
131 | __isl_null isl_poly *isl_poly_free(__isl_take isl_poly *poly); |
132 | __isl_give struct isl_poly *isl_poly_mul(__isl_take struct isl_poly *poly1, |
133 | __isl_take struct isl_poly *poly2); |
134 | |
135 | isl_bool isl_poly_is_cst(__isl_keep isl_poly *poly); |
136 | isl_bool isl_poly_is_zero(__isl_keep isl_poly *poly); |
137 | isl_bool isl_poly_is_one(__isl_keep isl_poly *poly); |
138 | isl_bool isl_poly_is_negone(__isl_keep isl_poly *poly); |
139 | __isl_keep isl_poly_cst *isl_poly_as_cst(__isl_keep isl_poly *poly); |
140 | __isl_keep isl_poly_rec *isl_poly_as_rec(__isl_keep isl_poly *poly); |
141 | |
142 | __isl_give isl_poly *isl_poly_sum(__isl_take isl_poly *poly1, |
143 | __isl_take isl_poly *poly2); |
144 | __isl_give struct isl_poly *isl_poly_mul_isl_int( |
145 | __isl_take isl_poly *poly, isl_int v); |
146 | |
147 | __isl_give isl_qpolynomial *isl_qpolynomial_alloc(__isl_take isl_space *space, |
148 | unsigned n_div, __isl_take isl_poly *poly); |
149 | __isl_give isl_qpolynomial *isl_qpolynomial_cow(__isl_take isl_qpolynomial *qp); |
150 | __isl_give isl_qpolynomial *isl_qpolynomial_dup(__isl_keep isl_qpolynomial *qp); |
151 | |
152 | __isl_give isl_qpolynomial *isl_qpolynomial_cst_on_domain( |
153 | __isl_take isl_space *domain, |
154 | isl_int v); |
155 | __isl_give isl_qpolynomial *isl_qpolynomial_rat_cst_on_domain( |
156 | __isl_take isl_space *domain, const isl_int n, const isl_int d); |
157 | __isl_give isl_qpolynomial *isl_qpolynomial_var_pow_on_domain( |
158 | __isl_take isl_space *domain, |
159 | int pos, int power); |
160 | isl_bool isl_qpolynomial_is_one(__isl_keep isl_qpolynomial *qp); |
161 | isl_bool isl_qpolynomial_is_affine(__isl_keep isl_qpolynomial *qp); |
162 | isl_bool isl_qpolynomial_is_cst(__isl_keep isl_qpolynomial *qp, |
163 | isl_int *n, isl_int *d); |
164 | |
165 | unsigned isl_qpolynomial_domain_offset(__isl_keep isl_qpolynomial *qp, |
166 | enum isl_dim_type type); |
167 | |
168 | __isl_give isl_qpolynomial *isl_qpolynomial_add_on_domain( |
169 | __isl_keep isl_set *dom, |
170 | __isl_take isl_qpolynomial *qp1, |
171 | __isl_take isl_qpolynomial *qp2); |
172 | |
173 | int isl_qpolynomial_plain_cmp(__isl_keep isl_qpolynomial *qp1, |
174 | __isl_keep isl_qpolynomial *qp2); |
175 | |
176 | int isl_qpolynomial_degree(__isl_keep isl_qpolynomial *poly); |
177 | __isl_give isl_qpolynomial *isl_qpolynomial_coeff( |
178 | __isl_keep isl_qpolynomial *poly, |
179 | enum isl_dim_type type, unsigned pos, int deg); |
180 | |
181 | __isl_give isl_vec *( |
182 | __isl_keep isl_qpolynomial *qp); |
183 | __isl_give isl_qpolynomial *isl_qpolynomial_from_affine( |
184 | __isl_take isl_space *space, isl_int *f, isl_int denom); |
185 | |
186 | __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_cow( |
187 | __isl_take isl_pw_qpolynomial *pwqp); |
188 | |
189 | __isl_keep isl_qpolynomial *isl_pw_qpolynomial_peek_base_at( |
190 | __isl_keep isl_pw_qpolynomial *pwqp, int pos); |
191 | |
192 | __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add_piece( |
193 | __isl_take isl_pw_qpolynomial *pwqp, |
194 | __isl_take isl_set *set, __isl_take isl_qpolynomial *qp); |
195 | int isl_pw_qpolynomial_is_one(__isl_keep isl_pw_qpolynomial *pwqp); |
196 | |
197 | __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_project_out( |
198 | __isl_take isl_pw_qpolynomial *pwqp, |
199 | enum isl_dim_type type, unsigned first, unsigned n); |
200 | |
201 | __isl_give isl_val *isl_qpolynomial_opt_on_domain( |
202 | __isl_take isl_qpolynomial *qp, __isl_take isl_set *set, int max); |
203 | |
204 | enum isl_fold isl_fold_type_negate(enum isl_fold type); |
205 | |
206 | __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_cow( |
207 | __isl_take isl_qpolynomial_fold *fold); |
208 | __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_dup( |
209 | __isl_keep isl_qpolynomial_fold *fold); |
210 | |
211 | __isl_keep isl_qpolynomial_list *isl_qpolynomial_fold_peek_list( |
212 | __isl_keep isl_qpolynomial_fold *fold); |
213 | |
214 | __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_cow( |
215 | __isl_take isl_pw_qpolynomial_fold *pwf); |
216 | |
217 | __isl_keep isl_qpolynomial_fold *isl_pw_qpolynomial_fold_peek_base_at( |
218 | __isl_keep isl_pw_qpolynomial_fold *pwf, int pos); |
219 | |
220 | __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_add_on_domain( |
221 | __isl_keep isl_set *set, |
222 | __isl_take isl_qpolynomial_fold *fold1, |
223 | __isl_take isl_qpolynomial_fold *fold2); |
224 | __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_fold_on_domain( |
225 | __isl_keep isl_set *set, |
226 | __isl_take isl_qpolynomial_fold *fold1, |
227 | __isl_take isl_qpolynomial_fold *fold2); |
228 | |
229 | int isl_qpolynomial_fold_plain_cmp(__isl_keep isl_qpolynomial_fold *fold1, |
230 | __isl_keep isl_qpolynomial_fold *fold2); |
231 | |
232 | __isl_give isl_val *isl_qpolynomial_fold_opt_on_domain( |
233 | __isl_take isl_qpolynomial_fold *fold, __isl_take isl_set *set, int max); |
234 | |
235 | isl_bool isl_pw_qpolynomial_fold_covers( |
236 | __isl_keep isl_pw_qpolynomial_fold *pwf1, |
237 | __isl_keep isl_pw_qpolynomial_fold *pwf2); |
238 | |
239 | __isl_give isl_qpolynomial *isl_qpolynomial_morph_domain( |
240 | __isl_take isl_qpolynomial *qp, __isl_take isl_morph *morph); |
241 | __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_morph_domain( |
242 | __isl_take isl_pw_qpolynomial *pwqp, __isl_take isl_morph *morph); |
243 | __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_morph_domain( |
244 | __isl_take isl_qpolynomial_fold *fold, __isl_take isl_morph *morph); |
245 | __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_morph_domain( |
246 | __isl_take isl_pw_qpolynomial_fold *pwf, __isl_take isl_morph *morph); |
247 | |
248 | __isl_give isl_qpolynomial *isl_qpolynomial_lift(__isl_take isl_qpolynomial *qp, |
249 | __isl_take isl_space *space); |
250 | __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_lift( |
251 | __isl_take isl_qpolynomial_fold *fold, __isl_take isl_space *space); |
252 | |
253 | __isl_give isl_qpolynomial *isl_qpolynomial_substitute_equalities( |
254 | __isl_take isl_qpolynomial *qp, __isl_take isl_basic_set *eq); |
255 | __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_substitute_equalities( |
256 | __isl_take isl_qpolynomial_fold *fold, __isl_take isl_basic_set *eq); |
257 | __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_gist( |
258 | __isl_take isl_qpolynomial_fold *fold, __isl_take isl_set *context); |
259 | |
260 | __isl_give isl_qpolynomial *isl_qpolynomial_realign_domain( |
261 | __isl_take isl_qpolynomial *qp, __isl_take isl_reordering *r); |
262 | __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_realign_domain( |
263 | __isl_take isl_qpolynomial_fold *fold, __isl_take isl_reordering *r); |
264 | |
265 | __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_reset_space( |
266 | __isl_take isl_pw_qpolynomial *pwqp, __isl_take isl_space *space); |
267 | __isl_give isl_qpolynomial *isl_qpolynomial_reset_domain_space( |
268 | __isl_take isl_qpolynomial *qp, __isl_take isl_space *space); |
269 | __isl_give isl_qpolynomial *isl_qpolynomial_reset_space_and_domain( |
270 | __isl_take isl_qpolynomial *qp, __isl_take isl_space *space, |
271 | __isl_take isl_space *domain); |
272 | __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_reset_domain_space( |
273 | __isl_take isl_qpolynomial_fold *fold, __isl_take isl_space *space); |
274 | __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_reset_space_and_domain( |
275 | __isl_take isl_qpolynomial_fold *fold, __isl_take isl_space *space, |
276 | __isl_take isl_space *domain); |
277 | __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_reset_domain_space( |
278 | __isl_take isl_pw_qpolynomial_fold *pwf, __isl_take isl_space *space); |
279 | |
280 | __isl_give isl_val *isl_qpolynomial_get_den(__isl_keep isl_qpolynomial *qp); |
281 | __isl_give isl_qpolynomial *isl_qpolynomial_add_isl_int( |
282 | __isl_take isl_qpolynomial *qp, isl_int v); |
283 | __isl_give isl_qpolynomial *isl_qpolynomial_mul_isl_int( |
284 | __isl_take isl_qpolynomial *qp, isl_int v); |
285 | |
286 | __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_scale( |
287 | __isl_take isl_qpolynomial_fold *fold, isl_int v); |
288 | |
289 | __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_mul_isl_int( |
290 | __isl_take isl_qpolynomial_fold *fold, isl_int v); |
291 | |
292 | ISL_DECLARE_LIST_FN_PRIVATE(qpolynomial) |
293 | |