Original Post
Ok i am back again with another stepping stone to this multi-dimensional array problem. i actually have gotten this to work successfully: i access the data successfully here and copy it over to a temp_array then return this array and basically what i have done is write out the data in this 4-D array backwards. thanks all for the help and after much paper i got this to work. what i would like to do to finish this off and make it less of a memory hog. that is dont use another array which is at least temporarily another copy of the original and just to reiterate we are talking about 8 million cells here. so as you can see i have commented out what i thought would work but unfortunately does not..that is trying to swap the data around in the array itself. i tried setting the outer loop to go half way but nothing much is accomplished by this. can anyone help? thanks a lot!
template <class T>
T *reverse_array(T *array, long x_size, long y_size, long depth_size, long time_size, int array_size)
{
int i, j, k, l;
int offset;
int count = 0;
T swap;
T *temp_array = new short[array_size];
std::cout << x_size << "x" << y_size << "x" << depth_size << "x" << time_size << endl;
for(l = 0; l < time_size; l++)
{
for(k = 0; k < depth_size; k++)
{
for(j = y_size; j > 0; j--)
{
offset = x_size * y_size * depth_size * l + (x_size * y_size * k) + (x_size * (j-1));
for(int x = 0; x < x_size; x++)
{
temp_array[count] = array[offset+x];
//swap = array[count];
//array[offset+x] = array[count];
//array[count] = swap;
count++;
}
}
}
}
return temp_array;
//return array;
}