define common bases
This commit is contained in:
parent
1b7c3a6cdc
commit
c8f46a7174
@ -3,7 +3,7 @@ from collections import defaultdict
|
|||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from lib import State, b_phi_p, b_phi_m, b_psi_p, b_psi_m, s, generate_bins
|
from lib import State, bell_basis, s, generate_bins
|
||||||
|
|
||||||
|
|
||||||
def test_krisi_measurement_2():
|
def test_krisi_measurement_2():
|
||||||
@ -33,7 +33,7 @@ def test_krisi_measurement_2():
|
|||||||
|
|
||||||
# Measure in the Bell's basis
|
# Measure in the Bell's basis
|
||||||
st = State(q0 * q1)
|
st = State(q0 * q1)
|
||||||
meas = st.measure(basis=[b_phi_p, b_phi_m, b_psi_p, b_psi_m])
|
meas = st.measure(basis=bell_basis)
|
||||||
return meas
|
return meas
|
||||||
|
|
||||||
correct = 0
|
correct = 0
|
||||||
@ -115,7 +115,7 @@ def test_krisi_measurement_3():
|
|||||||
if MEASURE_FIRST_BELL:
|
if MEASURE_FIRST_BELL:
|
||||||
# Measure in the Bell's basis
|
# Measure in the Bell's basis
|
||||||
st = State(q0 * q1)
|
st = State(q0 * q1)
|
||||||
meas = st.measure(basis=[b_phi_p, b_phi_m, b_psi_p, b_psi_m])
|
meas = st.measure(basis=bell_basis)
|
||||||
new_st = s("|" + meas + ">")
|
new_st = s("|" + meas + ">")
|
||||||
st = State(new_st * q2)
|
st = State(new_st * q2)
|
||||||
else:
|
else:
|
||||||
|
11
lib.py
11
lib.py
@ -393,6 +393,12 @@ class State(Vector):
|
|||||||
return [x, y, z]
|
return [x, y, z]
|
||||||
|
|
||||||
|
|
||||||
|
class Ket(State):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
"""Alias: Ket is a state"""
|
||||||
|
State.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def test_measure_partial():
|
def test_measure_partial():
|
||||||
state = b_phi_p
|
state = b_phi_p
|
||||||
state.measure_partial(1)
|
state.measure_partial(1)
|
||||||
@ -753,6 +759,11 @@ b_psi_m = State([[0],
|
|||||||
[0]],
|
[0]],
|
||||||
name="{}-".format(REPR_GREEK_PSI))
|
name="{}-".format(REPR_GREEK_PSI))
|
||||||
|
|
||||||
|
# define common bases:
|
||||||
|
computational_basis = [_0, _1]
|
||||||
|
plus_minus_basis = [_p, _m]
|
||||||
|
bell_basis = [b_phi_p, b_psi_p, b_phi_m, b_psi_m]
|
||||||
|
|
||||||
well_known_states = [_p, _m, b_phi_p, b_psi_p, b_phi_m, b_psi_m]
|
well_known_states = [_p, _m, b_phi_p, b_psi_p, b_phi_m, b_psi_m]
|
||||||
|
|
||||||
_ = I = Gate([[1, 0],
|
_ = I = Gate([[1, 0],
|
||||||
|
Loading…
Reference in New Issue
Block a user