-
Notifications
You must be signed in to change notification settings - Fork 0
/
fullTomography.m
50 lines (41 loc) · 1.77 KB
/
fullTomography.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
%main function for running the full tomography algorithms. CVX is not
%included with this zip file; download it at http://cvxr.com/cvx/download/
%inputs
%data: Nx1 vector of integers corresponding to numbers of detector clicks
%A: Nxd matrix of the measurement kets
%r (optional), multiplication factor turning probabilities into clicks
%output
%rhoEstimate: maximum likelihood density matrix
%timeTaken: time taken by each method
%costs: log-likelihood as a function of iteration number
function [rhoEstimates, timeTaken, costs] = fullTomography(data,A,r)
warning('off','all');
%check format of measurement matrix and data vector;
sD = size(data);
sA = size(A);
if sD(1)~=sA(1), error(['Number of measurements is not equal to number'...
' of outcomes. Should the measurement matrix and/or data vector'...
' be transposed?']);
end
if sA(1)<sA(2)*3/2 && sA(1)>sA(2)*2/3
error('Measurement matrix must be made of kets');
end
%fix dimensionality of system
d = sA(2);
%Specify method(s): comment/uncomment to enable/disable the method.
if exist('r','var')
[rhoEstimates.PGDM, timeTaken.PGDM, costs.PGDM] = runPGDM(data,A,r);
[rhoEstimates.FISTA, timeTaken.FISTA, costs.FISTA] = runFISTA(data,A,r);
[rhoEstimates.PGDB, timeTaken.PGDB, costs.PGDB] = runPGDB(data,A,r);
if d<100, [rhoEstimates.DIA, timeTaken.DIA, costs.DIA] = runDIA(data,A,r); end
if d<100 && exist('cvx','file')
[rhoEstimates.CVX, timeTaken.CVX] = runCVX(data,A,r);
end
else
%Only PGDMfreeTrace and CVX are written to accept data without 'r'.
[rhoEstimates.PGDMfreeTrace, timeTaken.PGDMfreeTrace,...
costs.PGDMfreeTrace] = runPGDMfreeTrace(data,A);
if d<50 && exist('cvx','file')
[rhoEstimates.CVX, timeTaken.CVX] = runCVX(data,A);
end
end