Function: partitions
Section: combinatorics
C-Name: partitions
Prototype: LDGDG
Help: partitions(k,{a=k},{n=k}): vector of partitions of the integer k.
 You can restrict the length of the partitions with parameter n (n=nmax or
 n=[nmin,nmax]), or the range of the parts with parameter a (a=amax
 or a=[amin,amax]). By default remove zeros, but one can set amin=0 to get X of
 fixed length nmax (=k by default).
Description:
  (small,?gen,?gen):vecvecsmall partitions($1, $2, $3)
Doc: returns the vector of partitions of the integer $k$ as a sum of positive
 integers (parts); for $k < 0$, it returns the empty set \kbd{[]}, and for $k
 = 0$ the trivial partition (no parts). A partition is given by a
 \typ{VECSMALL}, where parts are sorted in nondecreasing order:
 \bprog
 ? partitions(3)
 %1 = [Vecsmall([3]), Vecsmall([1, 2]), Vecsmall([1, 1, 1])]
 @eprog\noindent correspond to $3$, $1+2$ and $1+1+1$. The number
 of (unrestricted) partitions of $k$ is given
 by \tet{numbpart}:
 \bprog
 ? #partitions(50)
 %1 = 204226
 ? numbpart(50)
 %2 = 204226
 @eprog

 \noindent Optional parameters $n$ and $a$ are as follows:

 \item $n=\var{nmax}$ (resp. $n=[\var{nmin},\var{nmax}]$) restricts
 partitions to length less than $\var{nmax}$ (resp. length between
 $\var{nmin}$ and $nmax$), where the \emph{length} is the number of nonzero
 entries.

 \item $a=\var{amax}$ (resp. $a=[\var{amin},\var{amax}]$) restricts the parts
 to integers less than $\var{amax}$ (resp. between $\var{amin}$ and
 $\var{amax}$).
 \bprog
 ? partitions(4, 2)  \\ parts bounded by 2
 %1 = [Vecsmall([2, 2]), Vecsmall([1, 1, 2]), Vecsmall([1, 1, 1, 1])]
 ? partitions(4,, 2) \\ at most 2 parts
 %2 = [Vecsmall([4]), Vecsmall([1, 3]), Vecsmall([2, 2])]
 ? partitions(4,[0,3], 2) \\ at most 2 parts
 %3 = [Vecsmall([1,3]), Vecsmall([2,2])]
 @eprog\noindent
 By default, parts are positive and we remove zero entries unless
 $amin\leq0$, in which case $nmin$ is ignored and we fix $\#X = \var{nmax}$:
 \bprog
 ? partitions(4, [0,3])  \\ parts between 0 and 3
 %1 = [Vecsmall([0, 0, 1, 3]), Vecsmall([0, 0, 2, 2]),\
       Vecsmall([0, 1, 1, 2]), Vecsmall([1, 1, 1, 1])]
 ? partitions(1, [0,3], [2,4]) \\ no partition with 2 to 4 nonzero parts
 %2 = []
 @eprog
