Is it better to use the double pointer syntax M[][]
to define a matrix and then access the elements like
for (int i=0; i<height; ++i)
{
for (int j=0; j<width; ++j)
{
// do something with M[i][j]
}
}
or flatten the matrix in a vector, define it as M[]
and then access its elements like
for (int i=0; i<height; ++i)
{
for (int j=0; j<width; ++j)
{
int index = j + i * height;
// do something with M[index]
}
}