-
Notifications
You must be signed in to change notification settings - Fork 11
/
testInstall.m
108 lines (95 loc) · 3.16 KB
/
testInstall.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
clear
% A little script to check and see if all the components are installed and
% added to the path by calling function from each.
% Matlab is obvious so we don't need to try that one.
numProblems =0;
%% CVX
disp("Checking if CVX is installed")
try
%very simple CVX problem
cvx_begin quiet
variables x(2)
minimize norm(x)
subject to
x(1) +x(2) <= 5;
x(1) -x(2) >= 2;
cvx_end
disp("Passed")
catch err
numProblems = numProblems+1;
if ~checkCantFindFunction(err.identifier,"CVX")
disp("Some VERY unexpected error occured. Here's the stack trace.")
rethrow(err);
end
end
%% Qetlab
disp("Checking if Qetlab is installed")
QetlabFound = false;
try
iden(1,false);
QetlabFound = true;
disp("Passed")
catch err
numProblems = numProblems+1;
if ~checkCantFindFunction(err.identifier,"Qetlab")
disp("Some VERY unexpected error occured. Here's the stack trace.")
rethrow(err);
end
end
if QetlabFound
% Qetlab version 0.9 and lower has major bugs with using choi matrices.
% Unfortunetly, Qetlab has not updated their stable branch on their website
% so we have to direct people to their github.
disp("Checking if Qetlab version is above 0.9")
% The choi matrix we use for the test comes from this channel on 2x2 rho.
% testChannel = @(rho) blkdiag(0.25*rho,0.75*trace(rho));
testChoiMat = zeros(6,6);
testChoiMat(1,1) = 0.25;
testChoiMat(1,5) = 0.25;
testChoiMat(5,1) = 0.25;
testChoiMat(5,5) = 0.25;
testChoiMat(3,3) = 0.75;
testChoiMat(6,6) = 0.75;
qetLabChoiMat = PartialMap(MaxEntangled(2,false,false)*MaxEntangled(2,false,false)',...
testChoiMat,2,[2,2]);
% For Qetlab> 0.9, these should be EXACTLY the same.
if ~all(testChoiMat == qetLabChoiMat,"all")
numProblems = numProblems+1;
warning("Qetlab's PartialMap function failed for our test Choi matrix." + ...
" This is likely because you are using Qetlab version 0.9 or lower." + ...
" Please go to https://github.com/nathanieljohnston/QETLAB for the" + ...
" latest version of Qetlab.")
else
disp("Passed")
end
end
%% OpenQKDSecurity
disp("Checking if OpenQKDSecurity is installed")
try
debugInfo = DebugInfo();
disp("Passed")
catch err
numProblems = numProblems+1;
if ~checkCantFindFunction(err.identifier,"OpenQKDSecurity")
disp("Some VERY unexpected error occured. Here's the stack trace.")
rethrow(err);
end
end
%% All done!
if numProblems == 0
disp("Completed with no errors.")
else
fprintf("Completed with %d problem(s) to address.\n",numProblems)
end
clear
function isTheError = checkCantFindFunction(identifier,packageName)
isTheError = false;
if isequal(identifier, "MATLAB:UndefinedFunction")
isTheError = true;
warning("It seems that the package %s is missing. Plsease ensure" + ...
" that the package is installed and all folders and subfolders" + ...
" are on the path. If you encountered this error after restarting" + ...
" Matlab, then you likely didn't save your path setup and you" + ...
" have to redo them.\n",packageName);
end
end