From 17f12d8f63d696f09dbb44be3dc24b9aba7b88d3 Mon Sep 17 00:00:00 2001
From: Vivien Maisonneuve <v.maisonneuve@gmail.com>
Date: Sun, 6 Jul 2014 12:22:41 +0200
Subject: [PATCH] Add methods Domain.subs(), Polyhedron.subs()

---
 pypol/domains.py   | 6 ++++++
 pypol/polyhedra.py | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/pypol/domains.py b/pypol/domains.py
index fdb0ab0..2fbd544 100644
--- a/pypol/domains.py
+++ b/pypol/domains.py
@@ -301,6 +301,11 @@ class Domain:
             points.append(point)
         return points
 
+    def subs(self, symbol, expression=None):
+        polyhedra = [polyhedron.subs(symbol, expression)
+            for polyhedron in self.polyhedra]
+        return Domain(*polyhedra)
+
     @classmethod
     def _fromislset(cls, islset, symbols):
         from .polyhedra import Polyhedron
@@ -323,6 +328,7 @@ class Domain:
             self._dimension = len(self._symbols)
             return self
 
+    @classmethod
     def _toislset(cls, polyhedra, symbols):
         polyhedron = polyhedra[0]
         islbset = polyhedron._toislbasicset(polyhedron.equalities,
diff --git a/pypol/polyhedra.py b/pypol/polyhedra.py
index a6adeda..63ecb64 100644
--- a/pypol/polyhedra.py
+++ b/pypol/polyhedra.py
@@ -85,6 +85,13 @@ class Polyhedron(Domain):
     def aspolyhedron(self):
         return self
 
+    def subs(self, symbol, expression=None):
+        equalities = [equality.subs(symbol, expression)
+            for equality in self.equalities]
+        inequalities = [inequality.subs(symbol, expression)
+            for inequality in self.inequalities]
+        return Polyhedron(equalities, inequalities)
+
     @classmethod
     def _fromislbasicset(cls, islbset, symbols):
         islconstraints = islhelper.isl_basic_set_constraints(islbset)
-- 
2.20.1