DESCRIPTION

Integer::Partition takes an integer number and produces an object that can be used to generate all possible integer partitions of the original number in either forward or reverse lexicographic order.

METHODS

new

Creates a new Integer::Partition object. Takes an integer as a parameter. By default, the partitions appear in reverse order, as the algorithm is slightly faster. Forward ordering uses a different, slightly slower algorithm (which is nonetheless much faster than any existing algorithm).

next

Returns the partition, or undef when all partitions have been generated.

reset

Resets the object, which causes it to enumerate the arrangements from the beginning.

$p->reset; # begin again

DIAGNOSTICS

missing or undefined input

The new() method was called without an input parameter, which should be a positive integer.

n is not a positive integer

The new() method was called with zero or a negative integer.

n is not an integer

The new() method was called with a number containing a decimal component. Use int or sprintf '%d' on the input if necessary.

NOTES

This module implements the Zoghbi and Stojmenovic ZS1 and ZS2 algorithms for generating integer partitions. See http://www.site.uottawa.ca/~ivan/F49-int-part.pdf for more information. These algorithms have been proven to have constant average delay, that is, the amount of effort it takes to produce the next result in the series.

They are the fastest known algorithms known for generating integer partitions (with the ZS1 reverse lexicographic order algorithm being slightly faster than the ZS2 lexicographic order algorithm).