File Exchange

image thumbnail

Set partition

version 1.6 (6.99 KB) by

List all partitions a set n elements

7 Downloads

Updated

View License

A set of of n elements can be partitioned in non empty subsets.

This package provide function to list all possible partitions. The number of partition is Bell's number.

The number of subsets that composed the partitions can be optionally specified. The number of partition is Stirling's number of the second kind.

Comments and Ratings (7)

Alex Saja

Thank you a lot! I needed these functions in my Optimization project

Thanks Bruno!!

antdambr

Excellent codes, really fast!!

Alessandro

Is there an easy way to generate the partitions incrementally? I mean I'd like to use it for big N so it would be great if there was a way to generate a different partition a time, because of space limits.

Thanks!

Loginatorist

Loginatorist (view profile)

Very nice: smartly coded, fast, well implemented.

Bruno Luong

Bruno Luong (view profile)

Darren, thank you for the suggestion. I'll add an example of usage. Functions with more efficient engine will be soon upgraded.

At last someone has implemented this functionality. Excellent!
I would only suggest that an example of usage and output could be helpful in the SetPartition file and that the first few lines of Bell and Stirling2nd could be rearranged to give meaningful H1 lines.

Updates

1.6

Partitions display function

1.5

Possibility to partition generic set elements (following Matt Fig's idea). New function to replace elements of a standard set partitioning list

1.2

Correct a BUG for N=0. Minor speed improvement.

1.1

Improve engine and example usage in the help as suggested Darren Rowland

MATLAB Release
MATLAB 7.8 (R2009a)
Acknowledgements

Inspired: PARTITIONS

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video