-
Notifications
You must be signed in to change notification settings - Fork 3
/
validPOVMs.m
83 lines (67 loc) · 2.38 KB
/
validPOVMs.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
function are_valid_POVMs = validPOVMs(Max)
%VALIDPOVMS Determines whether a set of POVMs is valid or not
% This function has one argument:
% Max: a 4-D array, containing the POVM elements. The first two
% dimensions contain the POVM elements, while the remaining two
% dimensions are (a,x), such that Max(:,:,a,x) = M_a|x.
%
% are_valid_POVMs = validPOVMs(Max) is the indicator function for valid
% POVMs. It returns 1 if the measurements are valid , and 0 otherwise.
%
% are_valid_POVMs = validPOVMs(Max) can also be used inside CVX as
% a partially specified problem, to enforce the constraint that the CVX
% variable Max should be a valid collection of POVMs.
%
% EXAMPLE:
% cvx_begin
%
% variable Max(dA,dA,oa,ma)
%
% subject to
%
% validPOVMs(Max) == 1
%
% cvx_end
%
% Inside CVX, Max is a set of measurements with ma inputs and oa outcomes
% of dimension dA x dA. CVX enforces that Max should be a valid set of
% measurements, i.e. that for each x, sum_a M_a|x == identity(dA).
%
% requires: CVX (http://cvxr.com/cvx/), QETLAB (http://www.qetlab.com)
% authors: Paul Skrzypczyk, Daniel Cavalcanti
% last updated: March 17, 2016
tol = 1e-10; % numerical tolerance used
[dA,~,oa,ma] = size(Max);
% dA = dim., oa = # outcomes, ma = # inputs for Alice
if isa(Max,'cvx') == 0 % if Max isn't a CVX variable
% first check that each POVM element is
% positive-semidefinite
for a = 1:oa
for x = 1:ma
if ~all(eig(Max(:,:,a,x))>= -tol)
are_valid_POVMs = 0;
display('POVM elements are not positive semidefinite')
return
end
end
end
% now check that the POVMs sum to the identity
if ~all(reshape(abs(squeeze(sum(Max,3))-repmat(eye(dA),[1,1,ma])) ...
<= tol,1,[]))
are_valid_POVMs = 0;
display('POVMs do not sum to identity')
return
end
% if all the conditions are satisfied, the POVMs are valid.
are_valid_POVMs = 1;
return
elseif isa(Max,'cvx') == 1 % if sigma is a CVX variable
cvx_begin
subject to
squeeze(sum(Max,3)) == repmat(eye(dA),[1,1,ma]);
% sum_a M_a|x == identity(dA) forall x
cvx_end
% CVX will return +inf if the problem is infeasible, and 0 if feasible
% this maps {+inf,0} to {0,1}
are_valid_POVMs = 1-min(cvx_optval,1);
end