#量子相干态生成
// quantum coherent state
function [ket_co,rou_co] = rou_co(alpha)
Wei = 20;
ket_co = zeros(Wei,1);
for n = 1:1:Wei
ket_co(n) = exp((-1/2)*alpha^2) *alpha^(n-1)/(factorial(n-1))^0.5;
end
% ket_co = ket_co/norm(ket_co);
rou_co = ket_co*ket_co';
end
#量子挤压生成
// quantum squeezed state
function [ket_sq,rou_sq] = rou_sq(r,alpha,theta)
Wei = 20;
ket_sq = zeros(Wei,1);
for n = 0:1:Wei-1
ket_sq(n+1) = exp(-0.5*alpha^2+alpha^2*exp(1i*theta)*tanh(r)/2)*...
(1i)^n*sqrt(exp(1i*n*theta/2)/(factorial(n)*cosh(r)))*...
(tanh(r)/2)^(n/2)*...
hermiteH(n,-0.5*1i*exp(-1i*theta/2)*sqrt(2/tanh(r))*(alpha-exp(1i*theta)*tanh(r)*alpha));
end % hermiteH(i-1,mu*v/(B^2))
% ket_sq = ket_sq/norm(ket_sq);
rou_sq = ket_sq*ket_sq';
rou_sq = rou_sq/trace(rou_sq); % 使挤压态的迹归一化,可能有问题
end
%% 密度算子加噪
function rou_noi = rou_noi(rou,np) % np : noise parameter:σ
Wei = 20;
for n = 1:1:Wei
for m = 1:1:Wei
rou(n,m) = rou(n,m)*exp(-(n-m)^2*np^4/4);
end
end
% rou_noi = rou/trace(rou);
rou_noi = rou;
end