quantum/play.py
Daniel Tsvetkov 26bc532a81 slight fixes
2020-03-26 17:30:51 +01:00

20 lines
706 B
Python

import numpy as np
from lib_q_computer_math import Vector, Matrix, MeasurementOperator, _0, _1, _p, normalize_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')
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()