Iterator - Maple Programming Help

Online Help

All Products    Maple    MapleSim


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

Iterator

  

PartitionFixedSize

  

generate fixed-size partitions of an integer

 

Calling Sequence

Parameters

Options

Description

Notes

Examples

References

Compatibility

Calling Sequence

PartitionFixedSize(n, m, opts)

Parameters

n

-

posint; integer to partition

m

-

integer[2..n]; number of partitions

opts

-

(optional) equation(s) of the form option = value; specify options for the PartitionFixedSize command

Options

• 

compile = truefalse

  

True means compile the iterator. The default is true.

Description

• 

The PartitionFixedSize command returns an iterator that generates all integer m-tuples, a1,,am such that akak+1, am1, and k=1mak=n.

• 

The partitions are visited in colex order, that is, the reflected sequence am,,a1 is in lexicographic order.

• 

The n parameter specifies the integer to partition.

• 

The m parameter specifies the size of the partition. It must be lie in the range 2..n.

Notes

• 

The cost to run completely through this iterator is at most O3Nn,m+m, where Nn,m is the number of partitions of n of size m, cf. [1], theorem H, p. 50.

Examples

withIterator:

Construct an iterator to generate all 5-partitions of 12.

MPartitionFixedSize12,5:

forVinMdoprintf%d\n,Venddo:

8 1 1 1 1
7 2 1 1 1
6 3 1 1 1
5 4 1 1 1
6 2 2 1 1
5 3 2 1 1
4 4 2 1 1
4 3 3 1 1
5 2 2 2 1
4 3 2 2 1
3 3 3 2 1
4 2 2 2 2
3 3 2 2 2

References

  

1. Knuth, Donald Ervin. The Art of Computer Programming, volume 4, fascicle 3; generating all combinations and partitions, sec. 7.2.1.4, generating all partitions, algorithm H, partitions into m parts, p. 38.

Compatibility

• 

The Iterator[PartitionFixedSize] command was introduced in Maple 2016.

• 

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

See Also

combinat[numbpart]

Iterator

Iterator[Partition]

Iterator[SetPartitions]