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,
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_map_copy(void *v
)
169 return isl_map_copy((struct isl_map
*)v
);
172 static void isl_obj_map_free(void *v
)
174 isl_map_free((struct isl_map
*)v
);
177 static __isl_give isl_printer
*isl_obj_map_print(__isl_take isl_printer
*p
,
180 return isl_printer_print_map(p
, (struct isl_map
*)v
);
183 static void *isl_obj_map_add(void *v1
, void *v2
)
185 return isl_map_union((struct isl_map
*)v1
, (struct isl_map
*)v2
);
188 struct isl_obj_vtable isl_obj_map_vtable
= {
195 static void *isl_obj_union_map_copy(void *v
)
197 return isl_union_map_copy((isl_union_map
*)v
);
200 static void isl_obj_union_map_free(void *v
)
202 isl_union_map_free((isl_union_map
*)v
);
205 static __isl_give isl_printer
*isl_obj_union_map_print(__isl_take isl_printer
*p
,
208 return isl_printer_print_union_map(p
, (isl_union_map
*)v
);
211 static void *isl_obj_union_map_add(void *v1
, void *v2
)
213 return isl_union_map_union((isl_union_map
*)v1
, (isl_union_map
*)v2
);
216 struct isl_obj_vtable isl_obj_union_map_vtable
= {
217 isl_obj_union_map_copy
,
218 isl_obj_union_map_add
,
219 isl_obj_union_map_print
,
220 isl_obj_union_map_free
223 static void *isl_obj_set_copy(void *v
)
225 return isl_set_copy((struct isl_set
*)v
);
228 static void isl_obj_set_free(void *v
)
230 isl_set_free((struct isl_set
*)v
);
233 static __isl_give isl_printer
*isl_obj_set_print(__isl_take isl_printer
*p
,
236 return isl_printer_print_set(p
, (struct isl_set
*)v
);
239 static void *isl_obj_set_add(void *v1
, void *v2
)
241 return isl_set_union((struct isl_set
*)v1
, (struct isl_set
*)v2
);
244 struct isl_obj_vtable isl_obj_set_vtable
= {
251 static void *isl_obj_union_set_copy(void *v
)
253 return isl_union_set_copy((isl_union_set
*)v
);
256 static void isl_obj_union_set_free(void *v
)
258 isl_union_set_free((isl_union_set
*)v
);
261 static __isl_give isl_printer
*isl_obj_union_set_print(__isl_take isl_printer
*p
,
264 return isl_printer_print_union_set(p
, (isl_union_set
*)v
);
267 static void *isl_obj_union_set_add(void *v1
, void *v2
)
269 return isl_union_set_union((isl_union_set
*)v1
, (isl_union_set
*)v2
);
272 struct isl_obj_vtable isl_obj_union_set_vtable
= {
273 isl_obj_union_set_copy
,
274 isl_obj_union_set_add
,
275 isl_obj_union_set_print
,
276 isl_obj_union_set_free
279 static void *isl_obj_none_copy(void *v
)
284 static void isl_obj_none_free(void *v
)
288 static __isl_give isl_printer
*isl_obj_none_print(__isl_take isl_printer
*p
,
294 static void *isl_obj_none_add(void *v1
, void *v2
)
299 struct isl_obj_vtable isl_obj_none_vtable
= {
306 static void *isl_obj_pw_qp_copy(void *v
)
308 return isl_pw_qpolynomial_copy((struct isl_pw_qpolynomial
*)v
);
311 static void isl_obj_pw_qp_free(void *v
)
313 isl_pw_qpolynomial_free((struct isl_pw_qpolynomial
*)v
);
316 static __isl_give isl_printer
*isl_obj_pw_qp_print(__isl_take isl_printer
*p
,
319 return isl_printer_print_pw_qpolynomial(p
,
320 (struct isl_pw_qpolynomial
*)v
);
323 static void *isl_obj_pw_qp_add(void *v1
, void *v2
)
325 return isl_pw_qpolynomial_add((struct isl_pw_qpolynomial
*)v1
,
326 (struct isl_pw_qpolynomial
*)v2
);
329 struct isl_obj_vtable isl_obj_pw_qpolynomial_vtable
= {
336 static void *isl_obj_union_pw_qp_copy(void *v
)
338 return isl_union_pw_qpolynomial_copy((struct isl_union_pw_qpolynomial
*)v
);
341 static void isl_obj_union_pw_qp_free(void *v
)
343 isl_union_pw_qpolynomial_free((struct isl_union_pw_qpolynomial
*)v
);
346 static __isl_give isl_printer
*isl_obj_union_pw_qp_print(
347 __isl_take isl_printer
*p
, void *v
)
349 return isl_printer_print_union_pw_qpolynomial(p
,
350 (struct isl_union_pw_qpolynomial
*)v
);
353 static void *isl_obj_union_pw_qp_add(void *v1
, void *v2
)
355 return isl_union_pw_qpolynomial_add(
356 (struct isl_union_pw_qpolynomial
*)v1
,
357 (struct isl_union_pw_qpolynomial
*)v2
);
360 struct isl_obj_vtable isl_obj_union_pw_qpolynomial_vtable
= {
361 isl_obj_union_pw_qp_copy
,
362 isl_obj_union_pw_qp_add
,
363 isl_obj_union_pw_qp_print
,
364 isl_obj_union_pw_qp_free
367 static void *isl_obj_pw_qpf_copy(void *v
)
369 return isl_pw_qpolynomial_fold_copy((struct isl_pw_qpolynomial_fold
*)v
);
372 static void isl_obj_pw_qpf_free(void *v
)
374 isl_pw_qpolynomial_fold_free((struct isl_pw_qpolynomial_fold
*)v
);
377 static __isl_give isl_printer
*isl_obj_pw_qpf_print(__isl_take isl_printer
*p
,
380 return isl_printer_print_pw_qpolynomial_fold(p
,
381 (struct isl_pw_qpolynomial_fold
*)v
);
384 static void *isl_obj_pw_qpf_add(void *v1
, void *v2
)
386 return isl_pw_qpolynomial_fold_fold((struct isl_pw_qpolynomial_fold
*)v1
,
387 (struct isl_pw_qpolynomial_fold
*)v2
);
390 struct isl_obj_vtable isl_obj_pw_qpolynomial_fold_vtable
= {
393 isl_obj_pw_qpf_print
,
397 static void *isl_obj_union_pw_qpf_copy(void *v
)
399 return isl_union_pw_qpolynomial_fold_copy((struct isl_union_pw_qpolynomial_fold
*)v
);
402 static void isl_obj_union_pw_qpf_free(void *v
)
404 isl_union_pw_qpolynomial_fold_free((struct isl_union_pw_qpolynomial_fold
*)v
);
407 static __isl_give isl_printer
*isl_obj_union_pw_qpf_print(
408 __isl_take isl_printer
*p
, void *v
)
410 return isl_printer_print_union_pw_qpolynomial_fold(p
,
411 (struct isl_union_pw_qpolynomial_fold
*)v
);
414 static void *isl_obj_union_pw_qpf_add(void *v1
, void *v2
)
416 return isl_union_pw_qpolynomial_fold_fold(
417 (struct isl_union_pw_qpolynomial_fold
*)v1
,
418 (struct isl_union_pw_qpolynomial_fold
*)v2
);
421 struct isl_obj_vtable isl_obj_union_pw_qpolynomial_fold_vtable
= {
422 isl_obj_union_pw_qpf_copy
,
423 isl_obj_union_pw_qpf_add
,
424 isl_obj_union_pw_qpf_print
,
425 isl_obj_union_pw_qpf_free