Could someone help me to understand as to how to compute the partial trace and partial-transposition of an arbitrary matrix? I mean, is there any code to carry out these operations in Mathematica?
EDIT: Using the code suggested by @Budha_the_Scientist, following error messages appear:
`In[29]:= mat = {{1, 2}, {3, 0}};
In[30]:= partialtrace[a_List?MatrixQ, dim_, sys_] :=
Module[{mat, gtb, i, j}, mat = Partition[a, {dim[[2]], dim[[2]]}];
If[sys == 1, gtb = Tr[mat, Plus, 2],
gtb = Table[Tr[mat[[i, j]]], {i, dim[[1]]}, {j, dim[[1]]}]];
normalize[gtb]]
normalize[a_List?MatrixQ] := a/Tr[a]
partialtranspose[a_List?MatrixQ, dim_, sys_] :=
Module[{mat, pt}, mat = Partition[a, {dim[[2]], dim[[2]]}];
If[sys == 1, pt = ArrayFlatten[Transpose[mat]],
pt = ArrayFlatten[
Table[Transpose[mat[[i, j]]], {i, dim[[1]]}, {j, dim[[1]]}]]];
Return[pt];]
In[33]:= partialtrace[mat, {2, 2}, 2]
During evaluation of In[33]:= Part::partw: Part 2 of {{{1,2},{3,0}}} does not exist. >>
During evaluation of In[33]:= Part::partw: Part 2 of {{{{1,2},{3,0}}}} does not exist. >>
During evaluation of In[33]:= Part::partw: Part 2 of {{{{1,2},{3,0}}}} does not exist. >>
During evaluation of In[33]:= General::stop: Further output of Part::partw will be suppressed during this calculation. >>
Out[33]= {{1/(1 + Tr[{{{{1, 2}, {3, 0}}}}[[2, 2]]]),
Tr[{{{{1, 2}, {3, 0}}}}[[1, 2]]]/(
1 + Tr[{{{{1, 2}, {3, 0}}}}[[2, 2]]])}, {Tr[{{{{1, 2}, {3, 0}}}}[[2,
1]]]/(1 + Tr[{{{{1, 2}, {3, 0}}}}[[2, 2]]]),
Tr[{{{{1, 2}, {3, 0}}}}[[2, 2]]]/(
1 + Tr[{{{{1, 2}, {3, 0}}}}[[2, 2]]])}}`