I am trying to write a function to rotate an image matrix using a looping technique. However, I am encountering some problems to make it work correctly.
EDIT: Here is my updated code that works, but only when n is a multiple of the block size. How will I handle different matrix sizes? Right now, I'm just using square blocks, and it works great for these square blocks. How would I decide to change this to use rectangular blocks depending on the size of the array I am giving. In particular, if I have been given an nxn array, how can I select the rectangular dimensions of the block to divide it by?
int block = 20;
int i1, j1, k1, i, j, k;
for(i1 = 0; i1 < n; i1 += block) {
for(j1 = 0; j1< n; j1 += block) {
for(i = i1; i < i1 + block; i++){
for(j = j1; j < j1 + block; j++){
dest[getInd(j, i, n)] = src[getInd(i, n - 1 - j, n)];
}
}
}
}
}