(*
Copyright (C) 2004-2009 Toby Cubitt
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*)
BeginPackage["Partial`","LinearAlgebra`MatrixManipulation`"]
PartialTranspose::usage =
"PartialTranspose[p,a,b,sys] gives the partial transpose with respect to
system sys = (1 or 2) of a density matrix p with subsystems of dimensions
a and b. Author: Toby Cubitt"
PartialTrace::usage =
"PartialTrace[p,a,b,sys] gives the partial trace with respect to system
sys (1 or 2) of a density matrix p with subsystems of dimentions a and b.
Author: Toby Cubitt"
Begin["`Private`"]
PartialTranspose[p_,a_,b_,sys_]:=Module[{s},
s=Partition[p,{b,b}];
s=Transpose[s, If[sys==1,{2,1,3,4},{1,2,4,3}] ];
s=BlockMatrix[s]
]
PartialTrace[p_,a_,b_,sys_]:=Module[{s},
s=Partition[p,{b,b}];
If[sys==2,s=Transpose[s,{3,4,1,2}]];
s=Tr[s, Plus, 2]
]
End[ ]
EndPackage[ ]