Package sage :: Package combinat :: Module combinat :: Class CombinatorialClass
[hide private]
[frames] | no frames]

Class CombinatorialClass

source code

                      object --+    
                               |    
structure.sage_object.SageObject --+
                                   |
                                  CombinatorialClass
Known Subclasses:
integer_vector.IntegerVectors_all, integer_vector.IntegerVectors_nkconstraints, integer_vector.IntegerVectors_nk, integer_vector.IntegerVectors_nnondescents, ribbon_tableau.RibbonTableaux_shapeweightlength, ribbon_tableau.SemistandardMultiSkewTtableaux_shapeweight, word.ShuffleProduct_overlapping, word.ShuffleProduct_overlapping_r, word.ShuffleProduct_w1w2, word.Words_all, word.Words_alphabet, word.Words_alphabetk, word.Words_n, parking_non_decreasing_function.ParkingNonDecreasingFunctions, FilteredCombinatorialClass, UnionCombinatorialClass, set_partition.SetPartitions_setparts, subset.Subsets_s, subset.Subsets_sk, ribbon.StandardRibbons_shape, multichoose_nk.MultichooseNK, graph_path.GraphPaths_all, graph_path.GraphPaths_s, graph_path.GraphPaths_st, graph_path.GraphPaths_t, choose_nk.ChooseNK, tuple.Tuples_sk, tuple.UnorderedTuples_sk, composition_signed.SignedCompositions_n, permutation.Permutations_msetk, permutation.Permutations_setk, permutation.CyclicPermutationsOfPartition_partition, permutation.CyclicPermutations_mset, permutation.Permutations_mset, permutation.Permutations_nk, permutation.Permutations_set, permutation.StandardPermutations_all, permutation.StandardPermutations_avoiding_12, permutation.StandardPermutations_avoiding_123, permutation.StandardPermutations_avoiding_132, permutation.StandardPermutations_avoiding_21, permutation.StandardPermutations_avoiding_213, permutation.StandardPermutations_avoiding_231, permutation.StandardPermutations_avoiding_312, permutation.StandardPermutations_avoiding_321, permutation.StandardPermutations_avoiding_generic, permutation.StandardPermutations_bruhat_greater, permutation.StandardPermutations_bruhat_smaller, permutation.StandardPermutations_descents, permutation.StandardPermutations_n, permutation.StandardPermutations_recoils, permutation.StandardPermutations_recoilsfatter, permutation.StandardPermutations_recoilsfiner, tableau.SemistandardTableaux_all, tableau.SemistandardTableaux_n, tableau.SemistandardTableaux_nmu, tableau.SemistandardTableaux_p, tableau.SemistandardTableaux_pmu, tableau.StandardTableaux_all, tableau.StandardTableaux_n, tableau.StandardTableaux_partition, tableau.Tableaux_all, tableau.Tableaux_n, split_nk.SplitNK_nk, family.AbstractFamily, necklace.Necklaces_evaluation, set_partition_ordered.OrderedSetPartitions_s, set_partition_ordered.OrderedSetPartitions_scomp, set_partition_ordered.OrderedSetPartitions_sn, partition.OrderedPartitions_nk, partition.PartitionTuples_nk, partition.PartitionsGreatestEQ_nk, partition.PartitionsGreatestLE_nk, partition.PartitionsInBox_hw, partition.Partitions_all, partition.Partitions_constraints, partition.Partitions_ending, partition.Partitions_n, partition.Partitions_starting, partition.RestrictedPartitions_nsk, lyndon_word.LyndonWords_evaluation, lyndon_word.LyndonWords_nk, lyndon_word.StandardBracketedLyndonWords_nk, cartesian_product.CartesianProduct_iters, finite_class.FiniteCombinatorialClass_l, combination.Combinations_mset, combination.Combinations_msetk, subword.Subwords_w, subword.Subwords_wk, integer_vector_weighted.WeightedIntegerVectors_nweight, restricted_growth.RestrictedGrowthArrays, partition_algebra.SetPartitionsAkhalf_k, composition.Compositions_all, composition.Compositions_constraints, composition.Compositions_n, alternating_sign_matrix.AlternatingSignMatrices_n, alternating_sign_matrix.ContreTableaux_n, alternating_sign_matrix.TruncatedStaircases_nlastcolumn, permutation_nk.PermutationsNK, skew_tableau.SemistandardSkewTableaux_all, skew_tableau.SemistandardSkewTableaux_n, skew_tableau.SemistandardSkewTableaux_nmu, skew_tableau.SemistandardSkewTableaux_p, skew_tableau.SemistandardSkewTableaux_pmu, skew_tableau.StandardSkewTableaux_all, skew_tableau.StandardSkewTableaux_n, skew_tableau.StandardSkewTableaux_skewpartition, dyck_word.DyckWords_all, dyck_word.DyckWords_size, skew_partition.SkewPartitions_all, skew_partition.SkewPartitions_n, skew_partition.SkewPartitions_rowlengths, sf.ns_macdonald.NonattackingFillings_shape, species.species.SpeciesWrapper, crystals.crystals.Crystal

