I want to mirror a m*n matrix of doubles diagonally, like:

1 2 3 1 4
4 5 6 => 2 5
3 6

However, I don't want to allocate two matrices and copy one into the other. Instead, I want to have one double *matrix, which I interpret as a 2-dimensional matrix, i.e. matrix[a][b] = matrix[a*width+b]. This is due to memory restrictions, because the matrix I want to mirror may be huge (several MB).

Any ideas or mathematical solutions?