I´m working with a 4D matrix (using STL vectors). Usually, the dimensions are different.For example, I´m reading a matrix whose dimensions are 192x256x128x96, and the following code complete with 0´s to the bigger dimension (256 in this case).
while(matriz.size() < width) //width es el tamaño de N
{
vector<vector<vector<short>>> aux;
matriz.push_back(aux);
}
for(auto i = 0; i < matriz.size(); i++)
{
while(matriz[i].size() < width)
{
vector<vector<short>> aux;
matriz[i].push_back(aux);
}
}
for(auto i = 0; i < matriz.size(); i++)
for(auto j = 0; j < matriz[i].size(); j++)
while(matriz[i][j].size() < width)
{
vector<short> aux;
matriz[i][j].push_back(aux);
}
for(auto i = 0; i < matriz.size(); i++)
for(auto j = 0; j < matriz[i].size(); j++)
for(auto k = 0; k < matriz[i][j].size(); k++)
while(matriz[i][j][k].size() < width)
{
matriz[i][j][k].push_back(0);
}
That code works with little-medium size 4D matrix, I´ve been tried with 200x200x200x200 and it really works, but I need to use it with a 256x256x256x256 matrix and when I run it my computer doesn´t respond.
I´m not sure if it is a RAM issue. My computer has 12GB RAM, and if I'm not mistaken, the size of the matrix is 8GB.
Any idea how to fix this ?
edit
If I let the program works, a time later it is killed

The memory usage with a 200x200x200x200 matrix is 56.7%
