X-Git-Url: https://scm.cri.ensmp.fr/git/linpy.git/blobdiff_plain/be3afc267db06adc04b6787d62663165f2101788..d1592edb29b12dafe5c0d0698310b98b4915cf26:/linpy/domains.py diff --git a/linpy/domains.py b/linpy/domains.py index 31b5c3f..da0ea97 100644 --- a/linpy/domains.py +++ b/linpy/domains.py @@ -278,6 +278,10 @@ class Domain(GeometricObject): Project out the sequence of symbols given in arguments, and return the resulting domain. """ + symbols = list(symbols) + for symbol in symbols: + if not isinstance(symbol, Symbol): + raise TypeError('symbols must be Symbol instances') islset = self._toislset(self.polyhedra, self.symbols) n = 0 for index, symbol in reversed(list(enumerate(self.symbols))): @@ -316,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. """ - if len(others) == 0: - return self - symbols = self._xsymbols((self,) + others) - islset1 = self._toislset(self.polyhedra, symbols) + result = self 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): - 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):