F
fivelitermustang
Actually, how would I go about allocating a four-dimensional dynamic
array?
I only know how to make two dimensional dynamic arrays:
double **v;
v = new double*[C];
for (int i=0; i<C; i++)
{
v = new double[n];
}
Well my plans have changed a bit and I need to make an array to store
matrices "v" (like the one I allocated above with dynamic dimensions C*n).
I'm not going to use the code above... I want to allocate all four
dimensions in one snippet. It needs to be done in a similar manner because
I'm not sure that the memory will be contiguous.
What I want to do is have an array going a variable number of levels deep,
and the row after the previous will have "n" times the amount of matrices
"v".
For example... if n was 3:
On the first row there would contain 1 matrix "v".
On the second row there would contain 3 matrix "v".
On the third row there would contain 9 matrix "v".
In the program I am writing it would be convenient to access these members
like this:
example:
[1, 2, 1, 2]
This would correlate to the matrix v found on the second row and third
column of this matrix. It would access the second row and third column of
the member v that was seleced by the first two parameters)
array?
I only know how to make two dimensional dynamic arrays:
double **v;
v = new double*[C];
for (int i=0; i<C; i++)
{
v = new double[n];
}
Well my plans have changed a bit and I need to make an array to store
matrices "v" (like the one I allocated above with dynamic dimensions C*n).
I'm not going to use the code above... I want to allocate all four
dimensions in one snippet. It needs to be done in a similar manner because
I'm not sure that the memory will be contiguous.
What I want to do is have an array going a variable number of levels deep,
and the row after the previous will have "n" times the amount of matrices
"v".
For example... if n was 3:
On the first row there would contain 1 matrix "v".
On the second row there would contain 3 matrix "v".
On the third row there would contain 9 matrix "v".
In the program I am writing it would be convenient to access these members
like this:
example:
[1, 2, 1, 2]
This would correlate to the matrix v found on the second row and third
column of this matrix. It would access the second row and third column of
the member v that was seleced by the first two parameters)