Hello Constantin,
This is one of cint limitation. Here are a couple of workarounds.
# WORKAROUND1, using dynamic array allocation feature
Cint allows to allocate dynamic array if declared in command line or
unnamed macro. Using this feature, your macro can be simply written
as follows.
{
float *x;
int i,j,k;
int fnummer=5;
int kappanr=10;
int tnr=20;
// dynamic array can be allocated only within unnamed macro
float y[fnummer][kappanr][tnr];
x=new float[tnr];
for(i=0;i<tnr;i++) x[i]=i;
for(i=0;i<fnummer;i++){
for(j=0;j<kappanr;j++) {
for(k=0;k<tnr;k++){
y[i][j][k]= i*10000+j*100+k;
printf("%f ",y[i][j][k]);
}
}
}
printf("test finished\n");
for(i=0;i<fnummer;i++){
for(j=0;j<kappanr;j++) {
for(k=0;k<tnr;k++){
if(y[i][j][k] != i*10000+j*100+k) printf("error\n");
}
}
}
printf("test finished\n");
}
# WORKAROUND2, using temp pointer
If you want the code to be both compiled and interpreted, you need to
use temp pointer variable as follows.
{
float *x;
float ***y,**ppy,*py;
int i,j,k;
int fnummer=5;
int kappanr=10;
int tnr=20;
x=new float[tnr];
for(i=0;i<tnr;i++) x[i]=i;
y=new float**[fnummer];
for(i=0;i<fnummer;i++){
y[i]=new float*[kappanr];
ppy = y[i];
for(j=0;j<kappanr;j++) {
ppy[j] =new float[tnr];
py = ppy[j];
for(k=0;k<tnr;k++){
py[k] = i*10000+j*100+k;
printf("%f ",py[k]);
}
}
}
printf("test finished\n");
for(i=0;i<fnummer;i++){
ppy = y[i];
for(j=0;j<kappanr;j++) {
py = ppy[j];
for(k=0;k<tnr;k++){
if(py[k] != i*10000+j*100+k) printf("error\n");
}
}
}
printf("test finished\n");
}
Thank you
Masaharu Goto
>
>Hallo,
>it seems, that CINT can't handle the following piece of code:
>
>{
> float *x;
> float ***y;
> int i,j,k;
> int fnummer=5;
> int kappanr=10;
> int tnr=20;
> x=new float[tnr];
> for(i=0;i<tnr;i++) x[i]=i;
> y=new float**[fnummer];
> for(i=0;i<fnummer;i++){
> y[i]=new float*[kappanr];
> for(j=0;j<kappanr;j++)
> {
> y[i][j]=new float[tnr];
> for(k=0;k<tnr;k++){
> y[i][j][k]=0;
> printf("%f ",y[i][j][k]);
> }
> }
> }
> printf("test finished\n");
>}
>
>The code works perfectly with gcc 2.91. I am using
>CINT which came with
>Root Version 2.20/06 18 December 1998.
>Is there anything I can do to make that run?
>
>Thanks,
>C. Loizides
>
>------------------------------------------------------------------
>Institut fuer Theoretische Physik
>Tel: +49-69-798-22552
>
>PGP: http://www.rz.uni-frankfurt.de/~loizides/pgp/pgp.html
>
>
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:17 MET