That is because it zig_zags in the opposite direction. So you
need to plug-in the transpose
But as far as speed goes, you are probably better with a lookPHP Code:int my_transpose_matrix[8][8] = { { 0, 2, 3, 9, 10,20,21,35},
{ 1, 4, 8, 11,19,22,34,36},
{ 5, 7, 12, 18,23,33,37,48},
{ 6, 13, 17, 24,32,38,47,49},
{ 14, 16, 25, 31,39,46,50,57},
{ 15, 26, 30, 40,45,51,56,58},
{ 27, 29, 41, 44,52,55,59,62},
{ 38, 42, 43, 53,54,60,61,63}
};
up table, although you can use this function to generate one for any size of matrix
