Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #1208 Test #106

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,333 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"from qutip import *\n",
"from qutip.qip import *\n",
"from IPython.display import Image"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Pauli-X, Y and Z Quantum Gates"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Pauli-X gate is one of the most basic and fundamentals gates in quantum circuits. The Pauli-X gate is a single-qubit rotation through pi radians around the x-axis. Here you can see how to create this gate through a QObj."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\\begin{equation*}\\left(\\begin{array}{*{11}c}0.0 & 1.0\\\\1.0 & 0.0\\\\\\end{array}\\right)\\end{equation*}"
],
"text/plain": [
"Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n",
"Qobj data =\n",
"[[0. 1.]\n",
" [1. 0.]]"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x_gate()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The Pauli-Y gate is a single-qubit rotation through pi radians around the y-axis. Here you can see how to create this gate through a QObj."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\\begin{equation*}\\left(\\begin{array}{*{11}c}0.0 & -1.0j\\\\1.0j & 0.0\\\\\\end{array}\\right)\\end{equation*}"
],
"text/plain": [
"Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n",
"Qobj data =\n",
"[[0.+0.j 0.-1.j]\n",
" [0.+1.j 0.+0.j]]"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"y_gate()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The Pauli-Z gate is a single-qubit rotation through pi radians around the z-axis. Here you can see how to create this gate through a QObj."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\\begin{equation*}\\left(\\begin{array}{*{11}c}1.0 & 0.0\\\\0.0 & -1.0\\\\\\end{array}\\right)\\end{equation*}"
],
"text/plain": [
"Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n",
"Qobj data =\n",
"[[ 1. 0.]\n",
" [ 0. -1.]]"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"z_gate()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## S and T Quantum Gates"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The S gate is also known as the phase gate or the Z90 gate, because it represents a 90 degree rotation around the z-axis. Here you can see how to create this gate through a QObj."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = False\\begin{equation*}\\left(\\begin{array}{*{11}c}1.0 & 0.0\\\\0.0 & -1.0j\\\\\\end{array}\\right)\\end{equation*}"
],
"text/plain": [
"Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = False\n",
"Qobj data =\n",
"[[1.+0.j 0.+0.j]\n",
" [0.+0.j 0.-1.j]]"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"s_gate()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The T gate is just another phase gate that satisfies the property S=T*T. Here you can see how to create this gate through a QObj."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = False\\begin{equation*}\\left(\\begin{array}{*{11}c}1.0 & 0.0\\\\0.0 & (0.707+0.707j)\\\\\\end{array}\\right)\\end{equation*}"
],
"text/plain": [
"Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = False\n",
"Qobj data =\n",
"[[1. +0.j 0. +0.j ]\n",
" [0. +0.j 0.70710678+0.70710678j]]"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"t_gate()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Adding previous gates to a QubitCircuit"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[Gate(X, targets=[0], controls=None)]"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"q = QubitCircuit(1)\n",
"q.add_gate(\"X\", targets=[0])\n",
"q.gates"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[Gate(Y, targets=[0], controls=None)]"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"q = QubitCircuit(1)\n",
"q.add_gate(\"Y\", targets=[0])\n",
"q.gates"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[Gate(Z, targets=[0], controls=None)]"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"q = QubitCircuit(1)\n",
"q.add_gate(\"Z\", targets=[0])\n",
"q.gates"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[Gate(S, targets=[0], controls=None)]"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"q = QubitCircuit(1)\n",
"q.add_gate(\"S\", targets=[0])\n",
"q.gates"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[Gate(T, targets=[0], controls=None)]"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"q = QubitCircuit(1)\n",
"q.add_gate(\"T\", targets=[0])\n",
"q.gates"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "qutip-dev-py3",
"language": "python",
"name": "qutip-dev-py3"
},
"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.8.1"
}
},
"nbformat": 4,
"nbformat_minor": 4
}