4
$\begingroup$

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}] 
$\endgroup$
3
$\begingroup$
ClearAll[partialTranspose]
partialTranspose = ArrayFlatten @ Map[Transpose, #, {2}] &;

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

MatrixForm[mat]

enter image description here

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

Row[MatrixForm /@ {mat, mat24, partialTranspose @ mat24}, Spacer[10]]

enter image description here

Row[MatrixForm /@ {mat, mat42, partialTranspose @ mat42},  Spacer[10]]

enter image description here

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
| improve this answer | |
$\endgroup$
  • $\begingroup$ 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 $\endgroup$ – Ragab Zidan May 7 at 21:56
  • 3
    $\begingroup$ @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 :) $\endgroup$ – CA Trevillian May 8 at 0:29
  • 1
    $\begingroup$ @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. $\endgroup$ – Ragab Zidan May 8 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.