Function parts() returns the unrestricted partions; function
diffparts() returns the unequal partitions; function
restrictedparts() returns the restricted partitions; function
blockparts() returns the partitions subject to specified
maxima; and function compositions() returns all compositions
of the argument.
parts(n)
diffparts(n)
restrictedparts(n, m, include.zero=TRUE, decreasing=TRUE)
blockparts(f, n=NULL, include.fewer=FALSE)
compositions(n, m=NULL, include.zero=TRUE)blockparts(),
the default of NULL means to return all partitions of any sizerestrictedparts(), the order of the partitionrestrictedparts() and
compositions(), Boolean with default FALSE meaning to
include only partitions of $n$ into exactly $m$
parts; and TRUE meaning to include partitionsblockparts(), Boolean with
default FALSE meaning to return vectors whose sum is
exactly n and TRUE meaning to return partitions
whose sum is at most nrestrictedparts(), 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 Hindenburgblockparts(), a vector of strictly
positive integers that gives the maximal number of blocks; see
detailsparts() uses the algorithm in Andrews. Function
diffparts() uses a very similar algorithm that I have not seen
elsewhere. These functions behave strangely if given an argument of
zero. 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,\ldots,y_n)$ all sets of
$a=(a_1,\ldots,a_n)$ satisfying
$\sum_{i=1}^pa_i=n$ subect to $0
If n takes its default value of NULL, then
$\sum_{i=1}^pa_i=n$ is removed (the numbers may sum to
anything). Note that these solutions are not necessarily in standard
form, so functions durfee() and conjugate() may fail.
Function compositions() returns all $2^n$ ways of partitioning
an integer; thus 4+1+1 is distinct from 1+4+1 or
1+1+4. This function is different from all the others in the
package in that it is written in R; it is not clear that C
would be any faster.
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)
compositions(3)Run the code above in your browser using DataLab