Advanced routines |

Here is the description:Example:#include "def.h" #include "macro.h" main() { OP a,b; anfang(); a = callocobject(); b = callocobject(); scan(INTEGER,a); first_partition(a,b); do { println(b); } while (next(b,b)); freeall(a); freeall(b); ende(); }which is a program which first asks the weight, and then prints a list of all partitions of that weight.

- NAME:
*first_partition* - SYNOPSIS:
*INT first_partition(OP n, result)* - DESCRIPTION:
*n*must be an INTEGERobject, and result becomes the PARTITIONobject of VECTOR kind, which is the first one according to many orders of partitions, namely the partition*[n].*

- NAME:
*last_partition* - SYNOPSIS:
*INT last_partition(OP n, result)* - DESCRIPTION:
*n*must be an INTEGERobject, and*result*becomes the PARTITIONobject of VECTORkind, which is the last one according to many orders of partitions, namely the partition*[1*^{n}].

andfirst_part_VECTOR, first_part_EXPONENT

which have the same parameters and produce the specified PARTITIONobjects.last_part_VECTOR, last_part_EXPONENT

In order to generate the next partition you should use the standardroutine

which allows you to use the same object fornext(),

For the output of a PARTITIONobject using the standard routinesnext_partition().

The complete description is:Example:... scan(INTEGER,a); makevectorofpart(a,b); println(b); println(s_v_i(b,s_v_li(b)-1L)); ...which prints a vector with all partitions of given weight, and then in the next line it will print the last partition of the specified weight.

- NAME:
*makevectorofpart*gives a vector of partitions - SYNOPSIS:
*INT makevectorofpart(OP n, result)* - DESCRIPTION:
*n*must be an INTEGERobject, and*result*becomes a VECTORobject of PARTITIONobjects. The order is according to the order of*next().*The PARTITIONobjects are of the kind VECTOR.

This program prints the number of partitions of weight up to 199. As you know this is quite a big number, and the result for e.g.Example:#include "def.h" #include "macro.h" main() { INT i; OP a,b; anfang(); a = callocobject(); b = callocobject(); for (i=1L;i<200L;i++) { freeself(a); freeself(b); M_I_I(i,a); numberofpart(a,b); print (a) ; println(b); } freeall(a); freeall(b); ende(); }

- NAME:
*numberofpart*means*number_of_partitions,*while the name*numberofpart_i*abbreviates*number_of_partitions_as_an_INTvalue* - SYNOPSIS:
*INT numberofpart(OP n, result)**INT numberofpart_i(OP n)* - DESCRIPTION:
*numberofpart*computes the number of partitions of the given weight*n,*which must be an INTEGERobject. The result is an INTEGERobject, or a LONGINTobject, depending on the size of*n.**numberofpart_i*gives the number of partitions as the*return_value,*and so it works only for small sizes of*n*only. - RETURN:
*numberofpart_i*returns the number of partitions or ERROR*numberofpart*returns OK or ERROR.

- NAME:
*gupta_nm* - SYNOPSIS:
*INT gupta_nm(OP n,m,erg)* - DESCRIPTION: this routine computes the number of partitions
of
*n*with maximal part*m.*The result is*erg.*The input*n,m*must be INTEGERobjects. The result is freed first to an empty object. The result must be different from*m*and*n.* - RETURN: OK

- NAME:
*gupta_tafel* - SYNOPSIS:
*INT gupta_tafel(OP max, result)* - DESCRIPTION: it computes the table of the above values. The entry
*n,m*is the result of*gupta_nm.**result*is freed first.*max*must be an INTEGERobject, it is the maximum weight for the partitions.*max*must be different from*result.* - RETURN: OK

- NAME:
*indexofpart* - SYNOPSIS:
*INT indexofpart(OP part)* - DESCRIPTION: computes the index of a partition. The algorithm used
is the same as in
*next_partition.*So the partition given by*first_partition*has the index 0. - RETURN: The
*index*of the partition, or ERROR

harald.fripertinger@kfunigraz.ac.at,

last changed: November 19, 2001

Advanced routines |