get.partitions: Additive partitioning of natural numbers

View source: R/partitioning.R

get.partitionsR Documentation

Additive partitioning of natural numbers

Description

This function solves the problem of additive partitioning of positive integers. The approach for additive partitioning is based on a generating function discussed in details in Voinov and Nikulin (1995). The function enumerates all partitions of a positive integer n on at most (or exactly) M parts, M <= n.

Usage

 get.partitions(n, M, at.most=TRUE)

Arguments

n

A positive integer to be partitioned.

M

A positive integer, the number of parts of n, M <= n.

at.most

If TRUE then partitioning of n into at most M parts, if FALSE then partitioning on exactly M parts.

Value

p.n

total number of partitions obtained.

partitions

a matrix with each column presenting partitions of n.

Author(s)

Vassilly Voinov, Natalya Pya Arnqvist, Yevgeniy Voinov

References

Voinov, V. and Nikulin, M. (1995) Generating functions, problems of additive number theory, and some statistical applications. Revue Roumaine de Mathématiques Pures et Appliquées, 40(2), 107-147

Voinov, V.G. and Pya, N.E. (2017) R-software for additive partitioning of positive integers. Mathematical Journal (ISSN 1682-0525) 17(1), 69-76.

See Also

nilde-package, get.knapsack, get.subsetsum, nlde

Examples

## getting all partitions of n = 8 on at most 6 parts...
get.partitions(8,6,at.most=TRUE)

## getting all partitions of n = 8 on exactly 6 parts...
b <- get.partitions(8,6,at.most=FALSE)
b
colSums(b$partitions)


nilde documentation built on Aug. 16, 2022, 5:05 p.m.