|
2 | 2 | "cells": [
|
3 | 3 | {
|
4 | 4 | "cell_type": "markdown",
|
| 5 | + "id": "0b054e8d-d0bb-4613-bddd-81b37f3d2a8e", |
5 | 6 | "metadata": {
|
6 | 7 | "raw_mimetype": "text/restructuredtext"
|
7 | 8 | },
|
|
21 | 22 | {
|
22 | 23 | "cell_type": "code",
|
23 | 24 | "execution_count": 1,
|
| 25 | + "id": "a30d59e4-ebf6-417d-9adf-16de0b1bbbe1", |
24 | 26 | "metadata": {
|
25 | 27 | "raw_mimetype": "text/restructuredtext"
|
26 | 28 | },
|
|
32 | 34 | },
|
33 | 35 | {
|
34 | 36 | "cell_type": "markdown",
|
| 37 | + "id": "1f139c32-2483-406f-8a4c-399cf1945a34", |
35 | 38 | "metadata": {},
|
36 | 39 | "source": [
|
37 | 40 | "Kets are column vectors, i.e. with shape ``(d, 1)``:"
|
|
40 | 43 | {
|
41 | 44 | "cell_type": "code",
|
42 | 45 | "execution_count": 2,
|
| 46 | + "id": "69b02c9c-37c3-427d-99de-b480b7ea4d6d", |
43 | 47 | "metadata": {},
|
44 | 48 | "outputs": [
|
45 | 49 | {
|
|
61 | 65 | },
|
62 | 66 | {
|
63 | 67 | "cell_type": "markdown",
|
| 68 | + "id": "4a731dcf-13e7-4888-a7d1-e7defb06edd3", |
64 | 69 | "metadata": {},
|
65 | 70 | "source": [
|
66 | 71 | "The ``normalized=True`` option can be used to ensure a normalized output.\n",
|
|
71 | 76 | {
|
72 | 77 | "cell_type": "code",
|
73 | 78 | "execution_count": 3,
|
| 79 | + "id": "0770dcd6-e29b-4b92-9072-2b4ade641268", |
74 | 80 | "metadata": {},
|
75 | 81 | "outputs": [
|
76 | 82 | {
|
|
90 | 96 | },
|
91 | 97 | {
|
92 | 98 | "cell_type": "markdown",
|
| 99 | + "id": "f2ab8914-8431-4dad-bb4b-7a6c400c60df", |
93 | 100 | "metadata": {},
|
94 | 101 | "source": [
|
95 | 102 | "And operators are square matrices, i.e. have shape ``(d, d)``:"
|
|
98 | 105 | {
|
99 | 106 | "cell_type": "code",
|
100 | 107 | "execution_count": 4,
|
| 108 | + "id": "6a3a349c-8648-4934-8000-66d3ddf16805", |
101 | 109 | "metadata": {},
|
102 | 110 | "outputs": [
|
103 | 111 | {
|
104 | 112 | "data": {
|
105 | 113 | "text/plain": [
|
106 |
| - "[[ 1.+0.j 0.-2.j -3.+0.j]\n", |
| 114 | + "[[ 1.+0.j 0.-2.j -3.-0.j]\n", |
107 | 115 | " [ 0.+2.j 4.+0.j 0.-6.j]\n",
|
108 | 116 | " [-3.+0.j 0.+6.j 9.+0.j]]"
|
109 | 117 | ]
|
|
119 | 127 | },
|
120 | 128 | {
|
121 | 129 | "cell_type": "markdown",
|
| 130 | + "id": "fb452078-ab1c-4ba5-81e0-799af6ef0f76", |
122 | 131 | "metadata": {},
|
123 | 132 | "source": [
|
124 | 133 | "Which can also be sparse:"
|
|
127 | 136 | {
|
128 | 137 | "cell_type": "code",
|
129 | 138 | "execution_count": 5,
|
| 139 | + "id": "24cab7c2-7dd3-46a7-9acf-f1d3e0cbe5d3", |
130 | 140 | "metadata": {},
|
131 | 141 | "outputs": [
|
132 | 142 | {
|
133 | 143 | "data": {
|
134 | 144 | "text/plain": [
|
135 |
| - "<3x3 sparse matrix of type '<class 'numpy.complex128'>'\n", |
136 |
| - "\twith 9 stored elements in Compressed Sparse Row format>" |
| 145 | + "<Compressed Sparse Row sparse matrix of dtype 'complex128'\n", |
| 146 | + "\twith 9 stored elements and shape (3, 3)>" |
137 | 147 | ]
|
138 | 148 | },
|
139 | 149 | "execution_count": 5,
|
|
147 | 157 | },
|
148 | 158 | {
|
149 | 159 | "cell_type": "markdown",
|
| 160 | + "id": "a10ffe96-9bc3-4e4e-ace8-0098d0e29564", |
150 | 161 | "metadata": {
|
151 | 162 | "raw_mimetype": "text/restructuredtext"
|
152 | 163 | },
|
|
173 | 184 | {
|
174 | 185 | "cell_type": "code",
|
175 | 186 | "execution_count": 6,
|
| 187 | + "id": "7bebe19b-bb7e-4d5d-a55c-63340574aba4", |
176 | 188 | "metadata": {},
|
177 | 189 | "outputs": [
|
178 | 190 | {
|
|
197 | 209 | {
|
198 | 210 | "cell_type": "code",
|
199 | 211 | "execution_count": 7,
|
| 212 | + "id": "0cb44044-6832-4365-a4b0-5f6ed7b940c4", |
200 | 213 | "metadata": {},
|
201 | 214 | "outputs": [
|
202 | 215 | {
|
|
216 | 229 | },
|
217 | 230 | {
|
218 | 231 | "cell_type": "markdown",
|
| 232 | + "id": "9389db86-974f-47a7-94e0-729a34436be2", |
219 | 233 | "metadata": {
|
220 | 234 | "raw_mimetype": "text/restructuredtext"
|
221 | 235 | },
|
|
231 | 245 | {
|
232 | 246 | "cell_type": "code",
|
233 | 247 | "execution_count": 8,
|
| 248 | + "id": "ccb3c8b1-3673-496b-9efe-d15e13e15c45", |
234 | 249 | "metadata": {},
|
235 | 250 | "outputs": [
|
236 | 251 | {
|
|
253 | 268 | {
|
254 | 269 | "cell_type": "code",
|
255 | 270 | "execution_count": 9,
|
| 271 | + "id": "21c148d7-a55c-44cb-bbf3-8de4c9b33f41", |
256 | 272 | "metadata": {},
|
257 | 273 | "outputs": [
|
258 | 274 | {
|
|
273 | 289 | {
|
274 | 290 | "cell_type": "code",
|
275 | 291 | "execution_count": 10,
|
| 292 | + "id": "6916a93e-bbfa-4b37-92f3-a7816d58af28", |
276 | 293 | "metadata": {},
|
277 | 294 | "outputs": [
|
278 | 295 | {
|
|
295 | 312 | {
|
296 | 313 | "cell_type": "code",
|
297 | 314 | "execution_count": 11,
|
| 315 | + "id": "ad4186dc-309d-44b9-abed-5d6af268746a", |
298 | 316 | "metadata": {},
|
299 | 317 | "outputs": [
|
300 | 318 | {
|
|
314 | 332 | },
|
315 | 333 | {
|
316 | 334 | "cell_type": "markdown",
|
| 335 | + "id": "ba59088e-d798-455f-95b8-179512b0874f", |
317 | 336 | "metadata": {
|
318 | 337 | "raw_mimetype": "text/restructuredtext"
|
319 | 338 | },
|
|
327 | 346 | {
|
328 | 347 | "cell_type": "code",
|
329 | 348 | "execution_count": 12,
|
| 349 | + "id": "4012d11b-f4b9-4dd5-af69-96f51299839d", |
330 | 350 | "metadata": {},
|
331 | 351 | "outputs": [
|
332 | 352 | {
|
333 | 353 | "data": {
|
334 | 354 | "text/plain": [
|
335 |
| - "1.0" |
| 355 | + "np.float64(1.0)" |
336 | 356 | ]
|
337 | 357 | },
|
338 | 358 | "execution_count": 12,
|
|
347 | 367 | {
|
348 | 368 | "cell_type": "code",
|
349 | 369 | "execution_count": 13,
|
| 370 | + "id": "a67c2946-6e4b-40e6-91ff-f47c17e5f0d7", |
350 | 371 | "metadata": {},
|
351 | 372 | "outputs": [
|
352 | 373 | {
|
353 | 374 | "data": {
|
354 | 375 | "text/plain": [
|
355 |
| - "0j" |
| 376 | + "np.complex128(0j)" |
356 | 377 | ]
|
357 | 378 | },
|
358 | 379 | "execution_count": 13,
|
|
366 | 387 | },
|
367 | 388 | {
|
368 | 389 | "cell_type": "markdown",
|
| 390 | + "id": "cd62be41-0bf5-422e-b5b5-8cb9a37174d6", |
369 | 391 | "metadata": {},
|
370 | 392 | "source": [
|
371 | 393 | "Here's an example for a much larger (20 qubit), sparse operator expecation,\n",
|
|
375 | 397 | {
|
376 | 398 | "cell_type": "code",
|
377 | 399 | "execution_count": 14,
|
| 400 | + "id": "425bae86-798a-4d9d-a7e0-2690ea7a219b", |
378 | 401 | "metadata": {},
|
379 | 402 | "outputs": [
|
380 | 403 | {
|
381 | 404 | "data": {
|
382 | 405 | "text/plain": [
|
383 |
| - "<1048576x1048576 sparse matrix of type '<class 'numpy.complex128'>'\n", |
384 |
| - "\twith 11534268 stored elements in Compressed Sparse Row format>" |
| 406 | + "<Compressed Sparse Row sparse matrix of dtype 'complex128'\n", |
| 407 | + "\twith 11534284 stored elements and shape (1048576, 1048576)>" |
385 | 408 | ]
|
386 | 409 | },
|
387 | 410 | "execution_count": 14,
|
|
398 | 421 | {
|
399 | 422 | "cell_type": "code",
|
400 | 423 | "execution_count": 15,
|
| 424 | + "id": "4198dbc2-d143-4514-9563-8785ef1395f4", |
401 | 425 | "metadata": {},
|
402 | 426 | "outputs": [
|
403 | 427 | {
|
404 | 428 | "data": {
|
405 | 429 | "text/plain": [
|
406 |
| - "0.9998770131258168" |
| 430 | + "np.float64(1.0004858170636874)" |
407 | 431 | ]
|
408 | 432 | },
|
409 | 433 | "execution_count": 15,
|
|
418 | 442 | {
|
419 | 443 | "cell_type": "code",
|
420 | 444 | "execution_count": 16,
|
| 445 | + "id": "bda59aa7-95c5-4dbf-9b63-95a3635f1ec9", |
421 | 446 | "metadata": {},
|
422 | 447 | "outputs": [
|
423 | 448 | {
|
424 | 449 | "name": "stdout",
|
425 | 450 | "output_type": "stream",
|
426 | 451 | "text": [
|
427 |
| - "59 ms ± 3.85 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n" |
| 452 | + "55.1 ms ± 3.82 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n" |
428 | 453 | ]
|
429 | 454 | }
|
430 | 455 | ],
|
|
435 | 460 | },
|
436 | 461 | {
|
437 | 462 | "cell_type": "markdown",
|
| 463 | + "id": "e68195b9-331c-4e07-b3b2-a1276beb808e", |
438 | 464 | "metadata": {
|
439 | 465 | "raw_mimetype": "text/restructuredtext"
|
440 | 466 | },
|
|
464 | 490 | ":::\n",
|
465 | 491 | "\n",
|
466 | 492 | "Often one wants to sandwich an operator with many identities,\n",
|
467 |
| - "{func}`~quimb.core.ikron` can be used for this:\n" |
| 493 | + "{func}`~quimb.core.ikron` can be used for this:" |
468 | 494 | ]
|
469 | 495 | },
|
470 | 496 | {
|
471 | 497 | "cell_type": "code",
|
472 | 498 | "execution_count": 17,
|
| 499 | + "id": "bf597230-30d7-4d54-b876-e93967891fc7", |
473 | 500 | "metadata": {},
|
474 | 501 | "outputs": [
|
475 | 502 | {
|
|
492 | 519 | },
|
493 | 520 | {
|
494 | 521 | "cell_type": "markdown",
|
| 522 | + "id": "5b7a4905-ee44-4a82-89f1-6e1a612c021b", |
495 | 523 | "metadata": {
|
496 | 524 | "raw_mimetype": "text/restructuredtext"
|
497 | 525 | },
|
|
503 | 531 | {
|
504 | 532 | "cell_type": "code",
|
505 | 533 | "execution_count": 18,
|
| 534 | + "id": "ed53d5cc-a2e7-4acb-b867-cb1e61951d3f", |
506 | 535 | "metadata": {},
|
507 | 536 | "outputs": [
|
508 | 537 | {
|
|
532 | 561 | },
|
533 | 562 | {
|
534 | 563 | "cell_type": "markdown",
|
| 564 | + "id": "753aebb7-8d79-491b-8add-9b2497e6d81a", |
535 | 565 | "metadata": {
|
536 | 566 | "raw_mimetype": "text/restructuredtext"
|
537 | 567 | },
|
|
553 | 583 | {
|
554 | 584 | "cell_type": "code",
|
555 | 585 | "execution_count": 19,
|
| 586 | + "id": "5c6f0168-e595-4472-b78e-e7c551089e31", |
556 | 587 | "metadata": {},
|
557 | 588 | "outputs": [
|
558 | 589 | {
|
559 | 590 | "data": {
|
560 | 591 | "text/plain": [
|
561 |
| - "[[ 0.256+0.j -0.013-0.007j 0.02 +0.008j -0.014+0.007j]\n", |
562 |
| - " [-0.013+0.007j 0.263+0.j -0.011+0.008j 0.016+0.004j]\n", |
563 |
| - " [ 0.02 -0.008j -0.011-0.008j 0.231+0.j 0.01 +0.008j]\n", |
564 |
| - " [-0.014-0.007j 0.016-0.004j 0.01 -0.008j 0.25 +0.j ]]" |
| 592 | + "[[ 0.279+0.j 0.003-0.005j 0.012+0.009j 0.018-0.009j]\n", |
| 593 | + " [ 0.003+0.005j 0.239+0.j -0.005+0.007j -0.005-0.002j]\n", |
| 594 | + " [ 0.012-0.009j -0.005-0.007j 0.24 +0.j -0.015-0.014j]\n", |
| 595 | + " [ 0.018+0.009j -0.005+0.002j -0.015+0.014j 0.242+0.j ]]" |
565 | 596 | ]
|
566 | 597 | },
|
567 | 598 | "execution_count": 19,
|
|
579 | 610 | },
|
580 | 611 | {
|
581 | 612 | "cell_type": "markdown",
|
| 613 | + "id": "5ea15f65-79d4-40a1-993a-82b011dc77e1", |
582 | 614 | "metadata": {
|
583 | 615 | "raw_mimetype": "text/restructuredtext"
|
584 | 616 | },
|
|
590 | 622 | "metadata": {
|
591 | 623 | "celltoolbar": "Raw Cell Format",
|
592 | 624 | "kernelspec": {
|
593 |
| - "display_name": "Python 3.10.8 ('numpy')", |
| 625 | + "display_name": "py312", |
594 | 626 | "language": "python",
|
595 | 627 | "name": "python3"
|
596 | 628 | },
|
|
604 | 636 | "name": "python",
|
605 | 637 | "nbconvert_exporter": "python",
|
606 | 638 | "pygments_lexer": "ipython3",
|
607 |
| - "version": "3.10.8 (main, Nov 4 2022, 13:48:29) [GCC 11.2.0]" |
608 |
| - }, |
609 |
| - "vscode": { |
610 |
| - "interpreter": { |
611 |
| - "hash": "39c10650315d977fb13868ea1402e99f3e10e9885c2c202e692ae90b8995050d" |
612 |
| - } |
| 639 | + "version": "3.12.6" |
613 | 640 | }
|
614 | 641 | },
|
615 | 642 | "nbformat": 4,
|
|
0 commit comments