from collections import OrderedDict, Mapping
+from .geometry import GeometricObject
from .linexprs import Symbol
yield symbol, func(coordinate1, coordinate2)
-class Point(Coordinates):
+class Point(Coordinates, GeometricObject):
"""
This class represents points in space.
"""
from . import islhelper
from .islhelper import mainctx, libisl, isl_set_basic_sets
+from .geometry import GeometricObject
from .coordinates import Point
from .linexprs import Expression, Symbol
@functools.total_ordering
-class Domain:
+class Domain(GeometricObject):
__slots__ = (
'_polyhedra',
def __new__(cls, *polyhedra):
from .polyhedra import Polyhedron
if len(polyhedra) == 1:
- polyhedron = polyhedra[0]
- if isinstance(polyhedron, str):
- return cls.fromstring(polyhedron)
- elif isinstance(polyhedron, Polyhedron):
- return polyhedron
+ argument = polyhedra[0]
+ if isinstance(argument, str):
+ return cls.fromstring(argument)
+ elif isinstance(argument, GeometricObject):
+ return argument.aspolyhedron()
else:
raise TypeError('argument must be a string '
- 'or a Polyhedron instance')
+ 'or a GeometricObject instance')
else:
for polyhedron in polyhedra:
if not isinstance(polyhedron, Polyhedron):
islbset = libisl.isl_set_polyhedral_hull(islset)
return Polyhedron._fromislbasicset(islbset, self.symbols)
+ def asdomain(self):
+ return self
+
def project(self, dims):
# use to remove certain variables
islset = self._toislset(self.polyhedra, self.symbols)
--- /dev/null
+
+from abc import ABC, abstractmethod, abstractproperty
+
+
+__all__ = [
+ 'GeometricObject',
+]
+
+
+class GeometricObject(ABC):
+
+ @abstractproperty
+ def symbols(self):
+ pass
+
+ @property
+ def dimension(self):
+ return len(self.symbols)
+
+ @abstractmethod
+ def aspolyhedron(self):
+ pass
+
+ def asdomain(self):
+ return self.aspolyhedron()
from . import islhelper
from .islhelper import mainctx, libisl
+from .geometry import GeometricObject
from .coordinates import Point
from .linexprs import Expression, Symbol, Rational
from .domains import Domain
if inequalities is not None:
raise TypeError('too many arguments')
return cls.fromstring(equalities)
- elif isinstance(equalities, Polyhedron):
- if inequalities is not None:
- raise TypeError('too many arguments')
- return equalities
- elif isinstance(equalities, Domain):
+ elif isinstance(equalities, GeometricObject):
if inequalities is not None:
raise TypeError('too many arguments')
return equalities.aspolyhedron()