Skip to content

Commit fe4b421

Browse files
committed
Cumulative update.
Spelling and grammer fixes in comments. Tools for dividing problems and running them in parallel through bash. Fixed a bug with using ismembertol when order matters.
1 parent 016911b commit fe4b421

File tree

72 files changed

+918
-390
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+918
-390
lines changed

.gitignore

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
# ignore .mat files
22
*.mat
3+
34
# ignore figures
45
*.fig
5-
*.DS_Store
6-
# ignore folder for comparision to old software
6+
*.png
7+
*.jpg
8+
*.eps
79

10+
# Ignore log files
11+
*.log
12+
*.out
13+
14+
# Don't know where this is from but it keeps comming up
15+
*.DS_Store
816

917
# Default good practice MATLAB ignores:
1018
# Windows default autosave extension
@@ -18,4 +26,4 @@
1826

1927
# Packaged app and toolbox files
2028
*.mlappinstall
21-
*.mltbx
29+
*.mltbx

BasicProtocols/BasicBB84Alice2D/BasicBB84Alice2DChannelFunc.m

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function [newParams, modParser]= BasicBB84Alice2DChannelFunc(params,options,debugInfo)
22
% BasicBB84Alice2DChannelFunc a simple channel function for a qubit based
3-
% BB84 protocol with no loss. This channel model allows for depolariztion
3+
% BB84 protocol with no loss. This channel model allows for depolarization
44
% and misalignment between Alice and Bob's detectors. Here, Schmidt
55
% decomposition was used to shrink Alice from a 4d space to a 2d space.
66
% With this, we can model Alice and Bob through a maximally entangled
@@ -12,30 +12,31 @@
1212
% * dimB: The dimension of Bob's system. In this channel it is assumed to
1313
% be 2.
1414
% * observablesJoint: The joint observables from Alice and Bob's
15-
% measurments which they perform on the (idealy) max entangled state. The
16-
% observables must be hermitian and each must be the size dimA*dimB by
17-
% dimA*dimB. The observables assume the spaces are ordered A \otimes B.
18-
% They also should be positive semi-definite and should sum to identity,
19-
% but this is hard to check because of machine precision issues.
15+
% measurements which they perform on the (ideally) max entangled state.
16+
% The observables must be Hermitian and each must be the size dimA*dimB
17+
% by dimA*dimB. The observables assume the spaces are ordered A \otimes
18+
% B. They also should be positive semi-definite and should sum to
19+
% identity, but this is hard to check because of machine precision
20+
% issues.
2021
% * depolarization (0): The amount of depolarization applied to the signal
21-
% Alice sends to Bob. At maximum depolarization (depolariztion =1) a pure
22-
% qubit state is converted to a maximally mixed state. Depolarization
23-
% should be between 0 and 1.
22+
% Alice sends to Bob. At maximum depolarization (depolarization =1) a
23+
% pure qubit state is converted to a maximally mixed state.
24+
% Depolarization should be between 0 and 1.
2425
% * misalignmentAngle (0): Angle Alice and Bob's bases are misaligned by
2526
% around the Y-axis. For example, Bob's detectors could be slightly
2627
% rotated away from the incoming signals. Although calculations are done
2728
% on the Bloch sphere, angles should not be given in that form (period
2829
% 4pi). This angle is measured as the physical rotation of the device
2930
% (period 2pi).
3031
% Output parameters:
31-
% * expectationsJoint: The joint epxectations for Alice and Bob's
32+
% * expectationsJoint: The joint expectations for Alice and Bob's
3233
% measurement of the signals. Simply formed by taking the
3334
% observablesJoint and applying them to a simulated rhoAB.
3435
% Options:
3536
% * none
3637
% DebugInfo:
3738
% * rhoAB: Alice and Bob's shared density matrix after the channel has
38-
% acted on it. Usefull for checking the channel has been applied
39+
% acted on it. Useful for checking the channel has been applied
3940
% correctly.
4041
%
4142
% See also QKDChannelModule, makeGlobalOptionsParser
@@ -88,7 +89,7 @@
8889
% generate joint density operator
8990
% This should technically be rhoAAprime until we act the channels on
9091
% it.
91-
rhoAB = MaxEntangled(dimA,false,false); %This is really the only differnce between 2D and 4D Alice
92+
rhoAB = MaxEntangled(dimA,false,false); %This is really the only difference between 2D and 4D Alice
9293

