next up previous contents index
Next: Useful functions in the Up: Other useful functions in Previous: Other useful functions in   Contents   Index


Memory management

The library contains some functions which can be used to create and delete easily arrays. The type of variables are the same as for objects (cf. 6):


Type 0 : integers

Type 1 : simple precision real numbers

Type 2 : double precision real numbers

Type 3 : simple precision complex numbers with usual coordinates

Type 4 : double precision complex numbers with usual coordinates

Type 5 : simple precision complex numbers with polar coordinates

Type 6 : double precision complex numbers with polar coordinates


(the way complex numbers are represented is explained in 13). The functions avalaible to create arrays are the following :

int*           int_alloc1(int);
int**          int_alloc2(int, int);
int***         int_alloc3(int, int, int);
int****        int_alloc4(int, int, int, int);
float*         float_alloc1(int);
float**        float_alloc2(int, int);
float***       float_alloc3(int, int, int);
float****      float_alloc4(int, int, int, int);
double*        double_alloc1(int);
double**       double_alloc2(int, int);
double***      double_alloc3(int, int, int);
double****     double_alloc4(int, int, int, int);
fcomplex*      fcomplex_alloc1(int);
fcomplex**     fcomplex_alloc2(int, int);
fcomplex***    fcomplex_alloc3(int, int, int);
fcomplex****   fcomplex_alloc4(int, int, int, int);
dcomplex*      dcomplex_alloc1(int);
dcomplex**     dcomplex_alloc2(int, int);
dcomplex***    dcomplex_alloc3(int, int, int);
dcomplex****   dcomplex_alloc4(int, int, int, int);
fpolaire*      fpolaire_alloc1(int);
fpolaire**     fpolaire_alloc2(int, int);
fpolaire***    fpolaire_alloc3(int, int, int);
fpolaire****   fpolaire_alloc4(int, int, int, int);
dpolaire*      dpolaire_alloc1(int);
dpolaire**     dpolaire_alloc2(int, int);
dpolaire***    dpolaire_alloc3(int, int, int);
dpolaire****   dpolaire_alloc4(int, int, int, int);

The types fcomplex, dcomplex, fpolaire, dpolaire represent complex numbers (cf. 13). The number in the name of the function gives the number of dimensions of the created array. The parameters are the dimensions (which must be positive) (the indices which are allowed in such an array can vary between 0 and the given dimensions). For instance

float ***xx;

xx = float_alloc3(2,4,3);

will create a 3-dimensional array. The indices allowed for the first dimension can be 0, 1, or 2, and so on. There is a unique function to delete all such arrays. It is the macro XFREE.

XFREE(xx);

will free the memory used to store the array xx.

It is possible to create arrays with more than 4 dimensions, using the function

memm* memm_alloc(int*, int, int);

(the structure memm is defined in the file interp.h). To create an array with n dimensions we need for an array d which contain the dimensions of the array : d[0],...,d[n] must be positive numbers. Then we create a memm structure :

memm* M;

M = memm_alloc(d, n, type);

where type is the type of variables of the array (an integer between 0 and 6). To get the array we use then member ad of the structure M[0]. For instance, if it is an array of double precision real numbers with 5 dimensions (i.e n=5 and type=2) we have

double *****xx;

xx = (double*****) M[0].ad;


next up previous contents index
Next: Useful functions in the Up: Other useful functions in Previous: Other useful functions in   Contents   Index
2009-11-12