From 6120eb04e9422574814570d653e6ac19b057727f Mon Sep 17 00:00:00 2001 From: Danielle Bolan Date: Tue, 10 Jun 2014 10:04:18 +0200 Subject: [PATCH] add small isl changes --- pypol/isl.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/pypol/isl.py b/pypol/isl.py index 74cc5d3..41716c1 100644 --- a/pypol/isl.py +++ b/pypol/isl.py @@ -1,3 +1,7 @@ +""" +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 @@ -6,11 +10,11 @@ import operator 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 @@ -37,8 +41,8 @@ class Context: 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): @@ -115,12 +119,20 @@ class Value: 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) @@ -135,7 +147,7 @@ class Value: @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): -- 2.20.1