add function to swap dimensions in chunks using an inplace cyclic swapping