-
Notifications
You must be signed in to change notification settings - Fork 1
/
rt_bound.m
67 lines (57 loc) · 1.85 KB
/
rt_bound.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
function d = rt_bound(dm, ex, varargin)
% RT_BOUND Calculates the lower bound for the variances of quantum state or
% quantum process parameters estimator
% Documentation: https://github.com/PQCLab/mRootTomography/blob/master/Documentation.md
% The code is licensed under GPL v3
% Author: Boris Bantysh, 2021
opt.rank = 'dm';
for ja = 1:2:length(varargin)
opt.(lower(varargin{ja})) = varargin{ja + 1};
end
dim = size(dm, 1);
H = rt_infomatrix(dm, ex, 'rank', opt.rank);
Constraints = [];
[Uh, Sh] = eig(H);
h = diag(Sh);
if ischar(opt.rank) && strcmp(opt.rank,'dm')
opt.rank = rank(dm);
end
if strcmp(ex.obj_type, 'state')
% Normalization constraint
psi = rt_purify(dm, opt.rank);
Constraints = horzcat(Constraints, [real(psi(:)); imag(psi(:))]);
elseif strcmpi(ex.obj_type, 'process')
% Trace preserving constraint
E = rt_process_reform(dm, 'chi2kraus', opt.rank);
ds2r = dim * opt.rank;
ConsTP = zeros(2*ds2r, dim);
dim_sq = sqrt(dim);
for m = 1:dim_sq
for n = 1:dim_sq
ind = (m-1)*dim_sq + n;
Deriv = zeros(size(E));
Deriv(:,n,:) = Deriv(:,n,:) + E(:,m,:);
Deriv(:,m,:) = Deriv(:,m,:) + conj(E(:,n,:));
ConsTP(1:ds2r,ind) = Deriv(:);
Deriv = zeros(size(E));
Deriv(:,n,:) = Deriv(:,n,:) - 1j*E(:,m,:);
Deriv(:,m,:) = Deriv(:,m,:) + 1j*conj(E(:,n,:));
ConsTP((ds2r+1):end,ind) = Deriv(:);
end
end
Constraints = horzcat(Constraints, ConsTP);
end
% Phase insensitivity constraint
tol = max(h)*1e-10;
ind0 = find(h < tol);
if length(ind0) > opt.rank^2
warning('Information matrix has more than r^2 zero eigenvalues');
end
h(ind0) = tol;
ind0 = ind0(1:opt.rank^2);
Constraints = horzcat(Constraints, Uh(:,ind0));
% Finding d
L = null(Constraints')'*Uh*diag(1./sqrt(h));
d = svd(L).^2;
d = d / trace(dm);
end