Module: sage.combinat.composition_signed
Signed Compositions
Module-level Functions
n) |
Returns the combinatorial class of signed compositions of n.
sage: SC3 = SignedCompositions(3); SC3 Signed compositions of 3 sage: SC3.count() 18 sage: len(SC3.list()) 18 sage: SC3.first() [1, 1, 1] sage: SC3.last() [-3] sage: SC3.random_element() [1, -1, 1] sage: SC3.list() [[1, 1, 1], [1, 1, -1], [1, -1, 1], [1, -1, -1], [-1, 1, 1], [-1, 1, -1], [-1, -1, 1], [-1, -1, -1], [1, 2], [1, -2], [-1, 2], [-1, -2], [2, 1], [2, -1], [-2, 1], [-2, -1], [3], [-3]]
Class: SignedCompositions_n
self, n) |
TESTS:
sage: SC3 = SignedCompositions(3) sage: SC3 == loads(dumps(SC3)) True
Functions: count,
iterator
self) |
TESTS:
sage: SC4 = SignedCompositions(4) sage: SC4.count() == len(SC4.list()) True sage: SignedCompositions(3).count() 18
self) |
TESTS:
sage: SignedCompositions(0).list() #indirect doctest [[]] sage: SignedCompositions(1).list() #indirect doctest [[1], [-1]] sage: SignedCompositions(2).list() #indirect doctest [[1, 1], [1, -1], [-1, 1], [-1, -1], [2], [-2]]
Special Functions: __contains__,
__init__,
__repr__
self, x) |
TESTS:
sage: [] in SignedCompositions(0) True sage: [0] in SignedCompositions(0) False sage: [2,1,3] in SignedCompositions(6) True sage: [-2, 1, -3] in SignedCompositions(6) True
self) |
TESTS:
sage: repr(SignedCompositions(3)) 'Signed compositions of 3'