I have Fortran-based 3D column-major order array flattened into linear memory. What formula/algorithm can I use map it back to a Java 3D row-major order array? For example,
|1, 2, 3| |10, 11, 12| |19, 20, 21|
|4, 5, 6| |13, 14, 15| |22 23, 24|
|7, 8, 9| |16, 17, 18| |25, 26, 27|
Looks like this in memory
buffer = 1, 4, 7, 2, 5, 8, 3, 6, 9, 10, 13, 16, 11, 14, 17, 12, 15, 18, 19, 22, 25, 20, 23, 26, 21, 24, 27
Ideally, I need to pass in the array indices and get back the offset to the linear memory. In pseudo code, something like
for(;;)
{
javaarray[2][2][1] = buffer[Util.LookupOffset(2,2,1)]
}
Thanks.