|
2 | 2 | "cells": [
|
3 | 3 | {
|
4 | 4 | "cell_type": "markdown",
|
5 |
| - "id": "5c75973b", |
| 5 | + "id": "8533d106", |
6 | 6 | "metadata": {
|
7 | 7 | "cq.autogen": "title_cell"
|
8 | 8 | },
|
|
13 | 13 | {
|
14 | 14 | "cell_type": "code",
|
15 | 15 | "execution_count": null,
|
16 |
| - "id": "c0d3d2b2", |
| 16 | + "id": "b5831fa4", |
17 | 17 | "metadata": {
|
18 | 18 | "cq.autogen": "top_imports"
|
19 | 19 | },
|
|
30 | 30 | },
|
31 | 31 | {
|
32 | 32 | "cell_type": "markdown",
|
33 |
| - "id": "ac237fd0", |
| 33 | + "id": "b85b5ac2", |
34 | 34 | "metadata": {
|
35 | 35 | "cq.autogen": "MultiTargetCNOT.bloq_doc.md"
|
36 | 36 | },
|
|
48 | 48 | {
|
49 | 49 | "cell_type": "code",
|
50 | 50 | "execution_count": null,
|
51 |
| - "id": "a9e53831", |
| 51 | + "id": "387c77c3", |
52 | 52 | "metadata": {
|
53 | 53 | "cq.autogen": "MultiTargetCNOT.bloq_doc.py"
|
54 | 54 | },
|
|
59 | 59 | },
|
60 | 60 | {
|
61 | 61 | "cell_type": "markdown",
|
62 |
| - "id": "70036306", |
| 62 | + "id": "cb66ffb6", |
63 | 63 | "metadata": {
|
64 | 64 | "cq.autogen": "MultiTargetCNOT.example_instances.md"
|
65 | 65 | },
|
|
70 | 70 | {
|
71 | 71 | "cell_type": "code",
|
72 | 72 | "execution_count": null,
|
73 |
| - "id": "40a9ec07", |
| 73 | + "id": "e4d9154a", |
74 | 74 | "metadata": {
|
75 | 75 | "cq.autogen": "MultiTargetCNOT.c_multi_not_symb"
|
76 | 76 | },
|
|
83 | 83 | {
|
84 | 84 | "cell_type": "code",
|
85 | 85 | "execution_count": null,
|
86 |
| - "id": "ecddf931", |
| 86 | + "id": "ca47c43a", |
87 | 87 | "metadata": {
|
88 | 88 | "cq.autogen": "MultiTargetCNOT.c_multi_not"
|
89 | 89 | },
|
|
94 | 94 | },
|
95 | 95 | {
|
96 | 96 | "cell_type": "markdown",
|
97 |
| - "id": "251ca68a", |
| 97 | + "id": "a44ef0b1", |
98 | 98 | "metadata": {
|
99 | 99 | "cq.autogen": "MultiTargetCNOT.graphical_signature.md"
|
100 | 100 | },
|
|
105 | 105 | {
|
106 | 106 | "cell_type": "code",
|
107 | 107 | "execution_count": null,
|
108 |
| - "id": "bff75a03", |
| 108 | + "id": "baafd2bf", |
109 | 109 | "metadata": {
|
110 | 110 | "cq.autogen": "MultiTargetCNOT.graphical_signature.py"
|
111 | 111 | },
|
|
118 | 118 | },
|
119 | 119 | {
|
120 | 120 | "cell_type": "markdown",
|
121 |
| - "id": "bd425677", |
| 121 | + "id": "60bc96ef", |
122 | 122 | "metadata": {
|
123 | 123 | "cq.autogen": "MultiTargetCNOT.call_graph.md"
|
124 | 124 | },
|
|
129 | 129 | {
|
130 | 130 | "cell_type": "code",
|
131 | 131 | "execution_count": null,
|
132 |
| - "id": "a0082f8f", |
| 132 | + "id": "59e8162e", |
133 | 133 | "metadata": {
|
134 | 134 | "cq.autogen": "MultiTargetCNOT.call_graph.py"
|
135 | 135 | },
|
|
141 | 141 | "show_counts_sigma(c_multi_not_symb_sigma)"
|
142 | 142 | ]
|
143 | 143 | },
|
144 |
| - { |
145 |
| - "cell_type": "code", |
146 |
| - "execution_count": null, |
147 |
| - "id": "5457e35b", |
148 |
| - "metadata": {}, |
149 |
| - "outputs": [], |
150 |
| - "source": [ |
151 |
| - "from qualtran.drawing import get_musical_score_data, draw_musical_score\n", |
152 |
| - "\n", |
153 |
| - "draw_musical_score(get_musical_score_data(c_multi_not.decompose_bloq()))" |
154 |
| - ] |
155 |
| - }, |
156 | 144 | {
|
157 | 145 | "cell_type": "markdown",
|
158 |
| - "id": "aba024ec", |
| 146 | + "id": "2de64cfb", |
159 | 147 | "metadata": {
|
160 |
| - "cq.autogen": "MultiControlPauli.bloq_doc.md" |
| 148 | + "cq.autogen": "MultiControlX.bloq_doc.md" |
161 | 149 | },
|
162 | 150 | "source": [
|
163 |
| - "## `MultiControlPauli`\n", |
164 |
| - "Implements multi-control, single-target C^{n}P gate.\n", |
| 151 | + "## `MultiControlX`\n", |
| 152 | + "Implements multi-control, single-target X gate.\n", |
165 | 153 | "\n",
|
166 |
| - "Implements $C^{n}P = (1 - |1^{n}><1^{n}|) I + |1^{n}><1^{n}| P^{n}$ using $n-1$\n", |
167 |
| - "clean ancillas using a multi-controlled `AND` gate. Uses the Toffoli ladder\n", |
168 |
| - "construction described in \"n−2 Ancilla Bits\" section of Ref[1] but uses an\n", |
169 |
| - "$\\text{AND} / \\text{AND}^\\dagger$ ladder instead for computing / uncomputing\n", |
170 |
| - "using clean ancillas instead of the Toffoli ladder. The measurement based\n", |
171 |
| - "uncomputation of $\\text{AND}$ does not consume any magic states and thus has\n", |
172 |
| - "better constant factors.\n", |
| 154 | + "Reduces multiple controls to a single control using an `And` ladder.\n", |
| 155 | + "See class `ControlledViaAnd` for details on construction.\n", |
173 | 156 | "\n",
|
174 |
| - "#### References\n", |
175 |
| - " - [Constructing Large Controlled Nots](https://algassert.com/circuits/2015/06/05/Constructing-Large-Controlled-Nots.html). \n" |
| 157 | + "Alternatively, one can directly use `XGate().controlled(CtrlSpec(cvs=cvs))`\n", |
| 158 | + "\n", |
| 159 | + "#### Parameters\n", |
| 160 | + " - `cvs`: a tuple of `n` control bits, or a `HasLength(n)` to control by `n` 1s. \n", |
| 161 | + "\n", |
| 162 | + "#### Registers\n", |
| 163 | + " - `controls`: control register of type `QBit` and shape `(n,)`.\n", |
| 164 | + " - `target`: single qubit target register.\n" |
176 | 165 | ]
|
177 | 166 | },
|
178 | 167 | {
|
179 | 168 | "cell_type": "code",
|
180 | 169 | "execution_count": null,
|
181 |
| - "id": "bf4f6c5a", |
| 170 | + "id": "9b43be2a", |
182 | 171 | "metadata": {
|
183 |
| - "cq.autogen": "MultiControlPauli.bloq_doc.py" |
| 172 | + "cq.autogen": "MultiControlX.bloq_doc.py" |
184 | 173 | },
|
185 | 174 | "outputs": [],
|
186 | 175 | "source": [
|
187 |
| - "from qualtran.bloqs.mcmt import MultiControlPauli" |
| 176 | + "from qualtran.bloqs.mcmt import MultiControlX" |
188 | 177 | ]
|
189 | 178 | },
|
190 | 179 | {
|
191 | 180 | "cell_type": "markdown",
|
192 |
| - "id": "a3deef58", |
| 181 | + "id": "f9fbb578", |
193 | 182 | "metadata": {
|
194 |
| - "cq.autogen": "MultiControlPauli.example_instances.md" |
| 183 | + "cq.autogen": "MultiControlX.example_instances.md" |
195 | 184 | },
|
196 | 185 | "source": [
|
197 | 186 | "### Example Instances"
|
|
200 | 189 | {
|
201 | 190 | "cell_type": "code",
|
202 | 191 | "execution_count": null,
|
203 |
| - "id": "610dfdf5", |
| 192 | + "id": "050b0f8d", |
204 | 193 | "metadata": {
|
205 |
| - "cq.autogen": "MultiControlPauli.ccpauli" |
| 194 | + "cq.autogen": "MultiControlX.ccpauli" |
206 | 195 | },
|
207 | 196 | "outputs": [],
|
208 | 197 | "source": [
|
209 |
| - "ccpauli = MultiControlPauli(cvs=(1, 0, 1, 0, 1), target_gate=cirq.X)" |
| 198 | + "ccpauli = MultiControlX(cvs=(1, 0, 1, 0, 1))" |
210 | 199 | ]
|
211 | 200 | },
|
212 | 201 | {
|
213 | 202 | "cell_type": "markdown",
|
214 |
| - "id": "29045880", |
| 203 | + "id": "ccf7ef61", |
215 | 204 | "metadata": {
|
216 |
| - "cq.autogen": "MultiControlPauli.graphical_signature.md" |
| 205 | + "cq.autogen": "MultiControlX.graphical_signature.md" |
217 | 206 | },
|
218 | 207 | "source": [
|
219 | 208 | "#### Graphical Signature"
|
|
222 | 211 | {
|
223 | 212 | "cell_type": "code",
|
224 | 213 | "execution_count": null,
|
225 |
| - "id": "df830018", |
| 214 | + "id": "4fb51559", |
226 | 215 | "metadata": {
|
227 |
| - "cq.autogen": "MultiControlPauli.graphical_signature.py" |
| 216 | + "cq.autogen": "MultiControlX.graphical_signature.py" |
228 | 217 | },
|
229 | 218 | "outputs": [],
|
230 | 219 | "source": [
|
|
235 | 224 | },
|
236 | 225 | {
|
237 | 226 | "cell_type": "markdown",
|
238 |
| - "id": "6849b86b", |
| 227 | + "id": "358ff8ae", |
239 | 228 | "metadata": {
|
240 |
| - "cq.autogen": "MultiControlPauli.call_graph.md" |
| 229 | + "cq.autogen": "MultiControlX.call_graph.md" |
241 | 230 | },
|
242 | 231 | "source": [
|
243 | 232 | "### Call Graph"
|
|
246 | 235 | {
|
247 | 236 | "cell_type": "code",
|
248 | 237 | "execution_count": null,
|
249 |
| - "id": "dd1f8a53", |
| 238 | + "id": "216d9bdf", |
250 | 239 | "metadata": {
|
251 |
| - "cq.autogen": "MultiControlPauli.call_graph.py" |
| 240 | + "cq.autogen": "MultiControlX.call_graph.py" |
252 | 241 | },
|
253 | 242 | "outputs": [],
|
254 | 243 | "source": [
|
|
261 | 250 | ],
|
262 | 251 | "metadata": {
|
263 | 252 | "kernelspec": {
|
264 |
| - "display_name": "Python 3 (ipykernel)", |
| 253 | + "display_name": "Python 3", |
265 | 254 | "language": "python",
|
266 | 255 | "name": "python3"
|
267 | 256 | },
|
268 | 257 | "language_info": {
|
269 |
| - "codemirror_mode": { |
270 |
| - "name": "ipython", |
271 |
| - "version": 3 |
272 |
| - }, |
273 |
| - "file_extension": ".py", |
274 |
| - "mimetype": "text/x-python", |
275 |
| - "name": "python", |
276 |
| - "nbconvert_exporter": "python", |
277 |
| - "pygments_lexer": "ipython3", |
278 |
| - "version": "3.10.9" |
| 258 | + "name": "python" |
279 | 259 | }
|
280 | 260 | },
|
281 | 261 | "nbformat": 4,
|
|
0 commit comments