21 lines
764 B
Python
21 lines
764 B
Python
import numpy as np
|
|
from lib_q_computer_math import Vector, Matrix, MeasurementOperator, _0, _1, _p, normalize_state, State
|
|
|
|
|
|
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')
|
|
State(hor_filter.on(random_light).m).measure()
|
|
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()
|