To access a matrix we can use a double pointer, and then use 2d arrays with index i, j. for rows a column. For example the element (1,2) could be addressed as A[1][2].
Another method is to use single pointer, and then use 1D array, but do certain index calculation to correctly address a particular item in matrix.
I want to know the pros and cons of these two methods for accessing the matrix, especially in terms of performance. My understanding is that, the method involving single pointer may incur performance penalty because it has to do additional Calculation of index, which is not required in double pointer. Is my understanding correct ? What are the other pros and cons?
I am assuming that arrays are allocated dynamically.