fixed in-place transpose with O(1) extra memory