2 * Copyright 2010 INRIA Saclay
4 * Use of this software is governed by the GNU LGPLv2.1 license
6 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
7 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
19 __isl_give isl_int_obj *isl_int_obj_alloc(isl_ctx *ctx, isl_int v)
23 i = isl_alloc_type(ctx, isl_int_obj);
36 __isl_give isl_int_obj *isl_int_obj_copy(__isl_keep isl_int_obj *i)
45 __isl_give isl_int_obj *isl_int_obj_dup(__isl_keep isl_int_obj *i)
50 return isl_int_obj_alloc(i->ctx, i->v);
53 __isl_give isl_int_obj *isl_int_obj_cow(__isl_take isl_int_obj *i)
61 return isl_int_obj_dup(i);
64 void isl_int_obj_free(__isl_take isl_int_obj *i)
72 isl_ctx_deref(i->ctx);
77 __isl_give isl_int_obj *isl_int_obj_add(__isl_take isl_int_obj *i1,
78 __isl_take isl_int_obj *i2)
80 i1 = isl_int_obj_cow(i1);
84 isl_int_add(i1->v, i1->v, i2->v);
94 __isl_give isl_int_obj *isl_int_obj_sub(__isl_take isl_int_obj *i1,
95 __isl_take isl_int_obj *i2)
97 i1 = isl_int_obj_cow(i1);
101 isl_int_sub(i1->v, i1->v, i2->v);
103 isl_int_obj_free(i2);
106 isl_int_obj_free(i1);
107 isl_int_obj_free(i2);
111 __isl_give isl_int_obj *isl_int_obj_mul(__isl_take isl_int_obj *i1,
112 __isl_take isl_int_obj *i2)
114 i1 = isl_int_obj_cow(i1);
118 isl_int_mul(i1->v, i1->v, i2->v);
120 isl_int_obj_free(i2);
123 isl_int_obj_free(i1);
124 isl_int_obj_free(i2);
128 void isl_int_obj_get_int(__isl_keep isl_int_obj *i, isl_int *v)
132 isl_int_set(*v, i->v);
135 static void *isl_obj_int_copy(void *v)
137 return isl_int_obj_copy((isl_int_obj *)v);
140 static void isl_obj_int_free(void *v)
142 isl_int_obj_free((isl_int_obj *)v);
145 static __isl_give isl_printer *isl_obj_int_print(__isl_take isl_printer *p,
149 return isl_printer_print_isl_int(p, i->v);
152 static void *isl_obj_int_add(void *v1, void *v2)
154 return isl_int_obj_add((isl_int_obj *)v1, (isl_int_obj *)v2);
157 struct isl_obj_vtable isl_obj_int_vtable = {
164 static void *isl_obj_map_copy(void *v)
166 return isl_map_copy((struct isl_map *)v);
169 static void isl_obj_map_free(void *v)
171 isl_map_free((struct isl_map *)v);
174 static __isl_give isl_printer *isl_obj_map_print(__isl_take isl_printer *p,
177 return isl_printer_print_map(p, (struct isl_map *)v);
180 static void *isl_obj_map_add(void *v1, void *v2)
182 return isl_map_union((struct isl_map *)v1, (struct isl_map *)v2);
185 struct isl_obj_vtable isl_obj_map_vtable = {
192 static void *isl_obj_union_map_copy(void *v)
194 return isl_union_map_copy((isl_union_map *)v);
197 static void isl_obj_union_map_free(void *v)
199 isl_union_map_free((isl_union_map *)v);
202 static __isl_give isl_printer *isl_obj_union_map_print(__isl_take isl_printer *p,
205 return isl_printer_print_union_map(p, (isl_union_map *)v);
208 static void *isl_obj_union_map_add(void *v1, void *v2)
210 return isl_union_map_union((isl_union_map *)v1, (isl_union_map *)v2);
213 struct isl_obj_vtable isl_obj_union_map_vtable = {
214 isl_obj_union_map_copy,
215 isl_obj_union_map_add,
216 isl_obj_union_map_print,
217 isl_obj_union_map_free
220 static void *isl_obj_set_copy(void *v)
222 return isl_set_copy((struct isl_set *)v);
225 static void isl_obj_set_free(void *v)
227 isl_set_free((struct isl_set *)v);
230 static __isl_give isl_printer *isl_obj_set_print(__isl_take isl_printer *p,
233 return isl_printer_print_set(p, (struct isl_set *)v);
236 static void *isl_obj_set_add(void *v1, void *v2)
238 return isl_set_union((struct isl_set *)v1, (struct isl_set *)v2);
241 struct isl_obj_vtable isl_obj_set_vtable = {
248 static void *isl_obj_union_set_copy(void *v)
250 return isl_union_set_copy((isl_union_set *)v);
253 static void isl_obj_union_set_free(void *v)
255 isl_union_set_free((isl_union_set *)v);
258 static __isl_give isl_printer *isl_obj_union_set_print(__isl_take isl_printer *p,
261 return isl_printer_print_union_set(p, (isl_union_set *)v);
264 static void *isl_obj_union_set_add(void *v1, void *v2)
266 return isl_union_set_union((isl_union_set *)v1, (isl_union_set *)v2);
269 struct isl_obj_vtable isl_obj_union_set_vtable = {
270 isl_obj_union_set_copy,
271 isl_obj_union_set_add,
272 isl_obj_union_set_print,
273 isl_obj_union_set_free
276 static void *isl_obj_none_copy(void *v)
281 static void isl_obj_none_free(void *v)
285 static __isl_give isl_printer *isl_obj_none_print(__isl_take isl_printer *p,
291 static void *isl_obj_none_add(void *v1, void *v2)
296 struct isl_obj_vtable isl_obj_none_vtable = {
303 static void *isl_obj_pw_qp_copy(void *v)
305 return isl_pw_qpolynomial_copy((struct isl_pw_qpolynomial *)v);
308 static void isl_obj_pw_qp_free(void *v)
310 isl_pw_qpolynomial_free((struct isl_pw_qpolynomial *)v);
313 static __isl_give isl_printer *isl_obj_pw_qp_print(__isl_take isl_printer *p,
316 return isl_printer_print_pw_qpolynomial(p,
317 (struct isl_pw_qpolynomial *)v);
320 static void *isl_obj_pw_qp_add(void *v1, void *v2)
322 return isl_pw_qpolynomial_add((struct isl_pw_qpolynomial *)v1,
323 (struct isl_pw_qpolynomial *)v2);
326 struct isl_obj_vtable isl_obj_pw_qpolynomial_vtable = {
333 static void *isl_obj_union_pw_qp_copy(void *v)
335 return isl_union_pw_qpolynomial_copy((struct isl_union_pw_qpolynomial *)v);
338 static void isl_obj_union_pw_qp_free(void *v)
340 isl_union_pw_qpolynomial_free((struct isl_union_pw_qpolynomial *)v);
343 static __isl_give isl_printer *isl_obj_union_pw_qp_print(
344 __isl_take isl_printer *p, void *v)
346 return isl_printer_print_union_pw_qpolynomial(p,
347 (struct isl_union_pw_qpolynomial *)v);
350 static void *isl_obj_union_pw_qp_add(void *v1, void *v2)
352 return isl_union_pw_qpolynomial_add(
353 (struct isl_union_pw_qpolynomial *)v1,
354 (struct isl_union_pw_qpolynomial *)v2);
357 struct isl_obj_vtable isl_obj_union_pw_qpolynomial_vtable = {
358 isl_obj_union_pw_qp_copy,
359 isl_obj_union_pw_qp_add,
360 isl_obj_union_pw_qp_print,
361 isl_obj_union_pw_qp_free
364 static void *isl_obj_pw_qpf_copy(void *v)
366 return isl_pw_qpolynomial_fold_copy((struct isl_pw_qpolynomial_fold *)v);
369 static void isl_obj_pw_qpf_free(void *v)
371 isl_pw_qpolynomial_fold_free((struct isl_pw_qpolynomial_fold *)v);
374 static __isl_give isl_printer *isl_obj_pw_qpf_print(__isl_take isl_printer *p,
377 return isl_printer_print_pw_qpolynomial_fold(p,
378 (struct isl_pw_qpolynomial_fold *)v);
381 static void *isl_obj_pw_qpf_add(void *v1, void *v2)
383 return isl_pw_qpolynomial_fold_fold((struct isl_pw_qpolynomial_fold *)v1,
384 (struct isl_pw_qpolynomial_fold *)v2);
387 struct isl_obj_vtable isl_obj_pw_qpolynomial_fold_vtable = {
390 isl_obj_pw_qpf_print,
394 static void *isl_obj_union_pw_qpf_copy(void *v)
396 return isl_union_pw_qpolynomial_fold_copy((struct isl_union_pw_qpolynomial_fold *)v);
399 static void isl_obj_union_pw_qpf_free(void *v)
401 isl_union_pw_qpolynomial_fold_free((struct isl_union_pw_qpolynomial_fold *)v);
404 static __isl_give isl_printer *isl_obj_union_pw_qpf_print(
405 __isl_take isl_printer *p, void *v)
407 return isl_printer_print_union_pw_qpolynomial_fold(p,
408 (struct isl_union_pw_qpolynomial_fold *)v);
411 static void *isl_obj_union_pw_qpf_add(void *v1, void *v2)
413 return isl_union_pw_qpolynomial_fold_fold(
414 (struct isl_union_pw_qpolynomial_fold *)v1,
415 (struct isl_union_pw_qpolynomial_fold *)v2);
418 struct isl_obj_vtable isl_obj_union_pw_qpolynomial_fold_vtable = {
419 isl_obj_union_pw_qpf_copy,
420 isl_obj_union_pw_qpf_add,
421 isl_obj_union_pw_qpf_print,
422 isl_obj_union_pw_qpf_free