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$

1 Answer 1

2
$\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
$\endgroup$
3
  • $\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$
    – Bekaso
    May 7, 2020 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$ May 8, 2020 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$
    – Bekaso
    May 8, 2020 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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