-
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.
- Loading branch information
Showing
16 changed files
with
625 additions
and
47 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
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,160 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "046f6195", | ||
"metadata": { | ||
"cq.autogen": "title_cell" | ||
}, | ||
"source": [ | ||
"# Bitwise Operations" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e7fb03a9", | ||
"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": "18fe7319", | ||
"metadata": { | ||
"cq.autogen": "Xor.bloq_doc.md" | ||
}, | ||
"source": [ | ||
"## `Xor`\n", | ||
"Xor the value of one register into another via CNOTs.\n", | ||
"\n", | ||
"When both registers are in computational basis and the destination is 0,\n", | ||
"effectively copies the value of the source into the destination.\n", | ||
"\n", | ||
"#### Parameters\n", | ||
" - `dtype`: Data type of the input registers `x` and `y`. \n", | ||
"\n", | ||
"#### Registers\n", | ||
" - `x`: The source register.\n", | ||
" - `y`: The target register.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "9304ba8f", | ||
"metadata": { | ||
"cq.autogen": "Xor.bloq_doc.py" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from qualtran.bloqs.arithmetic import Xor" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "0432ed40", | ||
"metadata": { | ||
"cq.autogen": "Xor.example_instances.md" | ||
}, | ||
"source": [ | ||
"### Example Instances" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "55b01f5d", | ||
"metadata": { | ||
"cq.autogen": "Xor.xor" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"xor = Xor(QAny(4))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "8b8090ff", | ||
"metadata": { | ||
"cq.autogen": "Xor.xor_symb" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"xor_symb = Xor(QAny(sympy.Symbol(\"n\")))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "45b7826f", | ||
"metadata": { | ||
"cq.autogen": "Xor.graphical_signature.md" | ||
}, | ||
"source": [ | ||
"#### Graphical Signature" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "320f183d", | ||
"metadata": { | ||
"cq.autogen": "Xor.graphical_signature.py" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from qualtran.drawing import show_bloqs\n", | ||
"show_bloqs([xor, xor_symb],\n", | ||
" ['`xor`', '`xor_symb`'])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "b17250e4", | ||
"metadata": { | ||
"cq.autogen": "Xor.call_graph.md" | ||
}, | ||
"source": [ | ||
"### Call Graph" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "0ff8ffa9", | ||
"metadata": { | ||
"cq.autogen": "Xor.call_graph.py" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from qualtran.resource_counting.generalizers import ignore_split_join\n", | ||
"xor_g, xor_sigma = xor.call_graph(max_depth=1, generalizer=ignore_split_join)\n", | ||
"show_call_graph(xor_g)\n", | ||
"show_counts_sigma(xor_sigma)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"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
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.