-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comparison operators for PwAff #115
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -687,6 +687,56 @@ def pw_get_aggregate_domain(self): | |
|
||
return result | ||
|
||
def pw_le(self, other): | ||
""" | ||
:return: self <= other | ||
""" | ||
if isinstance(other, int): | ||
return self.le_set(self * 0 + other) | ||
else: | ||
assert isinstance(other, PwAff) | ||
return self.le_set(other) | ||
|
||
def pw_lt(self, other): | ||
""" | ||
:return: self < other | ||
""" | ||
if isinstance(other, int): | ||
return self.lt_set(self * 0 + other) | ||
else: | ||
assert isinstance(other, PwAff) | ||
return self.lt_set(other) | ||
|
||
def pw_ge(self, other): | ||
""" | ||
:return: self >= other | ||
""" | ||
if isinstance(other, int): | ||
return self.ge_set(self * 0 + other) | ||
else: | ||
assert isinstance(other, PwAff) | ||
return self.ge_set(other) | ||
|
||
def pw_gt(self, other): | ||
""" | ||
:return: self >= other | ||
""" | ||
if isinstance(other, int): | ||
return self.gt_set(self * 0 + other) | ||
else: | ||
assert isinstance(other, PwAff) | ||
return self.gt_set(other) | ||
|
||
def pw_bool(self): | ||
return NotImplementedError( | ||
"Converting a PwAff to a boolean is nor supported.") | ||
|
||
PwAff.__le__ = pw_le | ||
PwAff.__lt__ = pw_lt | ||
PwAff.__ge__ = pw_ge | ||
PwAff.__gt__ = pw_gt | ||
Comment on lines
+734
to
+737
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One issue with this is that it can't extend to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True. This is a problem for eg: SymPy where |
||
PwAff.__bool__ = pw_bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to override |
||
|
||
PwAff.get_pieces = pwaff_get_pieces | ||
PwAff.get_aggregate_domain = pw_get_aggregate_domain | ||
|
||
|
@@ -1288,13 +1338,13 @@ def make_zero_and_vars(set_vars, params=(), ctx=None): | |
v = isl.make_zero_and_vars("i,j,k", "n") | ||
|
||
myset = ( | ||
v[0].le_set(v["i"] + v["j"]) | ||
(0 <= v["i"] + v["j"]) | ||
& | ||
(v["i"] + v["j"]).lt_set(v["n"]) | ||
(v["i"] + v["j"] < v["n"]) | ||
& | ||
(v[0].le_set(v["i"])) | ||
(0 <= v["i"]) | ||
& | ||
(v["i"].le_set(13 + v["n"])) | ||
(v["i"] <= 13 + v["n"]) | ||
) | ||
""" | ||
if ctx is None: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There must be a better way to do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.