A
Akyl Tulegenov
Dear All!
this is a construct I use to create the tensor of rank 2 in C.
double **dtensor2(long nl1,long nh1,long nl2,long nh2){
double **tensor=NULL;
long i1,i2;
tensor=(double **)calloc((nh1-nl1+2), sizeof (*tensor));
if(nl1!=0) tensor=tensor-nl1+1;
for(i1=nl1;i1<=nh1;i1++){
tensor[i1]=(double *)calloc((nh2-nl2+2), sizeof (*tensor[0]));
if(nl2!=0) tensor[i1]=tensor[i1]-nl2+1;
}
return tensor;
}
Can anybody show how it would look in C++ (when "new" is used)? Any
additional comments on whether it is feasible to use "new" instead of
calloc are extremely invited.
Thanks,
Akyl Tulegenov.
________________________________________________________________________
-= For every properly stated question there exists a definite answer. =-
L.Wittgenstein
this is a construct I use to create the tensor of rank 2 in C.
double **dtensor2(long nl1,long nh1,long nl2,long nh2){
double **tensor=NULL;
long i1,i2;
tensor=(double **)calloc((nh1-nl1+2), sizeof (*tensor));
if(nl1!=0) tensor=tensor-nl1+1;
for(i1=nl1;i1<=nh1;i1++){
tensor[i1]=(double *)calloc((nh2-nl2+2), sizeof (*tensor[0]));
if(nl2!=0) tensor[i1]=tensor[i1]-nl2+1;
}
return tensor;
}
Can anybody show how it would look in C++ (when "new" is used)? Any
additional comments on whether it is feasible to use "new" instead of
calloc are extremely invited.
Thanks,
Akyl Tulegenov.
________________________________________________________________________
-= For every properly stated question there exists a definite answer. =-
L.Wittgenstein