projects
/
linpy.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
23787dd
)
add small isl changes
author
Danielle Bolan
<n02702451@hawkmail.newpaltz.edu>
Tue, 10 Jun 2014 08:04:18 +0000
(10:04 +0200)
committer
Danielle Bolan
<n02702451@hawkmail.newpaltz.edu>
Tue, 10 Jun 2014 08:04:18 +0000
(10:04 +0200)
pypol/isl.py
patch
|
blob
|
history
diff --git
a/pypol/isl.py
b/pypol/isl.py
index
74cc5d3
..
41716c1
100644
(file)
--- 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
import ctypes, ctypes.util
import math
@@
-6,11
+10,11
@@
import operator
import re
import functools
import re
import functools
+
from decimal import Decimal
from fractions import Fraction
from functools import wraps
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
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 _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):
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)
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
return self
+
@property
def _as_parameter_(self):
return self._iv
@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)
def __del__(self):
libisl.isl_val_free(self)
@@
-135,7
+147,7
@@
class Value:
@property
def denominator(self):
if self._denominator is None:
@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):
return self._denominator
def __bool__(self):