Skip to content

Commit

Permalink
update demo example
Browse files Browse the repository at this point in the history
  • Loading branch information
kaosmicadei committed Jul 18, 2024
1 parent 8e20750 commit e50664a
Showing 1 changed file with 35 additions and 18 deletions.
53 changes: 35 additions & 18 deletions examples/example.ipynb → examples/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
"## Syntax\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Improve notation"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -226,24 +233,24 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1.0"
"MyGate[0] MyGate[1, 2]"
]
},
"execution_count": 7,
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"MyGate = unitary_hermitian_operator('MyGate')\n",
"\n",
"MyGate(0, 1) * MyGate(0, 1)"
"MyGate(2, 1) * MyGate(0)"
]
},
{
Expand Down Expand Up @@ -325,7 +332,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## 🚧 Symbolic analysis"
"## Symbolic analysis 🚧"
]
},
{
Expand Down Expand Up @@ -380,17 +387,24 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RX(0.5 a phi)[2] CZ[*] RY(0.5 b phi)[0]\n"
]
},
{
"data": {
"text/plain": [
"Model(\n",
" register=AllocQubits(\n",
" num_qubits=3,\n",
" qubit_positions=[],\n",
" grid_type=None,\n",
" qubit_positions=[(0, 0), (0, 1), (1, 0)],\n",
" grid_type=triangular,\n",
" grid_scale=1.0,\n",
" options={},\n",
" ),\n",
Expand All @@ -408,18 +422,21 @@
" Assign('%3', Call('mul', Load('%2'), Load('phi'))),\n",
" QuInstruct('ry', Support(target=(0,)), Load('%3')),\n",
" ],\n",
" directives={},\n",
" directives={\n",
" 'enable_digital_analog': True,\n",
" },\n",
" settings={},\n",
")"
]
},
"execution_count": 12,
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"expr = RX(a * phi / 2)(2) * CZ() * RY(b * phi / 2)(0)\n",
"print(expr)\n",
"\n",
"irc(expr)"
]
Expand Down Expand Up @@ -525,14 +542,14 @@
{
"data": {
"text/plain": [
"Counter({'101': 137,\n",
" '011': 133,\n",
" '000': 130,\n",
" '010': 125,\n",
" '001': 124,\n",
" '100': 119,\n",
" '110': 117,\n",
" '111': 115})"
"Counter({'100': 138,\n",
" '110': 134,\n",
" '010': 132,\n",
" '101': 130,\n",
" '000': 124,\n",
" '011': 120,\n",
" '111': 114,\n",
" '001': 108})"
]
},
"execution_count": 14,
Expand Down

0 comments on commit e50664a

Please sign in to comment.