Vec partitions

vec_partitions is a function that returns all partitions a given vector into a specified number of parts. Note that, for this function, the order of the parts does matter, but the order of the elements within the parts does not matter (for example, when partitioning the vector [1,2,3,4], the partition {[1],[2,3,4]} is the same as {[1],[3,2,4]}, but distinct from {[2,3,4],[1]}).

Syntax

 * PT = vec_partitions(V,P)
 * PT = vec_partitions(V,P,SZ)

Argument descriptions

 * V: A vector to be partitioned.
 * P</tt>: A positive integer: the number of parts to partition P</tt> into.
 * SZ</tt> (optional, default [1,1,...,1]</tt>): A vector such that only the partitions with the property that the j-th part contains at least SZ(j)</tt> elements (for all j) are returned.

Examples
The following code generates all 14 partitions of the vector [1,2,3,4]</tt> into two parts. It then displays two of those partitions (the first and sixth).