|
2 | 2 | "cells": [
|
3 | 3 | {
|
4 | 4 | "cell_type": "markdown",
|
5 |
| - "id": "c231998b", |
| 5 | + "id": "c9483021", |
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": "b572d769", |
| 16 | + "id": "2dd760e6", |
17 | 17 | "metadata": {
|
18 | 18 | "cq.autogen": "top_imports"
|
19 | 19 | },
|
|
30 | 30 | },
|
31 | 31 | {
|
32 | 32 | "cell_type": "markdown",
|
33 |
| - "id": "d3f4ce95", |
| 33 | + "id": "95d8998c", |
34 | 34 | "metadata": {
|
35 | 35 | "cq.autogen": "Add.bloq_doc.md"
|
36 | 36 | },
|
|
55 | 55 | {
|
56 | 56 | "cell_type": "code",
|
57 | 57 | "execution_count": null,
|
58 |
| - "id": "6426bb53", |
| 58 | + "id": "4cb5b704", |
59 | 59 | "metadata": {
|
60 | 60 | "cq.autogen": "Add.bloq_doc.py"
|
61 | 61 | },
|
|
66 | 66 | },
|
67 | 67 | {
|
68 | 68 | "cell_type": "markdown",
|
69 |
| - "id": "3c8caad1", |
| 69 | + "id": "69f415a2", |
70 | 70 | "metadata": {
|
71 | 71 | "cq.autogen": "Add.example_instances.md"
|
72 | 72 | },
|
|
77 | 77 | {
|
78 | 78 | "cell_type": "code",
|
79 | 79 | "execution_count": null,
|
80 |
| - "id": "73929b65", |
| 80 | + "id": "b0c9815d", |
81 | 81 | "metadata": {
|
82 |
| - "cq.autogen": "Add.add_small" |
| 82 | + "cq.autogen": "Add.add_symb" |
83 | 83 | },
|
84 | 84 | "outputs": [],
|
85 | 85 | "source": [
|
86 |
| - "add_small = Add(QUInt(bitsize=4))" |
| 86 | + "n = sympy.Symbol('n')\n", |
| 87 | + "add_symb = Add(QInt(bitsize=n))" |
87 | 88 | ]
|
88 | 89 | },
|
89 | 90 | {
|
90 | 91 | "cell_type": "code",
|
91 | 92 | "execution_count": null,
|
92 |
| - "id": "fbd4dbe9", |
| 93 | + "id": "b481bd7d", |
93 | 94 | "metadata": {
|
94 |
| - "cq.autogen": "Add.add_large" |
| 95 | + "cq.autogen": "Add.add_small" |
95 | 96 | },
|
96 | 97 | "outputs": [],
|
97 | 98 | "source": [
|
98 |
| - "add_large = Add(QUInt(bitsize=64))" |
| 99 | + "add_small = Add(QUInt(bitsize=4))" |
99 | 100 | ]
|
100 | 101 | },
|
101 | 102 | {
|
102 | 103 | "cell_type": "code",
|
103 | 104 | "execution_count": null,
|
104 |
| - "id": "e749abdb", |
| 105 | + "id": "90bc9e29", |
105 | 106 | "metadata": {
|
106 |
| - "cq.autogen": "Add.add_symb" |
| 107 | + "cq.autogen": "Add.add_large" |
107 | 108 | },
|
108 | 109 | "outputs": [],
|
109 | 110 | "source": [
|
110 |
| - "n = sympy.Symbol('n')\n", |
111 |
| - "add_symb = Add(QInt(bitsize=n))" |
| 111 | + "add_large = Add(QUInt(bitsize=64))" |
112 | 112 | ]
|
113 | 113 | },
|
114 | 114 | {
|
115 | 115 | "cell_type": "code",
|
116 | 116 | "execution_count": null,
|
117 |
| - "id": "e5b746c1", |
| 117 | + "id": "2fbbb318", |
118 | 118 | "metadata": {
|
119 |
| - "collapsed": false |
| 119 | + "cq.autogen": "Add.add_diff_size_regs" |
120 | 120 | },
|
121 | 121 | "outputs": [],
|
122 | 122 | "source": [
|
|
125 | 125 | },
|
126 | 126 | {
|
127 | 127 | "cell_type": "markdown",
|
128 |
| - "id": "c3c1a7e4", |
| 128 | + "id": "253212ec", |
129 | 129 | "metadata": {
|
130 | 130 | "cq.autogen": "Add.graphical_signature.md"
|
131 | 131 | },
|
|
136 | 136 | {
|
137 | 137 | "cell_type": "code",
|
138 | 138 | "execution_count": null,
|
139 |
| - "id": "0f92be09", |
| 139 | + "id": "ed24479f", |
140 | 140 | "metadata": {
|
141 | 141 | "cq.autogen": "Add.graphical_signature.py"
|
142 | 142 | },
|
|
149 | 149 | },
|
150 | 150 | {
|
151 | 151 | "cell_type": "markdown",
|
152 |
| - "id": "350cb374", |
| 152 | + "id": "1c55412d", |
153 | 153 | "metadata": {
|
154 | 154 | "cq.autogen": "Add.call_graph.md"
|
155 | 155 | },
|
|
160 | 160 | {
|
161 | 161 | "cell_type": "code",
|
162 | 162 | "execution_count": null,
|
163 |
| - "id": "c36a3fc4", |
| 163 | + "id": "90569a0c", |
164 | 164 | "metadata": {
|
165 | 165 | "cq.autogen": "Add.call_graph.py"
|
166 | 166 | },
|
|
174 | 174 | },
|
175 | 175 | {
|
176 | 176 | "cell_type": "markdown",
|
177 |
| - "id": "ffc76cc5", |
| 177 | + "id": "8ae20541", |
178 | 178 | "metadata": {
|
179 | 179 | "cq.autogen": "OutOfPlaceAdder.bloq_doc.md"
|
180 | 180 | },
|
|
202 | 202 | {
|
203 | 203 | "cell_type": "code",
|
204 | 204 | "execution_count": null,
|
205 |
| - "id": "c2450d62", |
| 205 | + "id": "7c51ccda", |
206 | 206 | "metadata": {
|
207 | 207 | "cq.autogen": "OutOfPlaceAdder.bloq_doc.py"
|
208 | 208 | },
|
|
213 | 213 | },
|
214 | 214 | {
|
215 | 215 | "cell_type": "markdown",
|
216 |
| - "id": "b5c79e25", |
| 216 | + "id": "6e0af527", |
217 | 217 | "metadata": {
|
218 | 218 | "cq.autogen": "OutOfPlaceAdder.example_instances.md"
|
219 | 219 | },
|
|
224 | 224 | {
|
225 | 225 | "cell_type": "code",
|
226 | 226 | "execution_count": null,
|
227 |
| - "id": "e31acd2b", |
| 227 | + "id": "f062b497", |
228 | 228 | "metadata": {
|
229 | 229 | "cq.autogen": "OutOfPlaceAdder.add_oop_symb"
|
230 | 230 | },
|
|
237 | 237 | {
|
238 | 238 | "cell_type": "code",
|
239 | 239 | "execution_count": null,
|
240 |
| - "id": "ef8871a6", |
| 240 | + "id": "0bde421f", |
241 | 241 | "metadata": {
|
242 | 242 | "cq.autogen": "OutOfPlaceAdder.add_oop_small"
|
243 | 243 | },
|
|
249 | 249 | {
|
250 | 250 | "cell_type": "code",
|
251 | 251 | "execution_count": null,
|
252 |
| - "id": "e57b8c8d", |
| 252 | + "id": "ce284cd8", |
253 | 253 | "metadata": {
|
254 | 254 | "cq.autogen": "OutOfPlaceAdder.add_oop_large"
|
255 | 255 | },
|
|
260 | 260 | },
|
261 | 261 | {
|
262 | 262 | "cell_type": "markdown",
|
263 |
| - "id": "01915f46", |
| 263 | + "id": "052cf86a", |
264 | 264 | "metadata": {
|
265 | 265 | "cq.autogen": "OutOfPlaceAdder.graphical_signature.md"
|
266 | 266 | },
|
|
271 | 271 | {
|
272 | 272 | "cell_type": "code",
|
273 | 273 | "execution_count": null,
|
274 |
| - "id": "d117e345", |
| 274 | + "id": "672073d0", |
275 | 275 | "metadata": {
|
276 | 276 | "cq.autogen": "OutOfPlaceAdder.graphical_signature.py"
|
277 | 277 | },
|
|
284 | 284 | },
|
285 | 285 | {
|
286 | 286 | "cell_type": "markdown",
|
287 |
| - "id": "3b6469e0", |
| 287 | + "id": "ab488ede", |
288 | 288 | "metadata": {
|
289 | 289 | "cq.autogen": "OutOfPlaceAdder.call_graph.md"
|
290 | 290 | },
|
|
295 | 295 | {
|
296 | 296 | "cell_type": "code",
|
297 | 297 | "execution_count": null,
|
298 |
| - "id": "ff84301f", |
| 298 | + "id": "311c752e", |
299 | 299 | "metadata": {
|
300 | 300 | "cq.autogen": "OutOfPlaceAdder.call_graph.py"
|
301 | 301 | },
|
|
309 | 309 | },
|
310 | 310 | {
|
311 | 311 | "cell_type": "markdown",
|
312 |
| - "id": "2813f173", |
| 312 | + "id": "62b014b7", |
313 | 313 | "metadata": {
|
314 | 314 | "cq.autogen": "AddK.bloq_doc.md"
|
315 | 315 | },
|
|
324 | 324 | "only clifford operations.\n",
|
325 | 325 | "\n",
|
326 | 326 | "#### Parameters\n",
|
327 |
| - " - `bitsize`: Number of bits used to represent each integer.\n", |
| 327 | + " - `dtype`: data type of the input register `x`\n", |
328 | 328 | " - `k`: The classical integer value to be added to x.\n",
|
329 |
| - " - `cvs`: A tuple of control values. Each entry specifies whether that control line is a \"positive\" control (`cv[i]=1`) or a \"negative\" control (`cv[i]=0`).\n", |
330 |
| - " - `signed`: A boolean condition which controls whether the x register holds a value represented in 2's Complement or Unsigned. This affects the ability to add a negative constant. \n", |
| 329 | + " - `is_controlled`: if True, construct a singly-controlled bloq. \n", |
331 | 330 | "\n",
|
332 | 331 | "#### Registers\n",
|
333 |
| - " - `x`: A bitsize-sized input register (register x above). \n", |
| 332 | + " - `x`: register of type `self.dtype` \n", |
334 | 333 | "\n",
|
335 | 334 | "#### References\n",
|
336 | 335 | " - [Improved quantum circuits for elliptic curve discrete logarithms](https://arxiv.org/abs/2001.09580). Haner et al. 2020. Section 3: Components. \"Integer addition\" and Fig 2a.\n"
|
|
339 | 338 | {
|
340 | 339 | "cell_type": "code",
|
341 | 340 | "execution_count": null,
|
342 |
| - "id": "cd255bf9", |
| 341 | + "id": "3155864a", |
343 | 342 | "metadata": {
|
344 | 343 | "cq.autogen": "AddK.bloq_doc.py"
|
345 | 344 | },
|
|
350 | 349 | },
|
351 | 350 | {
|
352 | 351 | "cell_type": "markdown",
|
353 |
| - "id": "7538f9a5", |
| 352 | + "id": "9009b701", |
354 | 353 | "metadata": {
|
355 | 354 | "cq.autogen": "AddK.example_instances.md"
|
356 | 355 | },
|
|
361 | 360 | {
|
362 | 361 | "cell_type": "code",
|
363 | 362 | "execution_count": null,
|
364 |
| - "id": "4305289f", |
| 363 | + "id": "7e2a9fdf", |
365 | 364 | "metadata": {
|
366 | 365 | "cq.autogen": "AddK.add_k"
|
367 | 366 | },
|
368 | 367 | "outputs": [],
|
369 | 368 | "source": [
|
370 | 369 | "n, k = sympy.symbols('n k')\n",
|
371 |
| - "add_k = AddK(bitsize=n, k=k)" |
| 370 | + "add_k = AddK(QUInt(n), k=k)" |
372 | 371 | ]
|
373 | 372 | },
|
374 | 373 | {
|
375 | 374 | "cell_type": "code",
|
376 | 375 | "execution_count": null,
|
377 |
| - "id": "f6048819", |
| 376 | + "id": "f4e218da", |
378 | 377 | "metadata": {
|
379 | 378 | "cq.autogen": "AddK.add_k_small"
|
380 | 379 | },
|
381 | 380 | "outputs": [],
|
382 | 381 | "source": [
|
383 |
| - "add_k_small = AddK(bitsize=4, k=2, signed=False)" |
| 382 | + "add_k_small = AddK(QUInt(4), k=2)" |
384 | 383 | ]
|
385 | 384 | },
|
386 | 385 | {
|
387 | 386 | "cell_type": "code",
|
388 | 387 | "execution_count": null,
|
389 |
| - "id": "b67fd469", |
| 388 | + "id": "97073a76", |
390 | 389 | "metadata": {
|
391 | 390 | "cq.autogen": "AddK.add_k_large"
|
392 | 391 | },
|
393 | 392 | "outputs": [],
|
394 | 393 | "source": [
|
395 |
| - "add_k_large = AddK(bitsize=64, k=-23, signed=True)" |
| 394 | + "add_k_large = AddK(QInt(64), k=-23)" |
396 | 395 | ]
|
397 | 396 | },
|
398 | 397 | {
|
399 | 398 | "cell_type": "markdown",
|
400 |
| - "id": "b8b04228", |
| 399 | + "id": "57f1032d", |
401 | 400 | "metadata": {
|
402 | 401 | "cq.autogen": "AddK.graphical_signature.md"
|
403 | 402 | },
|
|
408 | 407 | {
|
409 | 408 | "cell_type": "code",
|
410 | 409 | "execution_count": null,
|
411 |
| - "id": "e93e7f2e", |
| 410 | + "id": "d5d7dad4", |
412 | 411 | "metadata": {
|
413 | 412 | "cq.autogen": "AddK.graphical_signature.py"
|
414 | 413 | },
|
|
421 | 420 | },
|
422 | 421 | {
|
423 | 422 | "cell_type": "markdown",
|
424 |
| - "id": "13552795", |
| 423 | + "id": "f1a51ffb", |
425 | 424 | "metadata": {
|
426 | 425 | "cq.autogen": "AddK.call_graph.md"
|
427 | 426 | },
|
|
432 | 431 | {
|
433 | 432 | "cell_type": "code",
|
434 | 433 | "execution_count": null,
|
435 |
| - "id": "d8d6584e", |
| 434 | + "id": "cbfc2d39", |
436 | 435 | "metadata": {
|
437 | 436 | "cq.autogen": "AddK.call_graph.py"
|
438 | 437 | },
|
|
443 | 442 | "show_call_graph(add_k_g)\n",
|
444 | 443 | "show_counts_sigma(add_k_sigma)"
|
445 | 444 | ]
|
446 |
| - }, |
447 |
| - { |
448 |
| - "cell_type": "code", |
449 |
| - "execution_count": null, |
450 |
| - "id": "8853ae5d", |
451 |
| - "metadata": { |
452 |
| - "cq.autogen": "Add.add_diff_size_regs" |
453 |
| - }, |
454 |
| - "outputs": [], |
455 |
| - "source": [ |
456 |
| - "add_diff_size_regs = Add(QUInt(bitsize=4), QUInt(bitsize=16))" |
457 |
| - ] |
458 | 445 | }
|
459 | 446 | ],
|
460 | 447 | "metadata": {
|
461 | 448 | "kernelspec": {
|
462 |
| - "display_name": "Python 3 (ipykernel)", |
| 449 | + "display_name": "Python 3", |
463 | 450 | "language": "python",
|
464 | 451 | "name": "python3"
|
465 | 452 | },
|
466 | 453 | "language_info": {
|
467 |
| - "codemirror_mode": { |
468 |
| - "name": "ipython", |
469 |
| - "version": 3 |
470 |
| - }, |
471 |
| - "file_extension": ".py", |
472 |
| - "mimetype": "text/x-python", |
473 |
| - "name": "python", |
474 |
| - "nbconvert_exporter": "python", |
475 |
| - "pygments_lexer": "ipython3", |
476 |
| - "version": "3.11.7" |
| 454 | + "name": "python" |
477 | 455 | }
|
478 | 456 | },
|
479 | 457 | "nbformat": 4,
|
|
0 commit comments