Let us say I have a double for loop.
/*Just a double for loop
*/
for(int i = 0; i<IMAX; i++){
for(int j = 0; j<JMAX; j++){
count++;
recover_loop_indices(count,IMAX,JMAX); /*this is not real world code.Just to illustrate what I mean*/
}
}
My question is precisely, given count, IMAX and JMAX, is it possible to recover the unique loop indices, i and j?
Yes, based on count:
You don’t need IMAX at all. In fact, this is often how one can reconstruct an image from a serial stream of pixels, given only the width of the stream.
Edit:
I am assuming you want to recover the values of i and j before the count++. To recover it after the count++, use (count-1).