PyOR Quantum

Author: Vineeth Thalakottoor

Introduction to kets and bras

[1]:
# Define the source path
SourcePath = '/media/HD2/Vineeth/PostDoc_Simulations/Github/PyOR_V1/PyOR_Combined/PyOR/Source_Doc'

# Add source path
import sys
sys.path.append(SourcePath)

# Import PyOR package
from PyOR_QuantumLibrary import QuantumLibrary
QLib = QuantumLibrary()
[2]:
ket1 = QLib.Basis_Ket(2,0, PrintDefault=True)
ket1.matrix
Quantum object initialized: shape=(2, 1), type='ket', dtype=complex128
[2]:
$\displaystyle \left[\begin{matrix}1.0\\0\end{matrix}\right]$
[3]:
ket2 = QLib.Basis_Ket(2,1, PrintDefault=True)
ket2.matrix
Quantum object initialized: shape=(2, 1), type='ket', dtype=complex128
[3]:
$\displaystyle \left[\begin{matrix}0\\1.0\end{matrix}\right]$
[4]:
bra1 = QLib.Basis_Bra(2,0, PrintDefault=True)
bra1.matrix
Quantum object initialized: shape=(1, 2), type='bra', dtype=complex128
[4]:
$\displaystyle \left[\begin{matrix}1.0 & 0\end{matrix}\right]$
[5]:
bra2 = QLib.Basis_Bra(2,1, PrintDefault=True)
bra2.matrix
Quantum object initialized: shape=(1, 2), type='bra', dtype=complex128
[5]:
$\displaystyle \left[\begin{matrix}0 & 1.0\end{matrix}\right]$
[6]:
# Create a state
psi1 = 1 * ket1 + 2 * ket2
psi1.matrix
[6]:
$\displaystyle \left[\begin{matrix}1.0\\2.0\end{matrix}\right]$