def negative_roots(self): r""" Returns the negative roots of self. EXAMPLES:: sage: L = RootSystem(['A', 2]).weight_lattice() sage: sorted(L.negative_roots()) [-2*Lambda[1] + Lambda[2], -Lambda[1] - Lambda[2], Lambda[1] - 2*Lambda[2]] Algorithm: negate the positive roots """ assert self.cartan_type().is_finite() from sage.combinat.combinat import MapCombinatorialClass return MapCombinatorialClass(self.positive_roots(), attrcall('__neg__'), "The negative roots of %s" % self)
def map(self, f, name=None): r""" Return the image `\{f(x) | x \in \text{self}\}` of this enumerated set by `f`, as an enumerated set. `f` is supposed to be injective. EXAMPLES:: sage: R = Compositions(4).map(attrcall('partial_sums')); R Image of Compositions of 4 by *.partial_sums() sage: R.cardinality() 8 sage: R.list() [[1, 2, 3, 4], [1, 2, 4], [1, 3, 4], [1, 4], [2, 3, 4], [2, 4], [3, 4], [4]] sage: [ r for r in R] [[1, 2, 3, 4], [1, 2, 4], [1, 3, 4], [1, 4], [2, 3, 4], [2, 4], [3, 4], [4]] .. warning:: If the function is not injective, then there may be repeated elements:: sage: P = Compositions(4) sage: P.list() [[1, 1, 1, 1], [1, 1, 2], [1, 2, 1], [1, 3], [2, 1, 1], [2, 2], [3, 1], [4]] sage: P.map(attrcall('major_index')).list() [6, 3, 4, 1, 5, 2, 3, 0] .. warning:: :class:`MapCombinatorialClass` needs to be refactored to use categories:: sage: R.category() # todo: not implemented Category of enumerated sets sage: TestSuite(R).run(skip=['_test_an_element', '_test_category', '_test_some_elements']) """ from sage.combinat.combinat import MapCombinatorialClass return MapCombinatorialClass(self, f, name)
def map(self, f, name=None): r""" Returns the image `\{f(x) | x \in \text{self}\}` of this enumerated set by `f`, as an enumerated set. `f` is supposed to be injective. EXAMPLES:: sage: R = SymmetricGroup(3).map(attrcall('reduced_word')); R Image of Symmetric group of order 3! as a permutation group by *.reduced_word() sage: R.cardinality() 6 sage: R.list() [[], [2], [1], [2, 1], [1, 2], [1, 2, 1]] sage: [ r for r in R] [[], [2], [1], [2, 1], [1, 2], [1, 2, 1]] .. warning:: If the function is not injective, then there may be repeated elements:: sage: P = SymmetricGroup(3) sage: P.list() [(), (2,3), (1,2), (1,2,3), (1,3,2), (1,3)] sage: P.map(attrcall('length')).list() [0, 1, 1, 2, 2, 3] .. warning:: :class:`MapCombinatorialClass` needs to be refactored to use categories:: sage: R.category() # todo: not implemented Category of enumerated sets sage: TestSuite(R).run(skip=['_test_an_element', '_test_category', '_test_some_elements']) """ from sage.combinat.combinat import MapCombinatorialClass return MapCombinatorialClass(self, f, name)