I have three questions about three nested loops:
for (int x=0; x<400; x++)
{
for (int y=0; y<300; y++)
{
for (int z=0; z<400; z++)
Considering that the array is huge, the amount of memory used, the indirections needed (a multidimensional array is a arrays of reference to arrays...), that does not seem at all slow to me. When you switch x and z you are probably trashing the cache.
For comparison, you could store everything in a flat array.... This would improve the storing speed... but then the retrieval would be more complex and much more slow.
int k = 0;
for (int x=0; x<400; x++)
{
for (int y=0; y<300; y++)
{
for (int z=0; z<400; z++)
{
// compute and store value
arr[k++] = val;
}
}
}