| Home | Trees | Indices | Help |
|---|
|
|
object --+
|
structure.sage_object.SageObject --+
|
CombinatorialClass
|
|||
| object_class | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from Inherited from |
|||
|
|||
|
Inherited from |
|||
|
|||
Returns the number of elements in the combinatorial class.
EXAMPLES:
sage: len(Partitions(5))
7
|
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
|
Returns a string representation of self.
EXAMPLES:
sage: str(Partitions(5))
'Partitions of the integer 5'
|
EXAMPLES:
sage: repr(Partitions(5))
'Partitions of the integer 5'
|
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
|
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]]
|
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
|
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
|
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
|
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
|
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]
|
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]
|
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]
|
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]
|
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]
|
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]
|
Default implementation of iterator.
EXAMPLES:
sage: C = CombinatorialClass()
sage: C.iterator()
Traceback (most recent call last):
...
NotImplementedError: iterator called but not implemented
|
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
|
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
|
Default implementation of random which uses unrank.
EXAMPLES:
sage: C = CombinatorialClass()
sage: C.list = lambda: [1,2,3]
sage: C.random_element()
1
|
Default implementation of random which uses unrank.
EXAMPLES:
sage: C = CombinatorialClass()
sage: C.list = lambda: [1,2,3]
sage: C.random_element()
1
|
Deprecated. Use self.random_element() instead.
EXAMPLES:
sage: C = CombinatorialClass()
sage: C.random()
Traceback (most recent call last):
...
NotImplementedError: Deprecated: use random_element() instead
|
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
|
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
|
Default implementation for first which uses iterator.
EXAMPLES:
sage: C = CombinatorialClass()
sage: C.list = lambda: [1,2,3]
sage: C.first() # indirect doctest
1
|
Default implementation for first which uses iterator.
EXAMPLES:
sage: C = CombinatorialClass()
sage: C.list = lambda: [1,2,3]
sage: C.first() # indirect doctest
1
|
Default implementation for first which uses iterator.
EXAMPLES:
sage: C = CombinatorialClass()
sage: C.list = lambda: [1,2,3]
sage: C.last() # indirect doctest
3
|
Default implementation for first which uses iterator.
EXAMPLES:
sage: C = CombinatorialClass()
sage: C.list = lambda: [1,2,3]
sage: C.last() # indirect doctest
3
|
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
|
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
|
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
|
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
|
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]]
|
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]]
|
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0beta1 on Thu Jul 17 04:23:32 2008 | http://epydoc.sourceforge.net |