Skip to content

Commit d1565bf

Browse files
authored
Create cnot_bb.tex
1 parent 23ffa8f commit d1565bf

File tree

1 file changed

+296
-0
lines changed

1 file changed

+296
-0
lines changed

algpseudocode/cnot_bb.tex

+296
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,296 @@
1+
\documentclass{article}
2+
\usepackage[utf8]{inputenc}
3+
\usepackage{algorithm}
4+
\usepackage{algpseudocode}
5+
\usepackage{braket}
6+
\usepackage{amsmath, amsfonts, amssymb, amsthm}
7+
8+
\newcommand{\norm}[1]{\left\lVert#1\right\rVert}
9+
\algrenewcommand\algorithmicrequire{\textbf{Input:}}
10+
\algrenewcommand\algorithmicensure{\textbf{Output:}}
11+
12+
\makeatletter
13+
\renewcommand{\fnum@algorithm}{\fname@algorithm}
14+
\makeatother
15+
16+
17+
18+
\usepackage{amsfonts}
19+
%\usepackage{braket}
20+
\usepackage[bottom]{footmisc}
21+
\usepackage{xcolor}
22+
\usepackage{amsmath}
23+
\usepackage{enumerate}
24+
\usepackage{tikz}
25+
\usetikzlibrary{matrix,decorations.pathreplacing,quantikz}
26+
\usepackage{mleftright}
27+
\usepackage{amssymb}
28+
\usepackage{mathabx}
29+
\usepackage[margin=20pt]{geometry}
30+
31+
\usetikzlibrary{math}
32+
33+
\begin{document}
34+
\pagestyle{empty}
35+
36+
37+
38+
\begin{tikzpicture}
39+
% address register
40+
\draw (0, 0) node{\small $\ket{i_0}$};
41+
\draw (0, 0.5) node{\small $\ket{i_1}$};
42+
\draw (0, 1) node{\small $\ket{i_2}$};
43+
44+
% memory register
45+
\draw (0, -12) node{\small $\ket{m_{000}}$};
46+
\draw (0, -12.5) node{\small $\ket{m_{001}}$};
47+
\draw (0, -13) node{\small $\ket{m_{010}}$};
48+
\draw (0, -13.5) node{\small $\ket{m_{011}}$};
49+
\draw (0, -14) node{\small $\ket{m_{100}}$};
50+
\draw (0, -14.5) node{\small $\ket{m_{101}}$};
51+
\draw (0, -15) node{\small $\ket{m_{110}}$};
52+
\draw (0, -15.5) node{\small $\ket{m_{111}}$};
53+
54+
% ancilla qubits register
55+
\draw (0, 2) node{\small $\ket{a_0}$};
56+
\draw (0, 2.5) node{\small $\ket{a_1}$};
57+
\draw (0, 3) node{\small $\ket{a_2}$};
58+
59+
60+
% target register
61+
\draw (0, -16.5) node{\small $\ket{b}$};
62+
63+
% horizontal line ancilla register
64+
\draw [-] [thick] (0+0.3, 2) to (16, 2);
65+
\draw [-] [thick] (0+0.3, 2.5) to (16, 2.5);
66+
\draw [-] [thick] (0+0.3, 3) to (16, 3);
67+
68+
% horizontal lines address register
69+
\draw [-] [thick] (0+0.3, 0) to (16, 0);
70+
\draw [-] [thick] (0+0.3, 0.5) to (16, 0.5);
71+
\draw [-] [thick] (0+0.3, 1) to (16, 1);
72+
73+
% horizontali lines memory and target
74+
\draw [-] [thick] (0+0.5, -12-0.1) to (16, -12-0.1);
75+
\draw [-] [thick] (0+0.5, -12.5-0.1) to (16, -12.5-0.1);
76+
\draw [-] [thick] (0+0.5, -13-0.1) to (16, -13-0.1);
77+
\draw [-] [thick] (0+0.5, -13.5-0.1) to (16, -13.5-0.1);
78+
\draw [-] [thick] (0+0.5, -14-0.1) to (16, -14-0.1);
79+
\draw [-] [thick] (0+0.5, -14.5-0.1) to (16, -14.5-0.1);
80+
\draw [-] [thick] (0+0.5, -15.5-0.1) to (16, -15.5-0.1);
81+
\draw [-] [thick] (0+0.5, -15-0.1) to (16, -15-0.1);
82+
83+
\draw [-] [thick] (0+0.5, -16.5) to (16, -16.5);
84+
85+
86+
% double lines for classical memory register
87+
\draw [-] [thick] (0+0.5, -12) to (16, -12);
88+
\draw [-] [thick] (0+0.5, -12.5) to (16, -12.5);
89+
\draw [-] [thick] (0+0.5, -13) to (16, -13);
90+
\draw [-] [thick] (0+0.5, -13.5) to (16, -13.5);
91+
\draw [-] [thick] (0+0.5, -14) to (16, -14);
92+
\draw [-] [thick] (0+0.5, -14.5) to (16, -14.5);
93+
\draw [-] [thick] (0+0.5, -15.5) to (16, -15.5);
94+
\draw [-] [thick] (0+0.5, -15) to (16, -15);
95+
\draw [-] [thick] (0+0.5, -16.5) to (16, -16.5);
96+
97+
98+
99+
% ANCILLA REGISTERS
100+
% central ancilla register
101+
\draw (0, -6) node{\small $\ket{0}$};
102+
\draw (0, -6.5) node{\small $\ket{1}$};
103+
104+
% above and below angilla register pt 2
105+
\draw (3, -4) node{\small $\ket{0}$};
106+
%\draw (3, -4.5) node{\small $\ket{1}$};
107+
108+
\draw (3, -8) node{\small $\ket{0}$};
109+
%\draw (3, -8.5) node{\small $\ket{1}$};
110+
111+
112+
% above and below kets pt 3
113+
\draw (6, -2) node{\small $\ket{0}$};
114+
%\draw (6, -2.5) node{\small $\ket{1}$};
115+
116+
\draw (6, -10) node{\small $\ket{0}$};
117+
%\draw (6, -10.5) node{\small $\ket{1}$};
118+
119+
\draw (6, -5) node{\small $\ket{0}$};
120+
%\draw (6, -5.5) node{\small $\ket{1}$};
121+
122+
\draw (6, -7) node{\small $\ket{0}$};
123+
%\draw (6, -7.5) node{\small $\ket{1}$};
124+
125+
126+
127+
% horizontal lines 2nd level of ancillas
128+
\draw [-] [thick] (0+0.3, -6) to (3+0.5, -6); % 0
129+
\draw [-] [thick] (0+0.3, -6.5) to (3+0.5, -6.5); % 1
130+
131+
132+
% % horizontal lines pt 2
133+
\draw [-] [thick] (3+0.5, -4.5) to (3+3.5, -4.5); % 1
134+
\draw [-] [thick] (3+0.5, -8.5) to (3+3.5, -8.5); % 1
135+
136+
\draw [-] [thick] (3+0.2, -4) to (3+3.5, -4); % 0
137+
\draw [-] [thick] (3+0.2, -8) to (3+3.5, -8); % 0
138+
139+
140+
% % horizontal lines pt 3
141+
\draw [-] [thick] (6+0.5-0.2, -2) to (16, -2); % 0
142+
\draw [-] [thick] (6+0.5, -2.5) to (16, -2.5); % 1
143+
144+
\draw [-] [thick] (6+0.5-0.2, -5) to (16, -5); % 0
145+
\draw [-] [thick] (6+0.5, -5.5) to (16, -5.5); % 1
146+
147+
\draw [-] [thick] (6+0.5-0.2, -7) to (16, -7); % 0
148+
\draw [-] [thick] (6+0.5, -7.5) to (16, -7.5); % 1
149+
150+
\draw [-] [thick] (6+0.5-0.2, -10) to (16, -10); % 0
151+
\draw [-] [thick] (6+0.5, -10.5) to (16, -10.5); % 1
152+
153+
154+
% vertical lines (central to external)
155+
\draw [-] [thick] (3+0.5, -6) to (3+0.5, -4.5); % 0 -> 1
156+
\draw [-] [thick] (3+0.5, -6.5) to (3+0.5, -8.5);
157+
158+
\draw [-] [thick] (6+0.5, -4) to (6+0.5, -2.5);
159+
\draw [-] [thick] (6+0.5, -4.5) to (6+0.5, -5);
160+
\draw [-] [thick] (6+0.5, -8.5) to (6+0.5, -10.5); % 4th
161+
\draw [-] [thick] (6+0.5, -8) to (6+0.5, -7.5);
162+
163+
164+
165+
166+
% CNOTS
167+
\draw[fill=black] (0+0.3+1, 0) circle [radius=0.1];
168+
\draw (0+0.3+1, -6) [thick] circle (0.13);
169+
\draw [-] [thick] (0+0.3+1, 0) to (0+0.3+1, -6);
170+
\draw [-] [thick] (0+0.3+1, -6-0.1) to (0+0.3+1, -6+0.1);
171+
172+
\draw[fill=black] (2, -6) circle [radius=0.1];
173+
\draw (2, -6.5) [thick] circle (0.13);
174+
\draw [-] [thick] (2, -6) to (2, -6.5);
175+
\draw [-] [thick] (2, -6.5+0.1) to (2, -6.5-0.1);
176+
177+
178+
\draw[fill=black] (3+0.3+1, 0.5) circle [radius=0.1];
179+
\draw (3+0.3+1, -4) [thick] circle (0.13);
180+
\draw [-] [thick] (3+0.3+1, 0.5) to (3+0.3+1, -4);
181+
\draw [-] [thick] (3+0.3+1, -4.5) to (3+0.3+1, -4);
182+
\draw[fill=black] (3+0.3+1, -4.5) circle [radius=0.1];
183+
184+
\draw[fill=black] (3+0.3+1+0.5, 0.5) circle [radius=0.1];
185+
\draw (3+0.3+1+0.5, -8) [thick] circle (0.13);
186+
\draw [-] [thick] (3+0.3+1+0.5, 0.5) to (3+0.3+1+0.5, -8.5);
187+
\draw [-] [thick] (3+0.3+1+0.5, -4.5) to (3+0.3+1+0.5, -4);
188+
\draw[fill=black] (3+0.3+1+0.5, -8.5) circle [radius=0.1];
189+
190+
\draw[fill=black] (5.5, -4) circle [radius=0.1];
191+
\draw (5.5, -4.5) [thick] circle (0.13);
192+
\draw [-] [thick] (5.5, -4) to (5.5, -4.5);
193+
\draw [-] [thick] (5.5, -4.5+0.1) to (5.5, -4.5-0.1);
194+
195+
\draw[fill=black] (5.5, -8) circle [radius=0.1];
196+
\draw (5.5, -8.5) [thick] circle (0.13);
197+
\draw [-] [thick] (5.5, -8) to (5.5, -8.5);
198+
\draw [-] [thick] (5.5, -8.5+0.1) to (5.5, -8.5-0.1);
199+
200+
201+
% last controlled on index register
202+
\draw[fill=black] (7, 1) circle [radius=0.1];
203+
\draw[fill=black] (7, -2.5) circle [radius=0.1];
204+
\draw (7, -2) [thick] circle (0.13);
205+
\draw [-] [thick] (7, -2.5) to (7, 1);
206+
207+
208+
209+
\draw[fill=black] (7.5, 1) circle [radius=0.1];
210+
\draw[fill=black] (7.5, -5.5) circle [radius=0.1];
211+
\draw (7.5, -5) [thick] circle (0.13);
212+
\draw [-] [thick] (7.5, -5.5) to (7.5, 1);
213+
214+
215+
\draw[fill=black] (8, 1) circle [radius=0.1];
216+
\draw[fill=black] (8, -7.5) circle [radius=0.1];
217+
\draw (8, -7) [thick] circle (0.13);
218+
\draw [-] [thick] (8, -7.5) to (8, 1);
219+
220+
221+
\draw[fill=black] (8.5, 1) circle [radius=0.1];
222+
\draw[fill=black] (8.5, -10.5) circle [radius=0.1];
223+
\draw (8.5, -10) [thick] circle (0.13);
224+
\draw [-] [thick] (8.5, -10.5) to (8.5, 1);
225+
226+
227+
% last layer of cnots
228+
% \draw[fill=black] (8.5, -2) circle [radius=0.1];
229+
\draw[fill=black] (9, -2) circle [radius=0.1];
230+
\draw (9, -2.5) [thick] circle (0.13);
231+
\draw [-] [thick] (9, -2.5-0.1) to (9, -2);
232+
233+
\draw[fill=black] (9, -5) circle [radius=0.1];
234+
\draw (9, -5.5) [thick] circle (0.13);
235+
\draw [-] [thick] (9, -5.5-0.1) to (9, -5);
236+
237+
238+
\draw[fill=black] (9, -7) circle [radius=0.1];
239+
\draw (9, -7.5) [thick] circle (0.13);
240+
\draw [-] [thick] (9, -7.5-0.1) to (9, -7);
241+
242+
\draw[fill=black] (9, -10) circle [radius=0.1];
243+
\draw (9, -10.5) [thick] circle (0.13);
244+
\draw [-] [thick] (9, -10.5-0.1) to (9, -10);
245+
246+
% writing in memory
247+
\draw[fill=black] (9.5, -10.5) circle [radius=0.1];
248+
\draw[fill=black] (9.5, -15.5-0.05) [thick] circle (0.1);
249+
\draw (9.5, -16.5) [thick] circle (0.13);
250+
\draw [-] [thick] (9.5, -10.5) to (9.5, -16.5-0.1);
251+
252+
\draw[fill=black] (10, -10) circle [radius=0.1];
253+
\draw[fill=black] (10, -15-0.05) [thick] circle (0.1);
254+
\draw (10, -16.5) [thick] circle (0.13);
255+
\draw [-] [thick] (10, -10) to (10, -16.5-0.1);
256+
257+
\draw[fill=black] (10.5, -7.5) circle [radius=0.1];
258+
\draw[fill=black] (10.5, -14.5-0.05) [thick] circle (0.1);
259+
\draw (10.5, -16.5) [thick] circle (0.13);
260+
\draw [-] [thick] (10.5, -7.5) to (10.5, -16.5-0.1);
261+
262+
\draw[fill=black] (11, -7) circle [radius=0.1];
263+
\draw[fill=black] (11, -14-0.05) [thick] circle (0.1);
264+
\draw (11, -16.5) [thick] circle (0.13);
265+
\draw [-] [thick] (11, -7) to (11, -16.5-0.1);
266+
267+
268+
\draw[fill=black] (11.5, -5.5) circle [radius=0.1];
269+
\draw[fill=black] (11.5, -13.5-0.05) [thick] circle (0.1);
270+
\draw (11.5, -16.5) [thick] circle (0.13);
271+
\draw [-] [thick] (11.5, -5.5) to (11.5, -16.5-0.1);
272+
273+
\draw[fill=black] (12, -5) circle [radius=0.1];
274+
\draw[fill=black] (12, -13-0.05) [thick] circle (0.1);
275+
\draw (12, -16.5) [thick] circle (0.13);
276+
\draw [-] [thick] (12, -5) to (12, -16.5-0.1);
277+
278+
279+
\draw[fill=black] (12.5, -2.5) circle [radius=0.1];
280+
\draw[fill=black] (12.5, -12.5-0.05) [thick] circle (0.1);
281+
\draw (12.5, -16.5) [thick] circle (0.13);
282+
\draw [-] [thick] (12.5, -2.5) to (12.5, -16.5-0.1);
283+
284+
\draw[fill=black] (13, -2) circle [radius=0.1];
285+
\draw[fill=black] (13, -12-0.05) [thick] circle (0.1);
286+
\draw (13, -16.5) [thick] circle (0.13);
287+
\draw [-] [thick] (13, -2) to (13, -16.5-0.1);
288+
289+
290+
\end{tikzpicture}
291+
292+
293+
294+
295+
296+
\end{document}

0 commit comments

Comments
 (0)