I was wondering if I could get some help to make this code run faster. I have a few ideas, which all involve taking out the RIDX function.
#define RIDX(i,j,n) ((i)*(n)+(j))
I think I can reduce the computation in this statement:
src[RIDX(i, j, dim)];
when i is 0, its basically counting j... so I was thinking, what if we changed the bounds of the loop to:
for (i = 0; i < (dim * dim); i++)
And just had a j++ instead of RIDX(i, j, dim)??
I'm not so sure what to do about dst[RIDX(dim-1-j, i, dim)] though... could you please help me out?
Thanks in advance!
void naive_rotate(int dim, pixel *src, pixel *dst)
int i, j;
for (i = 0; i < dim; i++)
for (j = 0; j < dim; j++)
dst[RIDX(dim-1-j, i, dim)] = src[RIDX(i, j, dim)];