-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRobust_Quantum_fixedpoint_fast.m
68 lines (55 loc) · 1.72 KB
/
Robust_Quantum_fixedpoint_fast.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
function [ rho1,result_min,result_rho,result_resid, t_095,fide_095] = Robust_Quantum_fixedpoint_fast (b,A,maxite,tol_1 ,X_true,gamma,lamda,c,M,t,svd_sNo,shrink_para)
% function that generates the reconstruction result
% rho1: the reconstructed density matrix rho
% result_rho: reconstructed accuracy
% t_095: the time uses when the algorithm acheives 95% accuracy
% fide_095: the time uses when the algorithm acheives 95% fidelity
%
% Copyrights to Dr. Kezhi Li, @Imperial College, 22nd Jan. 2017
[A_row,A_col] = size(A);
d = round(sqrt(A_col)); % the nearest integers
alp=t/lamda;
y=zeros(M,1);
rho=zeros(d*d,1);
ite=0;
converged=0;
result_min=zeros(1,maxite);
result_rho=zeros(1,maxite);
result_resid=zeros(1,maxite);
t_095 = -1;
flag =0;
fide_095=-1;
tic;
while ~converged
% display iteration
ite=ite+1
if mod(ite,10)==0
disp(['iterations:' num2str(ite)]);
end
xi=(gamma*lamda/(1+gamma*lamda))*(-y/lamda-(A*rho-b));
rho=rho-t*(A'*(A*rho+xi-b+y/lamda));%ÏòÁ¿
rho=project2Hermitian_singular_shrink_fast(rho,alp,d,svd_sNo); %ÏòÁ¿
resid=A*rho+xi-b;
y=y+c*lamda*resid;
result_3=norm(resid,2);
rho1=reshape(rho,d,d);
result_1=norm(X_true-rho1,'fro')^2/norm(X_true,'fro')^2;
if result_1<0.05&&flag == 0
t_095 = toc
t_095 = [ite,t_095];
flag = 1;
fide_095 = Fidelity(X_true,rho1); %trace(sqrt(sqrt(X_true)*rho1*sqrt(X_true)));
end
svd_sNo = round(shrink_para*svd_sNo);
result_rho(ite)=result_1;
result_resid(ite)=result_3;
stop=norm(resid,'fro');
if stop<tol_1
converged=1;
end
if ~converged && ite>=maxite
disp('maximum iteration reached');
converged=1;
end
end
end