parts {partitions}R Documentation

Enumerate the partitions of an integer

Description

Given an integer, return a matrix whose columns enumerate its partitions.

Function parts() returns the unrestricted partions; function diffparts() returns the unequal partitions; function restrictedparts() returns the restricted partitions.

Usage

parts(n)
diffparts(n)
restrictedparts(n, m, include.zero=TRUE, decreasing=TRUE)

Arguments

n Integer to be partitioned
m In restrictedparts(), the order of the partition
include.zero In restrictedparts(), Boolean with default FALSE meaning to include only partitions of n into exactly m parts; and TRUE meaning to include partitions of n into at most m parts (because zero parts are included)
decreasing In restrictedparts(), Boolean with default TRUE meaning to return partitions whose parts are in decreasing order and FALSE meaning to return partitions in lexicographical order, as appearing in Hindenburg's algorithm. Note that setting to decreasing to FALSE has the effect of making conjugate() return garbage.

Details

Function parts() uses the algorithm in Andrews. Function diffparts() uses a very similar algorithm that I have not seen elsewhere.

Function restrictedparts() uses the algorithm in Andrews, originally due to Hindenburg. For partitions into at most m parts, the same Hindenburg's algorithm is used but with a start vector of c(rep(0,m-1),n).

Author(s)

Robin K. S. Hankin

References

G. E. Andrews. “The Theory of Partitions”, Cambridge University Press, 1998

Examples

parts(5)
diffparts(10)
restrictedparts(9,4)
restrictedparts(9,4,FALSE)
restrictedparts(9,4,decreasing=TRUE)

[Package partitions version 1.1-2 Index]