Nested Classes [hide private]
  object_class
Instance Methods [hide private]
 
__len__(self)
Returns the number of elements in the combinatorial class.
source code
 
__getitem__(self, i)
Returns the combinatorial object of rank i.
source code
 
__str__(self)
Returns a string representation of self.
source code
 
__repr__(self)
EXAMPLES:...
source code
 
__contains__(self, x)
Tests whether or not the combinatorial class contains the object x.
source code
 
__iter__(self)
Allows the combinatorial class to be treated as an iterator.
source code
 
__cmp__(self, x)
Compares two different combinatorial classes.
source code
 
__count_from_iterator(self)
Default implmentation of count which just goes through the iterator of the combinatorial class to count the number of objects.
source code
 
count(self)
Default implmentation of count which just goes through the iterator of the combinatorial class to count the number of objects.
source code
 
__call__(self, x)
Returns x as an element of the combinatorial class's object class.
source code
 
__list_from_iterator(self)
The default implementation of list which builds the list from the iterator.
source code
 
list(self)
The default implementation of list which builds the list from the iterator.
source code
 
__iterator_from_next(self)
An iterator to use when .first() and .next() are provided.
source code
 
__iterator_from_previous(self)
An iterator to use when .last() and .previous() are provided.
source code
 
__iterator_from_unrank(self)
An iterator to use when .unrank() is provided.
source code
 
__iterator_from_list(self)
An iterator to use when .list() is provided()...
source code
 
iterator(self)
Default implementation of iterator.
source code
 
__unrank_from_iterator(self, r)
Default implementation of unrank which goes through the iterator.
source code
 
unrank(self, r)
Default implementation of unrank which goes through the iterator.
source code
 
__random_element_from_unrank(self)
Default implementation of random which uses unrank.
source code
 
random_element(self)
Default implementation of random which uses unrank.
source code
 
random(self)
Deprecated.
source code
 
__rank_from_iterator(self, obj)
Default implementation of rank which uses iterator.
source code
 
rank(self, obj)
Default implementation of rank which uses iterator.
source code
 
__first_from_iterator(self)
Default implementation for first which uses iterator.
source code
 
first(self)
Default implementation for first which uses iterator.
source code
 
__last_from_iterator(self)
Default implementation for first which uses iterator.
source code
 
last(self)
Default implementation for first which uses iterator.
source code
 
__next_from_iterator(self, obj)
Default implementation for next which uses iterator.
source code
 
next(self, obj)
Default implementation for next which uses iterator.
source code
 
__previous_from_iterator(self, obj)
Default implementation for next which uses iterator.
source code
 
previous(self, obj)
Default implementation for next which uses iterator.
source code
 
