SetPartitionFixedSize - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Iterator

  

SetPartitionFixedSize

  

generate fixed-size partitions of a set

 

Calling Sequence

Parameters

Options

Description

Examples

References

Compatibility

Calling Sequence

SetPartitionFixedSize(s, opts)

Parameters

s

-

list(nonnegint); 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 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 , then the k-th subset corresponds to the indices .

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

Partition the set of integers  into subsets of sizes 2, 1, and 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.

 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.

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

• 

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

Iterator[SetPartitions]

 


Download Help Document