mercredi 31 décembre 2014

C++ 3D Matrix Using References


Request for a sanity check ...


I am storing a 3D matrix in a 1D array as follows:



double * myVector = new double[NCHANNELS*NROWS*NCOLUMNS];


I want to be able to access myVector using [channel][row][column] syntax, so I am creating a C++ reference:



double (& my3dMatrix)[NCHANNELS][NROWS][NCOLUMNS] = myVector;


Have I used the proper syntax here, i.e., will



my3dMatrix[channel][row][column]


return



*(myVector + channel*NROWS*NCOLUMNS + row*NCOLUMNS + column)?


Thanks.





Aucun commentaire:

Enregistrer un commentaire