def retract(self, elt): r""" Return the canonical representative of the orbit of the integer ``elt`` under the action of the permutation group defining ``self``. If the element ``elt`` is already maximal in its orbits for the lexicographic order, ``elt`` is thus the good representative for its orbit. EXAMPLES:: sage: S = IntegerVectorsModPermutationGroup(PermutationGroup([[(1,2,3,4)]]), sum=2, max_part=1) sage: S.retract([1,1,0,0]) [1, 1, 0, 0] sage: S.retract([1,0,1,0]) [1, 0, 1, 0] sage: S.retract([1,0,0,1]) [1, 1, 0, 0] sage: S.retract([0,1,1,0]) [1, 1, 0, 0] sage: S.retract([0,1,0,1]) [1, 0, 1, 0] sage: S.retract([0,0,1,1]) [1, 1, 0, 0] """ # TODO: Once Sage integer vector will have a data structure # based on ClonableIntArray, remove the conversion intarray assert len(elt) == self.n, "%s is a quotient set of %s"%(self, self.ambient()) if self._sum is not None: assert sum(elt) == self._sum, "%s is a quotient set of %s"%(self, self.ambient()) if self._max_part >= 0: assert max(elt) <= self._max_part, "%s is a quotient set of %s"%(self, self.ambient()) intarray = self.element_class(self, elt, check=False) return self.element_class(self, canonical_representative_of_orbit_of(self._sgs, intarray), check=False)
def retract(self, elt): r""" Return the canonical representative of the orbit of the integer ``elt`` under the action of the permutation group defining ``self``. If the element ``elt`` is already maximal in its orbits for the lexicographic order, ``elt`` is thus the good representative for its orbit. EXAMPLES:: sage: S = IntegerVectorsModPermutationGroup(PermutationGroup([[(1,2,3,4)]]), sum=2, max_part=1) sage: S.retract([1,1,0,0]) [1, 1, 0, 0] sage: S.retract([1,0,1,0]) [1, 0, 1, 0] sage: S.retract([1,0,0,1]) [1, 1, 0, 0] sage: S.retract([0,1,1,0]) [1, 1, 0, 0] sage: S.retract([0,1,0,1]) [1, 0, 1, 0] sage: S.retract([0,0,1,1]) [1, 1, 0, 0] """ # TODO: Once Sage integer vector will have a data structure # based on ClonableIntArray, remove the conversion intarray assert len(elt) == self.n, "%s is a quotient set of %s"%(self, self.ambient()) if self._sum is not None: assert sum(elt) == self._sum, "%s is a quotient set of %s"%(self, self.ambient()) if self._max_part >= 0: assert max(elt) <= self._max_part, "%s is a quotient set of %s"%(self, self.ambient()) intarray = self.element_class(self, elt, check=False) return self.element_class(self, canonical_representative_of_orbit_of(self._sgs, intarray), check=False)