%File: gigpates.m
%Author: I. Chaung
%

global hadamard cnot cphase sx sy sz rx ry rz N zz xx yy

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%pauli matrices

sx=[0 1; 1 0];
sy=[0 -i; i 0];
sz=[1 0; 0 -1];
si=[1 0; 0 1];

pauli={sx,sy,sz};

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%two-qubit interaction terms: product space

zz=kron(sz,sz);
xx=kron(sx,sx);
yy=kron(sy,sy);
zi=kron(sz,si);
iz=kron(si,sz);
ii=kron(si,si);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%single qubit rotations (acting on 1 qubit 2x2 unitaries)

rx=expm(-i*pi/4*sx);
ry=expm(-i*pi/4*sy);
rz=expm(-i*pi/4*sz);
rzf=expm(-i*pi/2*sz);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%single qubit rotations (acting on 1 of 2 qubits: 4x4 unitaries)

rx1=kron(si,rx);
rx2=kron(rx,si);
ry1=kron(si,ry);
ry2=kron(ry,si);
rz1=kron(si,rz);
rz2=kron(rz,si);
rzf1=kron(si,rzf);
rzf2=kron(rzf,si);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%one-qubit computational basis states

psi0=[1; 0];
psi1=[0; 1];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%two-qubit computational basis states

psi00=kron(psi0,psi0);
psi01=kron(psi0,psi1);
psi10=kron(psi1,psi0);
psi11=kron(psi1,psi1);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Spin-1 Density matrix

p11=sym('p11');
p12=sym('p12');
p13=sym('p13');
p21=sym('p21');
p22=sym('p22');
p23=sym('p23');
p31=sym('p31');
p32=sym('p32');
p33=sym('p33');
p=[p11 p12 p13; p21 p22 p23; p31 p32 p33];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Spin-1 Matrices

jx=1/sqrt(2)*[0 1 0; 1 0 1; 0 1 0];
jy=1/sqrt(2)*[0 -i 0;i 0 -i;0 i 0];
jz=[1 0 0; 0 0 0;0 0 -1];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%two qubit Hamiltonian (for CHC13) & coupled evolution gate

ham=zz;
tau=expm(-i*pi/4*zz);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%standard ideal quantum logic gates

hadamard=[1 1; 1 -1]/sqrt(2);
cnot=[1 0 0 0; 0 1 0 0; 0 0 0 1; 0 0 1 0];
cphase=[1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 -1];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Example: near-controlled-not

Uncnot=ry1'*tau*rx1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Example: effect of Uncnot on thermal state density matrix

rho_therm=[5 0 0 0; 0 3 0 0; 0 0 -3 0; 0 0 0 -5];
rho_ou=Uncnot*rho_therm*Uncnot';