9394
rhoAB = (rhoAB*rhoAB')/dimA;
9495

@@ -97,7 +98,7 @@
9798
rhoAB = PartialMap(rhoAB,depolChoiMat,2,[dimA,dimB]);
9899

99100
%Rotation
100-
%When using QetLab's PartialMap function, kraus operators need to be
101+
%When using QetLab's PartialMap function, Kraus operators need to be
101102
%passed in as a cell array. If you don't, It will try and use it as a
102103
%Choi matrix.
103104
rotationKrausOps = {Qudit.rotateStateZXY(params.misalignmentAngle,[0,0,1],"angleOnBlochSphere",false)};

BasicProtocols/BasicBB84Alice2D/BasicBB84Alice2DDescriptionFunc.m

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
% 2d space. This is used with BasicKeyRateFunc.
66
%
77
% Input parameters:
8-
% * pz: The probability that ALice measures in the Z-basis (for this protocol,
9-
% it's also the probability that Bob measures in the Z-basis aswell). It
10-
% must be between 0 and 1.
8+
% * pz: The probability that Alice measures in the Z-basis (for this
9+
% protocol, it's also the probability that Bob measures in the Z-basis as
10+
% well). It must be between 0 and 1.
1111
% Output parameters:
1212
% * observablesJoint: The joint observables for Alice and Bob's measurement
1313
% of the signals.
@@ -27,7 +27,7 @@
2727
% outcome to key bits (May be written with Strings).
2828
% * krausOps: A cell array of matrices. The Kraus operators that form the G
2929
% map on Alice and Bob's joint system. These should form a completely
30-
% postive trace non-increasing linear map. Each Kraus operator must be
30+
% positive trace non-increasing linear map. Each Kraus operator must be
3131
% the same size.
3232
% * keyProj: A cell array of projection operators that extract the key
3333
% from G(\rho). These projection operators should sum to identity. This
@@ -77,7 +77,7 @@
7777
%% rhoA for source replacement scheme
7878
newParams.rhoA = eye(dimA)/dimA;
7979

80-
%% joint obserables
80+
%% joint observables
8181
POVMsA = {pz*diag([1,0]),pz*diag([0,1]),(1-pz)*(ketP*ketP'),(1-pz)*(ketM*ketM')};
8282
POVMsB = POVMsA;
8383
newParams.POVMA = POVMsA;
@@ -101,10 +101,10 @@
101101
%% Kraus Ops (for G map)
102102
% A: Alice's system, B: Bob's System, C: announcement register, R:
103103
% key register.
104-
% The Kraus operators are matrices from ABC \rightarrow RBC. Here we
105-
% used an isometry to shrink the Kraus operators from outputing on RABC
106-
% to just RBC. This lets us save time on computing eigen values later.
107-
% The factor of pz comes from a \sqrt(pz) from Alice's measurements(from Schmidt
104+
% The Kraus operators are matrices from ABC \rightarrow RBC. Here we used
105+
% an isometry to shrink the Kraus operators from outputting on RABC to just
106+
% RBC. This lets us save time on computing eigen values later. The factor
107+
% of pz comes from a \sqrt(pz) from Alice's measurements(from Schmidt
108108
% reduction) and \sqrt(pz) from Bob's measurements.
109109
krausOpZ = pz*kron(diag([1,0])+diag([0,1]),kron(eye(dimB),zket(2,1)));
110110
krausOpX = (1-pz)*kron(zket(2,1)*ketP'+zket(2,2)*ketM',kron(eye(dimB),zket(2,2)));
@@ -128,7 +128,7 @@
128128
proj1 = kron(diag([0,1]),eye(dimB*2));
129129
keyProj = {proj0,proj1};
130130

131-
%% set kraus ops and key projection in new parameters
131+
%% set Kraus ops and key projection in new parameters
132132
newParams.krausOps = krausOps;
133133
newParams.keyProj = keyProj;
134134

BasicProtocols/BasicBB84Alice2D/BasicBB84Alice2DPreset.m

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
function qkdInput = BasicBB84Alice2DPreset()
22
% BasicBB84Alice2DPreset A preset that describes a qubit based BB84 protocol
3-
% using source replacement. In this implementation, there is no tranmission
4-
% loss modeled. Alice and Bob have the same probability of choosing the
5-
% Z-basis (and same for the X-basis). Here, Schmidt decomposition was used
6-
% to shrink Alice from a 4d space to a 2d space.
3+
% using source replacement. In this implementation, there is no
4+
% transmission loss modeled. Alice and Bob have the same probability of
5+
% choosing the Z-basis (and same for the X-basis). Here, Schmidt
6+
% decomposition was used to shrink Alice from a 4d space to a 2d space.
77

88
qkdInput = QKDSolverInput();
99

1010
%% Parameters
1111

1212
%Here we start by setting what are the initial parameters we will use with
1313
%the protocol. These parameters help define what needs to be fixed, what we
14-
%want to scan over (usualy for graphing), and what needs to be optimized to
15-
%extract more key.
14+
%want to scan over (usually for graphing), and what needs to be optimized
15+
%to extract more key.
1616
%
1717
%How do we know what parameters can be set? Each module (the section after
1818
%this) has a series of inputs they request. If they aren't given by a
@@ -39,10 +39,10 @@
3939
% then they transmit / measure in the X-basis.
4040
qkdInput.addFixedParameter("pz",1/2);
4141

42-
% fEC: Efficiency of error correction. Real error correction protocols don't
43-
% reach the Shannon limit. f is a scalar muliple, that scales up the amount
44-
% of information leaked to fix a single bit. fEC=1, is the Shannon limit.
45-
% fEC=1.16 is a more realistic value.
42+
% fEC: Efficiency of error correction. Real error correction protocols
43+
% don't reach the Shannon limit. f is a scalar multiple, that scales up the
44+
% amount of information leaked to fix a single bit. fEC=1, is the Shannon
45+
% limit. fEC=1.16 is a more realistic value.
4646
qkdInput.addFixedParameter("fEC",1);
4747

4848
%% modules
@@ -57,11 +57,10 @@
5757
% This module works with the keyRate module to describe the class of
5858
% protocols that the keyRate module can solve. Usually code goes here
5959
% because it is likely to change to work on flavors of other protocols or
60-
% when parts of the protocol are usefull for a channel model to have access
61-
% to.
62-
% This description only provides the joint observables so that the channel
63-
% module can use them. It's useful when we want to swap out what our
64-
% measuremnts are.
60+
% when parts of the protocol are useful for a channel model to have access
61+
% to. This description only provides the joint observables so that the
62+
% channel module can use them. It's useful when we want to swap out what
63+
% our measurements are.
6564
descriptionModule = QKDDescriptionModule(@BasicBB84Alice2DDescriptionFunc);
6665
qkdInput.setDescriptionModule(descriptionModule);
6766

@@ -78,17 +77,17 @@
7877
keyRateModule = QKDKeyRateModule(@BasicKeyRateFunc);
7978
qkdInput.setKeyRateModule(keyRateModule);
8079

81-
% The optimizer module is designed to tweak perameters to increase your
80+
% The optimizer module is designed to tweak parameters to increase your
8281
% keyrate. It's not used in this protocol, though use cases can include
8382
% tweaking the intensity of coherent pulses used by Alice.
8483
optimizerMod = QKDOptimizerModule(@coordinateDescentFunc,struct("verboseLevel",0),struct("verboseLevel",0));
8584
qkdInput.setOptimizerModule(optimizerMod);
8685

8786

8887
% The mathSolver module takes in a description of linear equality, linear
89-
% ineqaulity, trace norm constraints, Kraus operators (for the G map) and
88+
% inequality, trace norm constraints, Kraus operators (for the G map) and
9089
% projectors for the key map (also known as the Z map). It then determine
91-
% the worst case senario and produces the minimum relaive entropy between
90+
% the worst case scenario and produces the minimum relative entropy between
9291
% the key and Eve's information.
9392
mathSolverOptions = struct();
9493
mathSolverOptions.initMethod = 1; %closest to maximally mixed.
@@ -109,7 +108,7 @@
109108
% * verboseLevel (default 1): Non-negative integer telling the program how
110109
% much information it should display in the command window. 0, minimum; 1
111110
% basic information; 2, full details, including CVX output.
112-
% * errorHandling (2): ErrorHandling object (unit8 or convertable),
111+
% * errorHandling (2): ErrorHandling object (unit8 or convertible),
113112
% detailing how the program should handle run time errors. CatchSilent 1:
114113
% catch but don't warn the user and the error message is appended to the
115114
% debug info. CatchWarn 2: catch and warn the user. The key rate for the

BasicProtocols/BasicBB84Alice2D/mainBasicBB84Alice2D.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
% qubit BB84 prepare and measure. We use schmidt decomposition to reduce
2-
% the dimension of Alice's state for enchanced speed and stability.
1+
% qubit BB84 prepare and measure. We use Schmidt decomposition to reduce
2+
% the dimension of Alice's state for enhanced speed and stability.
33
qkdInput = BasicBB84Alice2DPreset();
44

55
%run the QKDSolver with this input

BasicProtocols/BasicBB84Alice2DFinite/BasicBB84Alice2DFiniteKeyRateFunc.m

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,43 @@
1414
% outcome to key bits (May be written with Strings).
1515
% * krausOps: A cell array of matrices. The Kraus operators that form the G
1616
% map on Alice and Bob's joint system. These should form a completely
17-
% postive trace non-increasing linear map. Each Kraus operator must be
17+
% positive trace non-increasing linear map. Each Kraus operator must be
1818
% the same size.
1919
% * keyProj: A cell array of projection operators that perform the pinching map
2020
% key on G(\rho). These projection operators should sum to identity.
21-
% * fEC: error correction effiency. Set to 1 means for Shannon limit.
21+
% * fEC: error correction efficiency. Set to 1 means for Shannon limit.
2222
% * observablesJoint: The joint observables of Alice and Bob's
23-
% measurments. The observables must be hermitian and each must be the size
24-
% dimA*dimB by dimA*dimB. The observables assume the spaces are ordered A \otimes B.
25-
% They also should be positive semi-definite and should sum to identity.
23+
% measurements. The observables must be Hermitian and each must be the
24+
% size dimA*dimB by dimA*dimB. The observables assume the spaces are
25+
% ordered A \otimes B. They also should be positive semi-definite and
26+
% should sum to identity.
2627
% * expectationsJoint: The joint expectations (as an array) from Alice and
2728
% Bob's measurements that line up with it's corresponding observable in
28-
% observablesJoint. These values should be betwen 0 and 1.
29+
% observablesJoint. These values should be between 0 and 1.
2930
% * rhoA (nan): The fixed known density matrix on Alice's side for
3031
% prepare-and-measure protocols.
31-
% * epsilonPA : epsilon for privacy amplification.
32-
% * epsilonAT : epsilon for acceptance test.
33-
% * epsilonEC : epsilon for error-verification.
34-
% * epsilonBar : epsilon for smoothing.
35-
% * numSignals : total number of signals sent.
36-
% * pTest : pTest*numSignals is the number of signals used for testing
37-
% * tExp : finite-size parameter determining the size of the acceptance
32+
% * epsilonPA: epsilon for privacy amplification.
33+
% * epsilonAT: epsilon for acceptance test.
34+
% * epsilonEC: epsilon for error-verification.
35+
% * epsilonBar: epsilon for smoothing.
36+
% * numSignals: total number of signals sent.
37+
% * pTest: pTest*numSignals is the number of signals used for testing
38+
% * tExp: finite-size parameter determining the size of the acceptance
3839
% set.
3940

4041
% Outputs:
4142
% * keyrate: Key rate of the QKD protocol.
43+
%
4244
% Options:
4345
% * verboseLevel: (global option) See makeGlobalOptionsParser for details.
4446
% * errorHandling: (global option) See makeGlobalOptionsParser for details.
47+
%
4548
% DebugInfo:
46-
% * relEnt : The computed lower bound on the relative entropy.
47-
% * keyRateRelEntStep2Linearization : The relative entropy at the
48-
% linearization point.
49-
% See also QKDKeyRateModule, PM46DescriptionFunc, makeGlobalOptionsParser
49+
% * relEnt: The computed lower bound on the relative entropy.
50+
% * keyRateRelEntStep2Linearization: The relative entropy at the
51+
% linearization point.
52+
%
53+
% See also QKDKeyRateModule, makeGlobalOptionsParser
5054
arguments
5155
params (1,1) struct
5256
options (1,1) struct

BasicProtocols/BasicBB84Alice4D/BasicBB84Alice4DChannelFunc.m

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function [newParams, modParser]= BasicBB84Alice4DChannelFunc(params,options,debugInfo)
22
% BasicBB84Alice4DChannelFunc a simple channel function for a qubit based
3-
% BB84 protocol with no loss. This channel model allows for depolariztion
3+
% BB84 protocol with no loss. This channel model allows for depolarization
44
% and misalignment between Alice and Bob's detectors.
55
%
66
% Input parameters:
@@ -9,30 +9,31 @@
99
% * dimB: The dimension of Bob's system. In this channel it is assumed to
1010
% be 2.
1111
% * observablesJoint: The joint observables from Alice and Bob's
12-
% measurments which they perform on the (idealy) max entangled state. The
13-
% observables must be hermitian and each must be the size dimA*dimB by
14-
% dimA*dimB. The observables assume the spaces are ordered A \otimes B.
15-
% They also should be positive semi-definite and should sum to identity,
16-
% but this is hard to check because of machine precision issues.
12+
% measurements which they perform on the (ideally) max entangled state.
13+
% The observables must be Hermitian and each must be the size dimA*dimB
14+
% by dimA*dimB. The observables assume the spaces are ordered A \otimes
15+
% B. They also should be positive semi-definite and should sum to
16+
% identity, but this is hard to check because of machine precision
17+
% issues.
1718
% * depolarization (0): The amount of depolarization applied to the signal
18-
% Alice sends to Bob. At maximum depolarization (depolariztion =1) a pure
19-
% qubit state is converted to a maximally mixed state. Depolarization
20-
% should be between 0 and 1.
19+
% Alice sends to Bob. At maximum depolarization (depolarization =1) a
20+
% pure qubit state is converted to a maximally mixed state.
21+
% Depolarization should be between 0 and 1.
2122
% * misalignmentAngle (0): Angle Alice and Bob's bases are misaligned by
2223
% around the Y-axis. For example, Bob's detectors could be slightly
2324
% rotated away from the incoming signals. Although calculations are done
2425
% on the Bloch sphere, angles should not be given in that form (period
2526
% 4pi). This angle is measured as the physical rotation of the device
2627
% (period 2pi).
2728
% Output parameters:
28-
% * expectationsJoint: The joint epxectations for Alice and Bob's
29+
% * expectationsJoint: The joint expectations for Alice and Bob's
2930
% measurement of the signals. Simply formed by taking the
3031
% observablesJoint and applying them to a simulated rhoAB.
3132
% Options:
3233
% * none
3334
% DebugInfo:
3435
% * rhoAB: Alice and Bob's shared density matrix after the channel has
35-
% acted on it. Usefull for checking the channel has been applied
36+
% acted on it. Useful for checking the channel has been applied
3637
% correctly.
3738
%
3839
% See also QKDChannelModule
@@ -91,7 +92,7 @@
9192
ketM = 1/sqrt(2) * [1;-1];
9293

9394
% generate joint density operator. Technically this should be rhoAAPrime
94-
% untill the channels transform it.
95+
% until the channels transform it.
9596
rhoAB = sqrt(pz/2) * (kron(zket(dimA,1), zket(dimB,1)) + kron(zket(dimA,2), zket(dimB,2)))...
9697
+sqrt((1-pz)/2) * (kron(zket(dimA,3), ketP) + kron(zket(dimA,4), ketM));
9798

@@ -103,7 +104,7 @@
103104
rhoAB = PartialMap(rhoAB,depolChoiMat,2,[dimA,dimB]);
104105

105106
%Rotation
106-
%When using QetLab's PartialMap function, kraus operators need to be
107+
%When using QetLab's PartialMap function, Kraus operators need to be
107108
%passed in as a cell array. If you don't, It will try and use it as a
108109
%Choi matrix.
109110
rotationKrausOps = {Qudit.rotateStateZXY(params.misalignmentAngle,[0,0,1],"angleOnBlochSphere",false)};

0 commit comments

Comments
 (0)