Integer partitions

版本 1.3.0.0 (1.7 KB) 作者: Hin Kwan Wong
Finds all partitions of a set containing homogenous elements, also called integer partitions.
492.0 次下载
更新时间 2013/12/2

查看许可证

This is similar to submission "24185-partitions" in the exchange, but with the set containing identical elements. The partitioning is a also a way of writing the input n as a sum of positive integers.

An optional argument s can be supplied to output a subset of partitions with number of parts less than or equal to s.

The number of ways of partitioning is according to the sequence
http://oeis.org/A000041

Example 1: intpartition(4) gives {[1 1 1 1],[1 1 2],[1 3],[2 2],4}
Example 2: intpartition(10,2) gives {[3,7],[4,6],[5,5],10}

引用格式

Hin Kwan Wong (2024). Integer partitions (https://www.mathworks.com/matlabcentral/fileexchange/33616-integer-partitions), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2010b
兼容任何版本
平台兼容性
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.3.0.0

--Added optional parameter s to specify maximum size of the partitions.
--Updated to more efficient code (~5x speed), as an unintended consequence, the ordering of partitions in the output cell is changed from the older version.

1.1.0.0

corrected description

1.0.0.0