"
]
@@ -86,14 +105,52 @@
"outputs": [
{
"data": {
- "image/svg+xml": ""
+ "image/svg+xml": [
+ ""
+ ]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
- "image/svg+xml": ""
+ "image/svg+xml": [
+ ""
+ ]
},
"metadata": {},
"output_type": "display_data"
@@ -137,14 +194,62 @@
"outputs": [
{
"data": {
- "image/svg+xml": ""
+ "image/svg+xml": [
+ ""
+ ]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
- "image/svg+xml": ""
+ "image/svg+xml": [
+ ""
+ ]
},
"metadata": {},
"output_type": "display_data"
@@ -229,14 +334,57 @@
},
{
"data": {
- "image/svg+xml": ""
+ "image/svg+xml": [
+ ""
+ ]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
- "image/svg+xml": ""
+ "image/svg+xml": [
+ ""
+ ]
},
"metadata": {},
"output_type": "display_data"
@@ -333,14 +481,109 @@
"outputs": [
{
"data": {
- "image/svg+xml": ""
+ "image/svg+xml": [
+ ""
+ ]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
- "image/svg+xml": ""
+ "image/svg+xml": [
+ ""
+ ]
},
"metadata": {},
"output_type": "display_data"
@@ -419,7 +662,31 @@
},
{
"data": {
- "image/svg+xml": "",
+ "image/svg+xml": [
+ ""
+ ],
"text/plain": [
""
]
@@ -461,7 +728,7 @@
],
"metadata": {
"kernelspec": {
- "display_name": "Python 3.7.5 64-bit ('3.7.5')",
+ "display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@@ -477,7 +744,6 @@
"pygments_lexer": "ipython3",
"version": "3.7.5"
},
- "orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "fe23db6dbd04142dcf620a84033ad5fbdd1968100e6cb68cefa531a9613914d5"
diff --git a/solutions/lecture10.ipynb b/solutions/lecture10.ipynb
new file mode 100644
index 0000000000000000000000000000000000000000..410d0689b51b8a8a8d2dc456264540fcfcfc4eb5
--- /dev/null
+++ b/solutions/lecture10.ipynb
@@ -0,0 +1,103 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Exercise 1\n",
+ "\n",
+ "请验证下面的线路对于所有可能的输入 $q_0 = x, q_1 = y$ 能够生成对应的 $B_{xy}$ 。"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "image/svg+xml": ""
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "input: 1¦00⟩\n",
+ "output: \n",
+ "√2/2¦00⟩\n",
+ "√2/2¦11⟩\n",
+ "\n",
+ "input: 1¦01⟩\n",
+ "output: \n",
+ "√2/2¦00⟩\n",
+ "-√2/2¦11⟩\n",
+ "\n",
+ "input: 1¦10⟩\n",
+ "output: \n",
+ "√2/2¦01⟩\n",
+ "√2/2¦10⟩\n",
+ "\n",
+ "input: 1¦11⟩\n",
+ "output: \n",
+ "-√2/2¦01⟩\n",
+ "√2/2¦10⟩\n",
+ "\n"
+ ]
+ }
+ ],
+ "source": [
+ "from mindquantum.core.circuit import Circuit\n",
+ "from mindquantum.core.gates import H, CNOT\n",
+ "from mindquantum.simulator import Simulator\n",
+ "import numpy as np\n",
+ "from IPython.display import display_svg\n",
+ "\n",
+ "circ = Circuit()\n",
+ "circ += H.on(0)\n",
+ "circ += CNOT.on(1, 0)\n",
+ "display_svg(circ.svg())\n",
+ "\n",
+ "sim = Simulator(\"projectq\", 2)\n",
+ "\n",
+ "for i in range(4):\n",
+ " sim.reset()\n",
+ " state = np.zeros(4)\n",
+ " state[i] = 1\n",
+ " sim.set_qs(state)\n",
+ " print(f\"input: {sim.get_qs(True)}\")\n",
+ " sim.apply_circuit(circ)\n",
+ " print(f\"output: \\n{sim.get_qs(True)}\\n\")"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3.7.5 64-bit ('3.7.5')",
+ "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.7.5"
+ },
+ "orig_nbformat": 4,
+ "vscode": {
+ "interpreter": {
+ "hash": "fe23db6dbd04142dcf620a84033ad5fbdd1968100e6cb68cefa531a9613914d5"
+ }
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/solutions/lecture2.ipynb b/solutions/lecture2.ipynb
index feb22b09665841de3a39c6d0a783b6a848b70c19..e1b7d5ba87af1262b08c2ca019559dc6f29b095a 100644
--- a/solutions/lecture2.ipynb
+++ b/solutions/lecture2.ipynb
@@ -26,14 +26,146 @@
},
{
"data": {
- "image/svg+xml": ""
+ "image/svg+xml": [
+ ""
+ ]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
- "image/svg+xml": "",
+ "image/svg+xml": [
+ ""
+ ],
"text/plain": [
""
]
@@ -158,7 +290,73 @@
},
{
"data": {
- "image/svg+xml": "",
+ "image/svg+xml": [
+ ""
+ ],
"text/plain": [
""
]
@@ -185,7 +383,7 @@
],
"metadata": {
"kernelspec": {
- "display_name": "Python 3.7.5 64-bit ('3.7.5')",
+ "display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@@ -201,7 +399,6 @@
"pygments_lexer": "ipython3",
"version": "3.7.5"
},
- "orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "fe23db6dbd04142dcf620a84033ad5fbdd1968100e6cb68cefa531a9613914d5"
diff --git a/solutions/lecture6.ipynb b/solutions/lecture6.ipynb
index 3cac9f9c1c6b1d9e18f66a6a6437fd5f95922496..d26c9a70217cd6704ba0ae533c37720af5ecd147 100644
--- a/solutions/lecture6.ipynb
+++ b/solutions/lecture6.ipynb
@@ -64,7 +64,7 @@
],
"metadata": {
"kernelspec": {
- "display_name": "Python 3.7.5 64-bit ('3.7.5')",
+ "display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@@ -80,7 +80,6 @@
"pygments_lexer": "ipython3",
"version": "3.7.5"
},
- "orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "fe23db6dbd04142dcf620a84033ad5fbdd1968100e6cb68cefa531a9613914d5"