parts {partitions} | R Documentation |
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 and
function blockparts()
returns the partitions subject to
specified maxima.
parts(n) diffparts(n) restrictedparts(n, m, include.zero=TRUE, decreasing=TRUE) blockparts(f, n=NULL, include.fewer=FALSE)
n |
Integer to be partitioned. In function blockparts() ,
the default of NULL means to return all partitions of any size |
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) |
include.fewer |
In function blockparts() , Boolean with
default FALSE meaning to return partitions into
exactly n and TRUE meaning to return partitions
into at most n |
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 |
f |
In function blockparts() , a vector of strictly
positive integers that gives the maximal number of blocks; see
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)
.
Function blockparts()
enumerates the compositions of an integer
subject to a maximum criterion: given vector
y=(y_1,...,y_p) all sets of
a=(a_1,...,a_p) satisfying
sum(a_i)=n subect to 0<a_i<y_i for all i are given in lexicographical order.
If argument y
includes zero elements, these are treated
consistently (ie a position with zero capacity).
If n
takes its default value of NULL
, then
sum(a_i)=n is replaced by
sum(a_i)<=n. Note that these solutions
are not necessarily in standard form, so functions durfee()
and
conjugate()
may fail.
Robin K. S. Hankin
G. E. Andrews. “The Theory of Partitions”, Cambridge University Press, 1998
parts(5) diffparts(10) restrictedparts(9,4) restrictedparts(9,4,FALSE) restrictedparts(9,4,decreasing=TRUE) blockparts(1:4) blockparts(1:4,3) blockparts(1:4,3,include.fewer=TRUE)