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

Online Help

All Products    Maple    MapleSim


Iterator

  

PartitionPartCount

  

generate partitions of an integer in part-count form

 

Calling Sequence

Parameters

Options

Description

Examples

References

Compatibility

Calling Sequence

PartitionPartCount(n, opts)

Parameters

n

-

nonnegint; integer to partition

opts

-

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

Options

• 

compile = truefalse

  

True means compile the iterator. The default is true.

Description

• 

The PartitionPartCount command returns an iterator that generates all partitions of the integer n in part-count form, in reverse lexicographic order.

• 

A partition of integer n in part-count form is a sequence of integers c1,,cn such that n=k=1nkck and 0ckn for k1,,n.

• 

The n parameter is the integer to partition.

• 

The output of the iterator is an array of fixed length n.

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

withIterator:

Iterate through the partitions of 8.

n8:

PPartitionPartCountn:

PrintP,showrank:

 1: 8 0 0 0 0 0 0 0
 2: 6 1 0 0 0 0 0 0
 3: 4 2 0 0 0 0 0 0
 4: 2 3 0 0 0 0 0 0
 5: 0 4 0 0 0 0 0 0
 6: 5 0 1 0 0 0 0 0
 7: 3 1 1 0 0 0 0 0
 8: 1 2 1 0 0 0 0 0
 9: 2 0 2 0 0 0 0 0
10: 0 1 2 0 0 0 0 0
11: 4 0 0 1 0 0 0 0
12: 2 1 0 1 0 0 0 0
13: 0 2 0 1 0 0 0 0
14: 1 0 1 1 0 0 0 0
15: 0 0 0 2 0 0 0 0
16: 3 0 0 0 1 0 0 0
17: 1 1 0 0 1 0 0 0
18: 0 0 1 0 1 0 0 0
19: 2 0 0 0 0 1 0 0
20: 0 1 0 0 0 1 0 0
21: 1 0 0 0 0 0 1 0
22: 0 0 0 0 0 0 0 1

Compute the number of iterations.

NumberP

22

(1)

Add the elements of each partition to verify they sum to n.

seqaddkpk,k=1..n,p=P

8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8

(2)

References

  

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 C, p. 110, ex. 5.

Compatibility

• 

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

• 

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

• 

The Iterator[PartitionPartCount] command was updated in Maple 2022.

• 

The n parameter was updated in Maple 2022.

See Also

combinat[numbpart]

Iterator

Iterator[MultiPartition]

Iterator[Partition]

Iterator[PartitionFixedSize]

Iterator[SetPartitions]