Comparing partitions Partitions Building Advanced routines

Advanced routines

Generation of partitions: Very often you want to loop over all partitions, of a given weight. Look at the following lines:
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.
Here is the description: An analogous routine is And if you want to specify the kind of representation of the partition, there is also
first_part_VECTOR, first_part_EXPONENT
and
last_part_VECTOR, last_part_EXPONENT
which have the same parameters and produce the specified PARTITIONobjects.

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

next(),
which allows you to use the same object for input and output. Note that this is not allowed if you use the low level routine
next_partition().
For the output of a PARTITIONobject using the standard routines print, println or fprint and fprintln, you have to know the followiing convention:

The parts of size 10≤ size≤ 15 are printed as A,B,C,D,E,F and the parts bigger than 15 are printed with a ''|`` between the parts.

There is a routine for the generation of a vector of all partitions, look at the following example:
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.

The complete description is: If you are interested in the number of partitions, then look at the following example:
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();
}
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. a=150 will be no longer an INTEGERobject as for a=10, but a LONGINTobject. The next routine uses a recursive method described by Gupta: There is also a routine, which computes a table of these values: Very often we have to work with vectors or matrices labeled by partitions. So we need the index of a partition:
harald.fripertinger "at" uni-graz.at, May 26, 2011

Comparing partitions Partitions Building Uni-Graz Mathematik Advanced routines Valid HTML 4.0 Transitional Valid CSS!