-
Notifications
You must be signed in to change notification settings - Fork 15
/
examples_3d.m
172 lines (146 loc) · 3.58 KB
/
examples_3d.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
% three variable examples
%% 3 way redundant
Pxxxy = zeros(2,2,2,2);
Pxxxy(1,1,1,1) = 1/2;
Pxxxy(2,2,2,2) = 1/2;
fprintf(1,'RDN: redundant bits\n')
compare(lattice3d(),Pxxxy);
%% XORDUPLICATE : Griffith & Koch (2014) Fig. 6.6
Pxxxy = zeros(2,2,2,2);
p = 1/4;
Pxxxy(1,1,1,1) = p;
Pxxxy(1,2,1,2) = p;
Pxxxy(2,1,2,2) = p;
Pxxxy(2,2,2,1) = p;
fprintf(1,'XORDUPLICATE Griffith & Koch (2014) Fig. 6.6\n')
lat = compare(lattice3d(),Pxxxy);
%% two separate xors
Pxxxy = zeros(2,2,2,4);
p = 1/8;
Pxxxy(1,1,1,1) = p;
Pxxxy(1,1,2,2) = p;
Pxxxy(1,2,1,4) = p;
Pxxxy(1,2,2,3) = p;
Pxxxy(2,1,1,3) = p;
Pxxxy(2,1,2,4) = p;
Pxxxy(2,2,1,2) = p;
Pxxxy(2,2,2,1) = p;
fprintf(1,'Two separate Xors\n')
lat = compare(lattice3d(),Pxxxy);
%% XORLOSES : Griffith & Koch (2014) Fig. 6.7
Pxxxy = zeros(2,2,2,2);
Pxxxy(1,1,1,1) = 1/4;
Pxxxy(1,2,2,2) = 1/4;
Pxxxy(2,1,2,2) = 1/4;
Pxxxy(2,2,1,1) = 1/4;
fprintf(1,'XORLOSSES Griffith & Koch (2014) Fig. 6.7\n')
lat = compare(lattice3d(),Pxxxy);
%% ANDDUPLICATE : Griffith & Koch (2014) Fig. 6.13
Pxxxy = zeros(2,2,2,2);
p = 1/4;
Pxxxy(1,1,1,1) = p;
Pxxxy(1,2,1,1) = p;
Pxxxy(2,1,2,1) = p;
Pxxxy(2,2,2,2) = p;
fprintf(1,'ANDDUPLICATE Griffith & Koch (2014) Fig. 6.13\n')
lat = compare(lattice3d(),Pxxxy);
%% XORUNQ : 2 bit xor, with independent extra bit
Pxxxy = zeros(2,2,2,4);
p = 1/8;
Pxxxy(1,1,1,1) = p;
Pxxxy(1,1,2,2) = p;
Pxxxy(1,2,1,3) = p;
Pxxxy(1,2,2,4) = p;
Pxxxy(2,1,1,3) = p;
Pxxxy(2,1,2,4) = p;
Pxxxy(2,2,1,1) = p;
Pxxxy(2,2,2,2) = p;
fprintf(1,'2 bit XOR with independent extra bit\n')
lat = compare(lattice3d(),Pxxxy);
%% Bertschinger / Rauh. (x1,x2,x1 XOR x2) copied to output
Pxxxy = zeros(2,2,2,8);
Pxxxy(1,1,1,1) = 0.25;
Pxxxy(1,2,2,4) = 0.25;
Pxxxy(2,1,2,6) = 0.25;
Pxxxy(2,2,1,7) = 0.25;
fprintf(1,'Bertschinger / Rauh XOR copied input\n')
lat = compare(lattice3d(),Pxxxy);
%% 3 way EVEN PARITY
Pxxxy = zeros(2,2,2,2);
Pxxxy(1,1,1,1) = 1/8;
Pxxxy(1,1,2,2) = 1/8;
Pxxxy(1,2,1,2) = 1/8;
Pxxxy(1,2,2,1) = 1/8;
Pxxxy(2,1,1,2) = 1/8;
Pxxxy(2,1,2,1) = 1/8;
Pxxxy(2,2,1,1) = 1/8;
Pxxxy(2,2,2,2) = 1/8;
fprintf(1,'3-way EVEN PARITY\n')
lat = compare(lattice3d(),Pxxxy);
%% 3 way AND
Pxxxy = zeros(2,2,2,2);
Pxxxy(1,1,1,1) = 1/8;
Pxxxy(1,1,2,1) = 1/8;
Pxxxy(1,2,1,1) = 1/8;
Pxxxy(1,2,2,1) = 1/8;
Pxxxy(2,1,1,1) = 1/8;
Pxxxy(2,1,2,1) = 1/8;
Pxxxy(2,2,1,1) = 1/8;
Pxxxy(2,2,2,2) = 1/8;
fprintf(1,'3-way AND\n')
lat = compare(lattice3d(),Pxxxy);
%% XORMULTICOAL : Griffith & Koch (2014) Fig. 6.14
Pxxxy = zeros(4,4,4,2);
p = 1/8;
Pxxxy(1,1,1,1) = p;
Pxxxy(4,3,3,1) = p;
Pxxxy(3,4,2,1) = p;
Pxxxy(2,2,4,1) = p;
Pxxxy(3,3,1,2) = p;
Pxxxy(2,1,3,2) = p;
Pxxxy(1,2,2,2) = p;
Pxxxy(4,4,4,2) = p;
fprintf(1,'XORMULTICOAL Griffith & Koch (2014) Fig. 6.14\n')
lat = compare(lattice3d(),Pxxxy);
%% PARITYRDNRDN : Griffith & Koch (2014) (arXiv version) Fig. 13
% Pxxxy = zeros(8,8,8,8);
% p = 1/32;
%
% Pxxxy(1,1,1,1) = p;
% Pxxxy(1,1,2,2) = p;
% Pxxxy(1,2,1,2) = p;
% Pxxxy(1,2,2,1) = p;
% Pxxxy(2,1,1,2) = p;
% Pxxxy(2,1,2,1) = p;
% Pxxxy(2,2,1,1) = p;
% Pxxxy(2,2,2,2) = p;
%
% Pxxxy(3,3,3,3) = p;
% Pxxxy(3,3,4,4) = p;
% Pxxxy(3,4,3,4) = p;
% Pxxxy(3,4,4,3) = p;
% Pxxxy(4,3,3,4) = p;
% Pxxxy(4,3,4,3) = p;
% Pxxxy(4,4,3,3) = p;
% Pxxxy(4,4,4,4) = p;
%
% Pxxxy(5,5,5,5) = p;
% Pxxxy(5,5,6,6) = p;
% Pxxxy(5,6,5,6) = p;
% Pxxxy(5,6,6,5) = p;
% Pxxxy(6,5,5,6) = p;
% Pxxxy(6,5,6,5) = p;
% Pxxxy(6,6,5,5) = p;
% Pxxxy(6,6,6,6) = p;
%
% Pxxxy(7,7,7,7) = p;
% Pxxxy(7,7,8,8) = p;
% Pxxxy(7,8,7,8) = p;
% Pxxxy(7,8,8,7) = p;
% Pxxxy(8,7,7,8) = p;
% Pxxxy(8,7,8,7) = p;
% Pxxxy(8,8,7,7) = p;
% Pxxxy(8,8,8,8) = p;
%
% fprintf(1,'PARITYRDNRDN Griffith & Koch (arXiv version) Fig. 13\n')
% lat = compare(lattice3d(),Pxxxy);