tools/states.py
GHZ
Construct an
Returns
py
def GHZ(n: int, d: int) -> StateImplementation
python
def GHZ(n: int, d: int) -> State:
Ket = Basis(d)
vals = sum([Ket(f'{i}' * n) for i in range(d)])
return State(vals)W
Construct the
Returns
py
def W(n: int) -> StateImplementation
python
def W(n: int) -> State:
Ket = Basis(2)
vals = ['0' * i + '1' + '0' * (n - i - 1) for i in range(n)]
vals = sum([Ket(v) for v in vals])
return State(vals)NOON
Construct a two-mode NOON-like state.
Returns
py
def NOON(n: int, theta: float) -> StateImplementation
python
def NOON(n: int, theta: float=0.0) -> State:
Ket = Basis(n + 1)
kets = [Ket(0, n), Ket(n, 0)]
kets = kets[0] + np.exp(1j * n * theta) * kets[1]
return State(kets)Dicke
Construct an
Returns the uniform (unnormalized) superposition over all distinct permutations of
py
def Dicke(n: int, k: int) -> StateImplementation
python
def Dicke(n: int, k: int) -> State:
Ket = Basis(2)
vals = ['0'] * k + ['1'] * (n - k)
vals = set([''.join(p) for p in permutations(vals)])
vals = sum([Ket(v) for v in vals])
return State(vals)Coherent
Truncated coherent state in a finite
Builds
py
def Coherent(N: int, alpha: complex) -> StateImplementation
python
def Coherent(N: int, alpha: complex=1.0) -> State:
Ket = Basis(N + 1)
a2 = abs(alpha) ** 2
norm = np.exp(a2) * (1 - g(N + 1, a2) / F(N))
norm = 1 / np.sqrt(norm)
vec = sum((alpha ** n / np.sqrt(F(n)) * Ket(n) for n in range(N + 1)))
return State(norm * vec)