I had a 2D array (matrix) and its array(1D) representation, I want to know what is the relationship between the [x][y] position of an item in matrix with [index] of the corresponding item array representation.
Explanation: Lets say I had matrix of 3x4 size:
Matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]
Array = [1,2,3,4,5,6,7,8,9,10,11,12]
The position of item '6'
in matrix is [1][1]
and its position in array is [5]
.
So what I want to know is what is the relationship b/w [1][1]
and [5]
in matrix of size 3x4
.
Thanks for the suggestions and replies.
PS: I need the mathamatic logic behind it, not a function in any languages (matlab) to do this functionality.