2 * Copyright 2010 INRIA Saclay
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
7 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
13 #include <isl/polynomial.h>
22 __isl_give isl_int_obj
*isl_int_obj_alloc(isl_ctx
*ctx
, isl_int v
)
26 i
= isl_alloc_type(ctx
, isl_int_obj
);
39 __isl_give isl_int_obj
*isl_int_obj_copy(__isl_keep isl_int_obj
*i
)
48 __isl_give isl_int_obj
*isl_int_obj_dup(__isl_keep isl_int_obj
*i
)
53 return isl_int_obj_alloc(i
->ctx
, i
->v
);
56 __isl_give isl_int_obj
*isl_int_obj_cow(__isl_take isl_int_obj
*i
)
64 return isl_int_obj_dup(i
);
67 void isl_int_obj_free(__isl_take isl_int_obj
*i
)
75 isl_ctx_deref(i
->ctx
);
80 __isl_give isl_int_obj
*isl_int_obj_add(__isl_take isl_int_obj
*i1
,
81 __isl_take isl_int_obj
*i2
)
83 i1
= isl_int_obj_cow(i1
);
87 isl_int_add(i1
->v
, i1
->v
, i2
->v
);
97 __isl_give isl_int_obj
*isl_int_obj_sub(__isl_take isl_int_obj
*i1
,
98 __isl_take isl_int_obj
*i2
)
100 i1
= isl_int_obj_cow(i1
);
104 isl_int_sub(i1
->v
, i1
->v
, i2
->v
);
106 isl_int_obj_free(i2
);
109 isl_int_obj_free(i1
);
110 isl_int_obj_free(i2
);
114 __isl_give isl_int_obj
*isl_int_obj_mul(__isl_take isl_int_obj
*i1
,
115 __isl_take isl_int_obj
*i2
)
117 i1
= isl_int_obj_cow(i1
);
121 isl_int_mul(i1
->v
, i1
->v
, i2
->v
);
123 isl_int_obj_free(i2
);
126 isl_int_obj_free(i1
);
127 isl_int_obj_free(i2
);
131 void isl_int_obj_get_int(__isl_keep isl_int_obj
*i
, isl_int
*v
)
135 isl_int_set(*v
, i
->v
);
138 static void *isl_obj_int_copy(void *v
)
140 return isl_int_obj_copy((isl_int_obj
*)v
);
143 static void isl_obj_int_free(void *v
)
145 isl_int_obj_free((isl_int_obj
*)v
);
148 static __isl_give isl_printer
*isl_obj_int_print(__isl_take isl_printer
*p
,
152 return isl_printer_print_isl_int(p
, i
->v
);
155 static void *isl_obj_int_add(void *v1
, void *v2
)
157 return isl_int_obj_add((isl_int_obj
*)v1
, (isl_int_obj
*)v2
);
160 struct isl_obj_vtable isl_obj_int_vtable
= {
167 static void *isl_obj_val_copy(void *v
)
169 return isl_val_copy((isl_val
*)v
);
172 static void isl_obj_val_free(void *v
)
174 isl_val_free((isl_val
*)v
);
177 static __isl_give isl_printer
*isl_obj_val_print(__isl_take isl_printer
*p
,
180 return isl_printer_print_val(p
, (isl_val
*)v
);
183 static void *isl_obj_val_add(void *v1
, void *v2
)
185 return isl_val_add((isl_val
*) v1
, (isl_val
*) v2
);
188 struct isl_obj_vtable isl_obj_val_vtable
= {
195 static void *isl_obj_map_copy(void *v
)
197 return isl_map_copy((struct isl_map
*)v
);
200 static void isl_obj_map_free(void *v
)
202 isl_map_free((struct isl_map
*)v
);
205 static __isl_give isl_printer
*isl_obj_map_print(__isl_take isl_printer
*p
,
208 return isl_printer_print_map(p
, (struct isl_map
*)v
);
211 static void *isl_obj_map_add(void *v1
, void *v2
)
213 return isl_map_union((struct isl_map
*)v1
, (struct isl_map
*)v2
);
216 struct isl_obj_vtable isl_obj_map_vtable
= {
223 static void *isl_obj_union_map_copy(void *v
)
225 return isl_union_map_copy((isl_union_map
*)v
);
228 static void isl_obj_union_map_free(void *v
)
230 isl_union_map_free((isl_union_map
*)v
);
233 static __isl_give isl_printer
*isl_obj_union_map_print(__isl_take isl_printer
*p
,
236 return isl_printer_print_union_map(p
, (isl_union_map
*)v
);
239 static void *isl_obj_union_map_add(void *v1
, void *v2
)
241 return isl_union_map_union((isl_union_map
*)v1
, (isl_union_map
*)v2
);
244 struct isl_obj_vtable isl_obj_union_map_vtable
= {
245 isl_obj_union_map_copy
,
246 isl_obj_union_map_add
,
247 isl_obj_union_map_print
,
248 isl_obj_union_map_free
251 static void *isl_obj_set_copy(void *v
)
253 return isl_set_copy((struct isl_set
*)v
);
256 static void isl_obj_set_free(void *v
)
258 isl_set_free((struct isl_set
*)v
);
261 static __isl_give isl_printer
*isl_obj_set_print(__isl_take isl_printer
*p
,
264 return isl_printer_print_set(p
, (struct isl_set
*)v
);
267 static void *isl_obj_set_add(void *v1
, void *v2
)
269 return isl_set_union((struct isl_set
*)v1
, (struct isl_set
*)v2
);
272 struct isl_obj_vtable isl_obj_set_vtable
= {
279 static void *isl_obj_union_set_copy(void *v
)
281 return isl_union_set_copy((isl_union_set
*)v
);
284 static void isl_obj_union_set_free(void *v
)
286 isl_union_set_free((isl_union_set
*)v
);
289 static __isl_give isl_printer
*isl_obj_union_set_print(__isl_take isl_printer
*p
,
292 return isl_printer_print_union_set(p
, (isl_union_set
*)v
);
295 static void *isl_obj_union_set_add(void *v1
, void *v2
)
297 return isl_union_set_union((isl_union_set
*)v1
, (isl_union_set
*)v2
);
300 struct isl_obj_vtable isl_obj_union_set_vtable
= {
301 isl_obj_union_set_copy
,
302 isl_obj_union_set_add
,
303 isl_obj_union_set_print
,
304 isl_obj_union_set_free
307 static void *isl_obj_none_copy(void *v
)
312 static void isl_obj_none_free(void *v
)
316 static __isl_give isl_printer
*isl_obj_none_print(__isl_take isl_printer
*p
,
322 static void *isl_obj_none_add(void *v1
, void *v2
)
327 struct isl_obj_vtable isl_obj_none_vtable
= {
334 static void *isl_obj_pw_qp_copy(void *v
)
336 return isl_pw_qpolynomial_copy((struct isl_pw_qpolynomial
*)v
);
339 static void isl_obj_pw_qp_free(void *v
)
341 isl_pw_qpolynomial_free((struct isl_pw_qpolynomial
*)v
);
344 static __isl_give isl_printer
*isl_obj_pw_qp_print(__isl_take isl_printer
*p
,
347 return isl_printer_print_pw_qpolynomial(p
,
348 (struct isl_pw_qpolynomial
*)v
);
351 static void *isl_obj_pw_qp_add(void *v1
, void *v2
)
353 return isl_pw_qpolynomial_add((struct isl_pw_qpolynomial
*)v1
,
354 (struct isl_pw_qpolynomial
*)v2
);
357 struct isl_obj_vtable isl_obj_pw_qpolynomial_vtable
= {
364 static void *isl_obj_union_pw_qp_copy(void *v
)
366 return isl_union_pw_qpolynomial_copy((struct isl_union_pw_qpolynomial
*)v
);
369 static void isl_obj_union_pw_qp_free(void *v
)
371 isl_union_pw_qpolynomial_free((struct isl_union_pw_qpolynomial
*)v
);
374 static __isl_give isl_printer
*isl_obj_union_pw_qp_print(
375 __isl_take isl_printer
*p
, void *v
)
377 return isl_printer_print_union_pw_qpolynomial(p
,
378 (struct isl_union_pw_qpolynomial
*)v
);
381 static void *isl_obj_union_pw_qp_add(void *v1
, void *v2
)
383 return isl_union_pw_qpolynomial_add(
384 (struct isl_union_pw_qpolynomial
*)v1
,
385 (struct isl_union_pw_qpolynomial
*)v2
);
388 struct isl_obj_vtable isl_obj_union_pw_qpolynomial_vtable
= {
389 isl_obj_union_pw_qp_copy
,
390 isl_obj_union_pw_qp_add
,
391 isl_obj_union_pw_qp_print
,
392 isl_obj_union_pw_qp_free
395 static void *isl_obj_pw_qpf_copy(void *v
)
397 return isl_pw_qpolynomial_fold_copy((struct isl_pw_qpolynomial_fold
*)v
);
400 static void isl_obj_pw_qpf_free(void *v
)
402 isl_pw_qpolynomial_fold_free((struct isl_pw_qpolynomial_fold
*)v
);
405 static __isl_give isl_printer
*isl_obj_pw_qpf_print(__isl_take isl_printer
*p
,
408 return isl_printer_print_pw_qpolynomial_fold(p
,
409 (struct isl_pw_qpolynomial_fold
*)v
);
412 static void *isl_obj_pw_qpf_add(void *v1
, void *v2
)
414 return isl_pw_qpolynomial_fold_fold((struct isl_pw_qpolynomial_fold
*)v1
,
415 (struct isl_pw_qpolynomial_fold
*)v2
);
418 struct isl_obj_vtable isl_obj_pw_qpolynomial_fold_vtable
= {
421 isl_obj_pw_qpf_print
,
425 static void *isl_obj_union_pw_qpf_copy(void *v
)
427 return isl_union_pw_qpolynomial_fold_copy((struct isl_union_pw_qpolynomial_fold
*)v
);
430 static void isl_obj_union_pw_qpf_free(void *v
)
432 isl_union_pw_qpolynomial_fold_free((struct isl_union_pw_qpolynomial_fold
*)v
);
435 static __isl_give isl_printer
*isl_obj_union_pw_qpf_print(
436 __isl_take isl_printer
*p
, void *v
)
438 return isl_printer_print_union_pw_qpolynomial_fold(p
,
439 (struct isl_union_pw_qpolynomial_fold
*)v
);
442 static void *isl_obj_union_pw_qpf_add(void *v1
, void *v2
)
444 return isl_union_pw_qpolynomial_fold_fold(
445 (struct isl_union_pw_qpolynomial_fold
*)v1
,
446 (struct isl_union_pw_qpolynomial_fold
*)v2
);
449 struct isl_obj_vtable isl_obj_union_pw_qpolynomial_fold_vtable
= {
450 isl_obj_union_pw_qpf_copy
,
451 isl_obj_union_pw_qpf_add
,
452 isl_obj_union_pw_qpf_print
,
453 isl_obj_union_pw_qpf_free