Some tricky pointer arithmetic.
Turns out a really easy optimization if order doesn't matter much is to treat it like a single dimentional array of length d1 x d2 x d3 ... dn where d1 is the first dimention, etc. These two expressions are exactly equivalent in the way the memory is laid out, for instance:
int a[2][2] = {{1,2},{3,4}};
int a[4] = {1,2,3,4};
In C:
Leave a comment -