Possible Duplicate:
Why is my program slow when looping over exactly 8192 elements?
I have been tinkering around with a program that I'm using to simply sum the elements of a 2d array. A typo led to what seem to me at least, some very strange results.
When dealing with array, matrix[SIZE][SIZE]:
for(int row = 0; row < SIZE; ++row)
for(int col = 0; col < SIZE; ++col)
sum1 += matrix[row][col];
Runs very quickly, however is the above line sum1... is modified:
sum2 += matrix[col][row]
As I did once on accident without realizing it, I notice that my runtime increases SIGNIFICANTLY. Why is this?