I have an array of float rtmp1[NMAX * 3][3], and it is used as rtmp1[i][n], where n is from 0 to 2, and i is from 0 to 3 * NMAX – 1. However, I would like to convert rtmp1 to be rtmp1[3 * 3 * NMAX]. Would addressing this new 1D array as rtmp1[3 * i + n] be equivalent to rtmp1[i][n]? Thanks in advance for the clarifications.
C++: 2D arrays vs. 1D array differences
arrayscmultidimensional-array
Related Topic
- C++ – The Definitive C++ Book Guide and List
- Javascript – Get all unique values in a JavaScript array (remove duplicates)
- Javascript – Get the last item in an array
- C++ – the copy-and-swap idiom
- Javascript – How to remove a specific item from an array
- Javascript – How to add new array elements at the beginning of an array in Javascript
- Javascript – For-each over an array in JavaScript
- Java – Why is processing a sorted array faster than processing an unsorted array
Best Answer
rtmp1[i][n] is equivalent to rtmp1[i*NMAX + n]
See http://www.cplusplus.com/doc/tutorial/arrays/, where your NMAX is their width.