2020-03-26 17:30:51 +01:00
|
|
|
import numpy as np
|
2020-03-26 18:16:46 +01:00
|
|
|
from lib_q_computer_math import Vector, Matrix, MeasurementOperator, _0, _1, _p, normalize_state, State
|
2020-03-26 17:30:51 +01:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
random_pol = Vector([[np.random.uniform(0, 1)], [np.random.uniform(0, 1)]])
|
|
|
|
random_light = normalize_state(random_pol)
|
|
|
|
hor_filter = MeasurementOperator.create_from_prob(Matrix(_0.m), name='h')
|
|
|
|
diag_filter = MeasurementOperator.create_from_prob(Matrix(_p.m), name='d')
|
|
|
|
ver_filter = MeasurementOperator.create_from_prob(Matrix(_1.m), name='v')
|
2020-03-26 18:16:46 +01:00
|
|
|
State(hor_filter.on(random_light).m).measure()
|
2020-03-26 17:30:51 +01:00
|
|
|
print(hor_filter.on(_0))
|
|
|
|
print(ver_filter.on(_0))
|
|
|
|
print(ver_filter.on(hor_filter.on(_0)))
|
|
|
|
print(ver_filter.on(diag_filter.on(hor_filter.on(_0))))
|
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|