class FaceMonoid(Parent): def __init__(self, generators): Parent.__init__(self, category = FiniteMonoids()) self._semigroup_generators = map(self._element_constructor_, generators) def _repr_(self): return "Monoïde de vecteurs de signes engendré par: %s" % (self._semigroup_generators) def one(self): length = len(self._semigroup_generators[0].value) return self((0,) * length) def semigroup_generators(self): return [self.one()] + [self(g) for g in self._semigroup_generators] def product(self, x, y): xv = x.value yv = y.value z = tuple([xv[i] if xv[i] != 0 else yv[i] for i in range(len(xv))]) return self(z) def regions(self): return [x for x in self if 0 not in x.value] class Element(ElementWrapper): wrapped_class = tuple def _repr_(self): d = {0:'0', 1:'+', -1:'-'} return "".join([d[i] for i in self.value])