I'm trying to program tensorial algebra, for which I need some arrays whose dimension will be unknown when compiling (please, recall that text within square brackets is NOT actual code):
float [undetermined number of *'s] element; //elements of the tensor
unsigned int co_index;
unsigned int contra_index;
unsigned int N;
Where "element" variable has as many "*" symbols as (co_index + contra_index); is there a way to do this, define the "dimension" of "element" variable at execution time?
An example of what I mean: if (co_index + contra_index = 3), the memory allocation for "element" should look like:
elemento = (float***)malloc(sizeof(float**) * N);
for(i=0;i<N;i++)
elemento[i]=(float**)malloc(sizeof(float*) * N);
for(i=0;i<N;i++)
{
for(j=0;j<N;j++)
elemento[i][j]=(float*)malloc(sizeof(float) * N);
}
Can this "floating dimension" array be defined in general at execution time?