 Set Partition Fixed Size - Maple Help

Iterator

 SetPartitionFixedSize
 generate fixed-size partitions of a set Calling Sequence SetPartitionFixedSize(s, opts) Parameters

 s - list(posint); size of each subset opts - (optional) equation(s) of the form option = value; specify options for the SetPartitionFixedSize command Options

 • compile = truefalse
 True means compile the iterator. The default is true. Description

 • 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 positive integers that specify the size of each subset of a partition.
 • 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 ${S}_{k}=1+\left(\sum _{j=1}^{k-1}{s}_{j}\right)$, then the k-th subset corresponds to the indices ${S}_{k}..{S}_{k+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. Examples

 > $\mathrm{with}\left(\mathrm{Iterator}\right):$

Partition the set of integers $\left\{1,2,3,4,5\right\}$ into subsets of sizes 2, 1, and 2.

 > $F≔\mathrm{SetPartitionFixedSize}\left(\left[2,1,2\right]\right):$

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.

 > $\mathrm{Print}\left(F,'\mathrm{showrank}'\right):$
 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.

 > $\mathrm{Number}\left(F\right)$
 ${15}$ (1) References

 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. Compatibility

 • The Iterator[SetPartitionFixedSize] command was introduced in Maple 2016.