transpose a complex matrix using a mapping function