Iterator - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Mathematics : Discrete Mathematics : Combinatorics : Iterator : Iterator/SetPartitionFixedSize

Iterator

  

SetPartitionFixedSize

  

generate fixed partitions of a set

 

Calling Sequence

Parameters

Options

Description

Examples

References

Compatibility

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 Sk=1+j=1k1sj, then the k-th subset corresponds to the indices Sk..Sk+11.

Methods

The 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

withIterator:

Partition the set of integers 1,2,3,4,5 into subsets of sizes 2, 1, and 2.

FSetPartitionFixedSize2,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.

forfinFdoprintf%{}d\n,fenddo:

1 2 3 4 5
1 2 4 3 5
1 2 5 3 4
1 3 4 2 5
1 3 5 2 4
1 4 5 2 3
1 3 2 4 5
1 4 2 3 5
1 5 2 3 4
1 4 3 2 5
1 5 3 2 4
1 5 4 2 3
2 3 1 4 5
2 4 1 3 5
2 5 1 3 4

Compute the number of iterations.

NumberF

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.

• 

For more information on Maple 2016 changes, see Updates in Maple 2016.

See Also

Iterator

Iterator[SetPartitions]