filter(self, f, name=['4ti2-20061025', 'R-2.6.0', 'atlas-3.7.37', 'atlas-3.8.1', 'a...)
Returns the combinatorial subclass of f which consists of the elements x of self such that f(x) is True.
source code
 
union(self, right_cc, name=['4ti2-20061025', 'R-2.6.0', 'atlas-3.7.37', 'atlas-3.8.1', 'a...)
Returns the combinatorial class representing the union of self and right_cc.
source code

Inherited from structure.sage_object.SageObject: __hash__, __new__, _axiom_, _axiom_init_, _gap_, _gap_init_, _gp_, _gp_init_, _interface_, _interface_init_, _interface_is_cached_, _kash_, _kash_init_, _macaulay2_, _macaulay2_init_, _magma_, _magma_init_, _maple_, _maple_init_, _mathematica_, _mathematica_init_, _maxima_, _maxima_init_, _octave_, _octave_init_, _pari_, _pari_init_, _r_init_, _sage_, _singular_, _singular_init_, category, db, dump, dumps, plot, rename, reset_name, save, version

Inherited from object: __delattr__, __getattribute__, __init__, __reduce__, __reduce_ex__, __setattr__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__len__(self)
(Length operator)

source code 

Returns the number of elements in the combinatorial class.

EXAMPLES:
    sage: len(Partitions(5))
    7

__getitem__(self, i)
(Indexing operator)

source code 

Returns the combinatorial object of rank i.

EXAMPLES:
    sage: p5 = Partitions(5)
    sage: p5[0]
    [5]
    sage: p5[6]
    [1, 1, 1, 1, 1]
    sage: p5[7]
    Traceback (most recent call last):
    ...
    ValueError: the value must be between 0 and 6 inclusive

__str__(self)
(Informal representation operator)

source code 

Returns a string representation of self.

EXAMPLES:
    sage: str(Partitions(5))
    'Partitions of the integer 5'

Overrides: object.__str__

__repr__(self)
(Representation operator)

source code 

EXAMPLES:
    sage: repr(Partitions(5))
    'Partitions of the integer 5'

Overrides: structure.sage_object.SageObject.__repr__

__contains__(self, x)
(In operator)

source code 

Tests whether or not the combinatorial class contains the
object x.  This raises a NotImplementedError as a default
since _all_ subclasses of CombinatorialClass should
override this.

Note that we could replace this with a default implementation
that just iterates through the elements of the combinatorial
class and checks for equality.  However, since we use __contains__
for type checking, this operation should be cheap and should be
implemented manually for each combinatorial class.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: x in C
    Traceback (most recent call last):
    ...
    NotImplementedError

__iter__(self)

source code 

Allows the combinatorial class to be treated as an iterator.

EXAMPLES:
    sage: p5 = Partitions(5)
    sage: [i for i in p5]
    [[5], [4, 1], [3, 2], [3, 1, 1], [2, 2, 1], [2, 1, 1, 1], [1, 1, 1, 1, 1]]

__cmp__(self, x)
(Comparison operator)

source code 

Compares two different combinatorial classes.  For now, the comparison
is done just on their repr's.

EXAMPLES:
    sage: p5 = Partitions(5)
    sage: p6 = Partitions(6)
    sage: repr(p5) == repr(p6)
    False
    sage: p5 == p6
    False

__count_from_iterator(self)

source code 

Default implmentation of count which just goes through the iterator
of the combinatorial class to count the number of objects.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: it = lambda: iter([1,2,3])
    sage: C.iterator = it
    sage: C.count() #indirect doctest
    3

count(self)

source code 

Default implmentation of count which just goes through the iterator
of the combinatorial class to count the number of objects.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: it = lambda: iter([1,2,3])
    sage: C.iterator = it
    sage: C.count() #indirect doctest
    3

__call__(self, x)
(Call operator)

source code 

Returns x as an element of the combinatorial class's object class.

EXAMPLES:
    sage: p5 = Partitions(5)
    sage: a = [2,2,1]
    sage: type(a)
    <type 'list'>
    sage: a = p5(a)
    sage: type(a)
    <class 'sage.combinat.partition.Partition_class'>
    sage: p5([2,1])
    Traceback (most recent call last):
    ...
    ValueError: [2, 1] not in Partitions of the integer 5

__list_from_iterator(self)

source code 

The default implementation of list which builds the list from
the iterator.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: it = lambda: iter([1,2,3])
    sage: C.iterator = it
    sage: C.list() #indirect doctest
    [1, 2, 3]

list(self)

source code 

The default implementation of list which builds the list from
the iterator.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: it = lambda: iter([1,2,3])
    sage: C.iterator = it
    sage: C.list() #indirect doctest
    [1, 2, 3]

__iterator_from_next(self)

source code 

An iterator to use when .first() and .next() are provided.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: C.first = lambda: 0
    sage: C.next  = lambda c: c+1
    sage: it = C.iterator() # indirect doctest
    sage: [it.next() for _ in range(4)]
    [0, 1, 2, 3]

__iterator_from_previous(self)

source code 

An iterator to use when .last() and .previous() are provided.
Note that this requires the combinatorial class to be finite.
It is not recommended to implement combinatorial classes
using last and previous.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: C.last = lambda: 4
    sage: def prev(c):
    ...       if c <= 1:
    ...           return None
    ...       else:
    ...           return c-1
    ...
    sage: C.previous  = prev
    sage: it = C.iterator() # indirect doctest
    sage: [it.next() for _ in range(4)]
    [1, 2, 3, 4]

__iterator_from_unrank(self)

source code 

An iterator to use when .unrank() is provided.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: l = [1,2,3]
    sage: C.unrank = lambda c: l[c]
    sage: list(C.iterator()) # indirect doctest
    [1, 2, 3]

__iterator_from_list(self)

source code 

An iterator to use when .list() is provided()

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: C.list = lambda: [1, 2, 3]
    sage: list(C.iterator()) # indirect doctest
    [1, 2, 3]

iterator(self)

source code 

Default implementation of iterator.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: C.iterator()
    Traceback (most recent call last):
    ...
    NotImplementedError: iterator called but not implemented

__unrank_from_iterator(self, r)

source code 

Default implementation of unrank which goes through the iterator.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: C.list = lambda: [1,2,3]
    sage: C.unrank(1) # indirect doctest
    2

unrank(self, r)

source code 

Default implementation of unrank which goes through the iterator.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: C.list = lambda: [1,2,3]
    sage: C.unrank(1) # indirect doctest
    2

__random_element_from_unrank(self)

source code 

Default implementation of random which uses unrank.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: C.list = lambda: [1,2,3]
    sage: C.random_element()
    1

random_element(self)

source code 

Default implementation of random which uses unrank.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: C.list = lambda: [1,2,3]
    sage: C.random_element()
    1

random(self)

source code 

Deprecated.  Use self.random_element() instead.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: C.random()
    Traceback (most recent call last):
    ...
    NotImplementedError: Deprecated: use random_element() instead

__rank_from_iterator(self, obj)

source code 

Default implementation of rank which uses iterator.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: C.list = lambda: [1,2,3]
    sage: C.rank(3) # indirect doctest
    2

rank(self, obj)

source code 

Default implementation of rank which uses iterator.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: C.list = lambda: [1,2,3]
    sage: C.rank(3) # indirect doctest
    2

__first_from_iterator(self)

source code 

Default implementation for first which uses iterator.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: C.list = lambda: [1,2,3]
    sage: C.first() # indirect doctest
    1

first(self)

source code 

Default implementation for first which uses iterator.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: C.list = lambda: [1,2,3]
    sage: C.first() # indirect doctest
    1

__last_from_iterator(self)

source code 

Default implementation for first which uses iterator.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: C.list = lambda: [1,2,3]
    sage: C.last() # indirect doctest
    3

last(self)

source code 

Default implementation for first which uses iterator.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: C.list = lambda: [1,2,3]
    sage: C.last() # indirect doctest
    3

__next_from_iterator(self, obj)

source code 

Default implementation for next which uses iterator.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: C.list = lambda: [1,2,3]
    sage: C.next(2) # indirect doctest
    3

next(self, obj)

source code 

Default implementation for next which uses iterator.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: C.list = lambda: [1,2,3]
    sage: C.next(2) # indirect doctest
    3

__previous_from_iterator(self, obj)

source code 

Default implementation for next which uses iterator.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: C.list = lambda: [1,2,3]
    sage: C.previous(2) # indirect doctest
    1

previous(self, obj)

source code 

Default implementation for next which uses iterator.

EXAMPLES:
    sage: C = CombinatorialClass()
    sage: C.list = lambda: [1,2,3]
    sage: C.previous(2) # indirect doctest
    1

filter(self, f, name=['4ti2-20061025', 'R-2.6.0', 'atlas-3.7.37', 'atlas-3.8.1', 'a...)

source code 

Returns the combinatorial subclass of f which consists of
the elements x of self such that f(x) is True.

EXAMPLES:
    sage: P = Permutations(3).filter(lambda x: x.avoids([1,2]))
    sage: P.list()
    [[3, 2, 1]]

union(self, right_cc, name=['4ti2-20061025', 'R-2.6.0', 'atlas-3.7.37', 'atlas-3.8.1', 'a...)

source code 

Returns the combinatorial class representing the union
of self and right_cc.

EXAMPLES:
    sage: P = Permutations(2).union(Permutations(1))
    sage: P.list()
    [[1, 2], [2, 1], [1]]