+"""
+note: for islpy
+isl format: basic set: ("{[x, y] : x >= 0 and x < 5 and y >= 0 and y < x+4 }")
+"""
import ctypes, ctypes.util
import math
import re
import functools
+
from decimal import Decimal
from fractions import Fraction
from functools import wraps
-
libisl = ctypes.CDLL(ctypes.util.find_library('isl'))
libisl.isl_printer_get_str.restype = ctypes.c_char_p
def _as_parameter_(self):
return self._ic
- def __del__(self):
- libisl.isl_ctx_free(self)
+ #def __del__(self):
+ # libisl.isl_ctx_free(self)
def __eq__(self, other):
if not isinstance(other, Context):
numerator = libisl.isl_val_read_from_str(context, numerator)
denominator = str(frac.denominator).encode()
denominator = libisl.isl_val_read_from_str(context, denominator)
- self._iv = libisl.isl_val_div(numerator, denominator)
+ self._iv = libisl.isl_val_div(numerator, denominator)
+ print('in isl')
return self
+
@property
def _as_parameter_(self):
return self._iv
+
+ def symbols(self):
+ s = set()
+ for constraint in self.constraints():
+ s.update(constraint.symbols)
+ yield from sorted(s)
def __del__(self):
libisl.isl_val_free(self)
@property
def denominator(self):
if self._denominator is None:
- raise ValueError('not a rational number')
+ raise ValueError('not a rational number')
return self._denominator
def __bool__(self):