# Partial transpose of 8x8 density matrix?

Please could someone help me to knew how to compute the partial partial-transposition of the following matrix?

mat = Table[ρ[i, j], {i, 1, 8}, {j, 1, 8}]


ClearAll[partialTranspose]
partialTranspose = ArrayFlatten @ Map[Transpose, #, {2}] &;

mat = Array[Subscript[ρ, Row @ {##}] &, {8, 8}];

MatrixForm[mat] mat24 = Partition[mat, {2, 2}];
mat42 = Partition[mat, {4, 4}];

Row[MatrixForm /@ {mat, mat24, partialTranspose @ mat24}, Spacer] Row[MatrixForm /@ {mat, mat42, partialTranspose @ mat42},  Spacer] Alternatively, you can combine the partitioning and transposing steps:

ClearAll[flattenTransposePartition]
flattenTransposePartition = ArrayFlatten @* Map[Map[Transpose]] @* Partition;

flattenTransposePartition[mat, {2, 2}] == partialTranspose@mat24

True

flattenTransposePartition[mat, {4, 4}] == partialTranspose@mat42

True


You can also use BlockMap:

ClearAll[blockTranspose]
blockTranspose = ArrayFlatten@BlockMap[Transpose, ##] &;

blockTranspose[mat, {2, 2}] == flattenTransposePartition[mat, {2, 2}]

 True

blockTranspose[mat, {4, 4}] == flattenTransposePartition[mat, {4, 4}]

 True

• Thank you very much, It is so simple code. Can you please show me how I can get transposition as shown in figures? please see the edit. @kglr May 7 '20 at 21:56
• @RagabZidan it is always better to include information such as this from the start of a question, as best you can, just for future reference. I’m sure kglr will make an awesome update, but you may find the larger partial transpose may be accomplished by merely transposing the mat42 defined in this answer. I’ll see if I can make a generalized attempt myself, for fun :) May 8 '20 at 0:29
• @CATrevillian I know it's my fault. I really appreciate your help and I will work to improve my showing for the question in the future. May 8 '20 at 9:54