Minor improvements to Polyhedra._fromislbasicset(), _toislbasicset()
[linpy.git] / pypol / islhelper.py
1 import ctypes, ctypes.util
2
3 from . import _islhelper
4 from ._islhelper import isl_basic_set_constraints, isl_set_basic_sets
5
6
7 __all__ = [
8 'libisl',
9 'mainctx',
10 'isl_val_to_int',
11 'isl_basic_set_to_str', 'isl_basic_set_constraints',
12 'isl_set_to_str', 'isl_set_basic_sets',
13 ]
14
15
16 libisl = ctypes.CDLL(ctypes.util.find_library('isl'))
17
18 libisl.isl_printer_get_str.restype = ctypes.c_char_p
19 libisl.isl_dim_set = _islhelper.dim_set
20
21
22 mainctx = libisl.isl_ctx_alloc()
23
24
25 def isl_val_to_int(islval):
26 islpr = libisl.isl_printer_to_str(mainctx)
27 islpr = libisl.isl_printer_print_val(islpr, islval)
28 string = libisl.isl_printer_get_str(islpr).decode()
29 return int(string)
30
31 def isl_basic_set_to_str(islbset):
32 islpr = libisl.isl_printer_to_str(mainctx)
33 islpr = libisl.isl_printer_print_basic_set(islpr, islbset)
34 string = libisl.isl_printer_get_str(islpr).decode()
35 return string
36
37 def isl_set_to_str(islset):
38 islpr = libisl.isl_printer_to_str(mainctx)
39 islpr = libisl.isl_printer_print_set(islpr, islset)
40 string = libisl.isl_printer_get_str(islpr).decode()
41 return string