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:
a93fd1c
)
Cleaner implementation of Domain.__and__()
author
Vivien Maisonneuve
<v.maisonneuve@gmail.com>
Tue, 19 Aug 2014 14:26:24 +0000
(16:26 +0200)
committer
Vivien Maisonneuve
<v.maisonneuve@gmail.com>
Tue, 19 Aug 2014 14:26:24 +0000
(16:26 +0200)
linpy/domains.py
patch
|
blob
|
history
diff --git
a/linpy/domains.py
b/linpy/domains.py
index
7015252
..
da0ea97
100644
(file)
--- a/
linpy/domains.py
+++ b/
linpy/domains.py
@@
-320,17
+320,19
@@
class Domain(GeometricObject):
Return the intersection of two or more domains as a new domain. As an
alternative, function And() can be used.
"""
Return the intersection of two or more domains as a new domain. As an
alternative, function And() can be used.
"""
- if len(others) == 0:
- return self
- symbols = self._xsymbols((self,) + others)
- islset1 = self._toislset(self.polyhedra, symbols)
+ result = self
for other in others:
for other in others:
- islset2 = other._toislset(other.polyhedra, symbols)
- islset1 = libisl.isl_set_intersect(islset1, islset2)
- return self._fromislset(islset1, symbols)
+ result &= other
+ return result
def __and__(self, other):
def __and__(self, other):
- return self.intersection(other)
+ if isinstance(other, Domain):
+ symbols = self._xsymbols([self, other])
+ islset1 = self._toislset(self.polyhedra, symbols)
+ islset2 = other._toislset(other.polyhedra, symbols)
+ islset = libisl.isl_set_intersect(islset1, islset2)
+ return self._fromislset(islset, symbols)
+ return NotImplemented
__and__.__doc__ = intersection.__doc__
def union(self, *others):
__and__.__doc__ = intersection.__doc__
def union(self, *others):