-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix_zero_sized_registers
- Loading branch information
Showing
15 changed files
with
421 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,279 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "82ad144d", | ||
"metadata": { | ||
"cq.autogen": "title_cell" | ||
}, | ||
"source": [ | ||
"# Z, S, and CZ" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "dfaec0e3", | ||
"metadata": { | ||
"cq.autogen": "top_imports" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from qualtran import Bloq, CompositeBloq, BloqBuilder, Signature, Register\n", | ||
"from qualtran import QBit, QInt, QUInt, QAny\n", | ||
"from qualtran.drawing import show_bloq, show_call_graph, show_counts_sigma\n", | ||
"from typing import *\n", | ||
"import numpy as np\n", | ||
"import sympy\n", | ||
"import cirq" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "aebd73ef", | ||
"metadata": { | ||
"cq.autogen": "ZGate.bloq_doc.md" | ||
}, | ||
"source": [ | ||
"## `ZGate`\n", | ||
"The Z gate.\n", | ||
"\n", | ||
"This causes a phase flip: Z|+> = |-> and vice-versa." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "5a50dd9b", | ||
"metadata": { | ||
"cq.autogen": "ZGate.bloq_doc.py" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from qualtran.bloqs.basic_gates import ZGate" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "4bf0966c", | ||
"metadata": { | ||
"cq.autogen": "ZGate.example_instances.md" | ||
}, | ||
"source": [ | ||
"### Example Instances" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "f1df6149", | ||
"metadata": { | ||
"cq.autogen": "ZGate.zgate" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"zgate = ZGate()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "69313d0e", | ||
"metadata": { | ||
"cq.autogen": "ZGate.graphical_signature.md" | ||
}, | ||
"source": [ | ||
"#### Graphical Signature" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "f386e781", | ||
"metadata": { | ||
"cq.autogen": "ZGate.graphical_signature.py" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from qualtran.drawing import show_bloqs\n", | ||
"show_bloqs([zgate],\n", | ||
" ['`zgate`'])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "b735f98a", | ||
"metadata": { | ||
"cq.autogen": "SGate.bloq_doc.md" | ||
}, | ||
"source": [ | ||
"## `SGate`\n", | ||
"The S gate.\n", | ||
"\n", | ||
"The unitary matrix of `SGate` is\n", | ||
"$$\n", | ||
"\\begin{bmatrix}\n", | ||
" 1 & 0 \\\\\n", | ||
" 0 & i\n", | ||
"\\end{bmatrix}\n", | ||
"$$\n", | ||
"\n", | ||
"It is the 'square root' of the Z gate: $S\\cdot S = Z$.\n", | ||
"\n", | ||
"#### Registers\n", | ||
" - `q`: The qubit\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "232eb559", | ||
"metadata": { | ||
"cq.autogen": "SGate.bloq_doc.py" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from qualtran.bloqs.basic_gates import SGate" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "8313afa6", | ||
"metadata": { | ||
"cq.autogen": "SGate.example_instances.md" | ||
}, | ||
"source": [ | ||
"### Example Instances" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "52c54793", | ||
"metadata": { | ||
"cq.autogen": "SGate.s_gate" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"s_gate = SGate()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "70d66060", | ||
"metadata": { | ||
"cq.autogen": "SGate.graphical_signature.md" | ||
}, | ||
"source": [ | ||
"#### Graphical Signature" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "a4405a00", | ||
"metadata": { | ||
"cq.autogen": "SGate.graphical_signature.py" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from qualtran.drawing import show_bloqs\n", | ||
"show_bloqs([s_gate],\n", | ||
" ['`s_gate`'])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "b4474ada", | ||
"metadata": { | ||
"cq.autogen": "CZ.bloq_doc.md" | ||
}, | ||
"source": [ | ||
"## `CZ`\n", | ||
"Two-qubit controlled-Z gate.\n", | ||
"\n", | ||
"#### Registers\n", | ||
" - `ctrl`: One-bit control register.\n", | ||
" - `target`: One-bit target register.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "81108e72", | ||
"metadata": { | ||
"cq.autogen": "CZ.bloq_doc.py" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from qualtran.bloqs.basic_gates import CZ" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "053ef676", | ||
"metadata": { | ||
"cq.autogen": "CZ.example_instances.md" | ||
}, | ||
"source": [ | ||
"### Example Instances" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "0f233e08", | ||
"metadata": { | ||
"cq.autogen": "CZ.cz" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"cz = CZ()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "ba4f9ff9", | ||
"metadata": { | ||
"cq.autogen": "CZ.graphical_signature.md" | ||
}, | ||
"source": [ | ||
"#### Graphical Signature" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "db97bbab", | ||
"metadata": { | ||
"cq.autogen": "CZ.graphical_signature.py" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from qualtran.drawing import show_bloqs\n", | ||
"show_bloqs([cz],\n", | ||
" ['`cz`'])" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.8" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.