Iterator
SetPartitionFixedSize
generate fixed-size partitions of a set
Calling Sequence
Parameters
Options
Description
Examples
References
Compatibility
SetPartitionFixedSize(s, opts)
s
-
list(nonnegint); size of each subset
opts
(optional) equation(s) of the form option = value; specify options for the SetPartitionFixedSize command
compile = truefalse
True means compile the iterator. The default is true.
The SetPartitionFixedSize command returns an iterator that generates fixed-size partitions of the set of integers starting at one. A partition of a set is a division of the set into disjoint subsets whose union is the set. A fixed-size partition fixes the sizes and number of the partitions.
The s parameter is a list of nonnegative integers that specify the size of each subset of a partition. Any zeros in s have no effect on the output.
The iterator output is a permutation of the integers from one to n, where n is the sum of the sizes of the subsets. Let Sk=1+∑j=1k−1⁡sj, then the k-th subset corresponds to the indices Sk..Sk+1−1.
Methods
In addition to the common iterator methods, this iterator object has the following methods. The self parameter is the iterator object.
Number(self): return the number of iterations required to step through the iterator, assuming it started at rank one.
with⁡Iterator:
Partition the set of integers 1,2,3,4,5 into subsets of sizes 2, 1, and 2.
F≔SetPartitionFixedSize⁡2,1,2:
Print the vectors corresponding to the partitions. Indices 1 and 2 contain the first subset, index 3 the second, and indices 4 and 5 the third.
Print⁡F,showrank:
1: 1 2 3 4 5 2: 1 2 4 3 5 3: 1 2 5 3 4 4: 1 3 4 2 5 5: 1 3 5 2 4 6: 1 4 5 2 3 7: 1 3 2 4 5 8: 1 4 2 3 5 9: 1 5 2 3 4 10: 1 4 3 2 5 11: 1 5 3 2 4 12: 1 5 4 2 3 13: 2 3 1 4 5 14: 2 4 1 3 5 15: 2 5 1 3 4
Compute the number of iterations.
Number⁡F
15
Knuth, Donald Ervin. The Art of Computer Programming, volume 4, fascicle 3; generating all combinations and partitions, sec. 7.2.1.5, generating all set partitions, fixed sizes, exercise 6, pp. 78 and 125.
The Iterator[SetPartitionFixedSize] command was introduced in Maple 2016.
For more information on Maple 2016 changes, see Updates in Maple 2016.
The Iterator[SetPartitionFixedSize] command was updated in Maple 2022.
The s parameter was updated in Maple 2022.
See Also
Iterator[SetPartitions]
Download Help Document