Use bitstring DumpMachine format in first notebooks (#574)
This change adds configuration to switch DumpMachine basis state labels to bitstring in the notebooks from the first section. It also shows %trace command.
This commit is contained in:
Родитель
b6afa1813e
Коммит
753ed1fcaa
|
@ -0,0 +1 @@
|
|||
{"dump.basisStateLabelingConvention":"Bitstring"}
|
|
@ -0,0 +1 @@
|
|||
{"dump.basisStateLabelingConvention":"Bitstring"}
|
|
@ -0,0 +1 @@
|
|||
{"dump.basisStateLabelingConvention":"Bitstring"}
|
|
@ -265,9 +265,7 @@
|
|||
"\n",
|
||||
"These demos use the function `DumpMachine` to print the state of the quantum simulator. \n",
|
||||
"If you aren't familiar with the output of this function for single qubits, you should revisit the tutorial on [the concept of a qubit](../Qubit/Qubit.ipynb#Demo:-Examining-Qubit-States-in-Q#). \n",
|
||||
"When printing the state of multi-qubit systems, this function outputs the same information for each multi-qubit basis state.\n",
|
||||
"\n",
|
||||
"> `DumpMachine` prints system states in little-endian format: for three qubits, $|0\\rangle$ is $|000\\rangle$, $|1\\rangle$ is $|100\\rangle$, $|2\\rangle$ is $|010\\rangle$, $|3\\rangle$ is $|110\\rangle$, and so on."
|
||||
"When printing the state of multi-qubit systems, this function outputs the same information for each multi-qubit basis state."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -291,7 +289,7 @@
|
|||
" // The entire system is now in state |10⟩\n",
|
||||
" X(qs[0]);\n",
|
||||
" \n",
|
||||
" Message(\"System in state |10⟩ = |1⟩:\");\n",
|
||||
" Message(\"System in state |10⟩:\");\n",
|
||||
" DumpMachine();\n",
|
||||
" Message(divider);\n",
|
||||
" \n",
|
||||
|
@ -299,7 +297,7 @@
|
|||
" // The entire system is now in state (1/sqrt(2))(|10⟩ + |11⟩)\n",
|
||||
" H(qs[1]);\n",
|
||||
" \n",
|
||||
" Message(\"System in state (1/sqrt(2))(|10⟩ + |11⟩) = (1/sqrt(2))(|1⟩ + |3⟩):\");\n",
|
||||
" Message(\"System in state (1/sqrt(2))(|10⟩ + |11⟩):\");\n",
|
||||
" DumpMachine();\n",
|
||||
" Message(divider);\n",
|
||||
" \n",
|
||||
|
@ -307,7 +305,7 @@
|
|||
" // The entire system is now in state 0.5(|00⟩ + |01⟩ - |10⟩ - |11⟩)\n",
|
||||
" H(qs[0]);\n",
|
||||
" \n",
|
||||
" Message(\"System in state 0.5(|00⟩ + |01⟩ - |10⟩ - |11⟩) = 0.5(|0⟩ + |2⟩ - |1⟩ - |3⟩):\");\n",
|
||||
" Message(\"System in state 0.5(|00⟩ + |01⟩ - |10⟩ - |11⟩):\");\n",
|
||||
" DumpMachine();\n",
|
||||
" Message(divider);\n",
|
||||
" \n",
|
||||
|
|
|
@ -342,7 +342,7 @@
|
|||
"source": [
|
||||
"### <span style=\"color:blue\">Demo: Pauli Gates</span>\n",
|
||||
"\n",
|
||||
"The following cell contains code demonstrating how to apply gates in Q#, using the Pauli $X$ gate as an example. It sets up a series of quantum states, and then shows the result of applying the $X$ gate to each one. To run the demo, run the next cell using `Ctrl+Enter` (`⌘+Enter` on a Mac), then run the cell after it to see the output.\n",
|
||||
"The following cell contains code demonstrating how to apply gates in Q#, using the Pauli $X$ gate as an example. It sets up a series of quantum states, and then shows the result of applying the $X$ gate to each one. To run the demo, run the next cell using `Ctrl+Enter` (`⌘+Enter` on a Mac).\n",
|
||||
"\n",
|
||||
"In the previous tutorial we discussed that the qubit state in Q# cannot be directly assigned or accessed. The same logic is extended to the quantum gates: applying a gate to a qubit modifies the internal state of that qubit but doesn't return the resulting state of the qubit. This is why we never assign the output of these gates to any variables in this demo - they don't produce any output.\n",
|
||||
"\n",
|
||||
|
@ -404,6 +404,13 @@
|
|||
"}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"In the previous tutorials we used `%simulate` command to run the Q# code on the full-state simulator. Here we will use `%trace` command: it will run the code on the full-state simulator as well, but will also print the circuit diagram of the run after the output."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
|
@ -412,7 +419,7 @@
|
|||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%simulate PauliGates_Demo"
|
||||
"%trace PauliGates_Demo"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -904,4 +911,4 @@
|
|||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче