Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. from PyQt5 import QtWidgets, uic
  2. from PyQt5.QtWidgets import *
  3. from interface import Ui_Dialog
  4. import sys
  5. import numpy as np
  6.  
  7.  
  8. class myinter(QtWidgets.QMainWindow):
  9. def __init__(self):
  10. super(myinter, self).__init__()
  11. self.ui = Ui_Dialog()
  12. self.ui.setupUi(self)
  13.  
  14.  
  15. def cheek(a, b):
  16. if (lambda x, y: x ** 2 + y ** 2)(a, b) == 1:
  17. return True
  18. return False
  19.  
  20.  
  21. def dX():
  22. a1P = np.complex(0)
  23. a2P = np.complex(1)
  24. b1P = np.complex(1)
  25. b2P = np.complex(0)
  26. matX = [[a1P, a2P], [b1P, b2P]]
  27. return matX
  28.  
  29.  
  30. def dY():
  31. a1P = np.complex(0)
  32. a2P = np.complex(0, -1)
  33. b1P = np.complex(0, 1)
  34. b2P = np.complex(0)
  35. matX = [[a1P, a2P], [b1P, b2P]]
  36. return matX
  37.  
  38.  
  39. def dZ():
  40. a1P = np.complex(1)
  41. a2P = np.complex(0)
  42. b1P = np.complex(0)
  43. b2P = np.complex(-1)
  44. matX = [[a1P, a2P], [b1P, b2P]]
  45. return matX
  46.  
  47.  
  48. def X(a1, b1, a2, b2):
  49. a = np.complex(a1, b1)
  50. b = np.complex(a2, b2)
  51. lL = [a, b]
  52. liX = np.transpose(lL)
  53.  
  54. matX = dX()
  55.  
  56. res = np.dot(matX, liX)
  57. return res
  58.  
  59.  
  60. def Y(a1, b1, a2, b2):
  61. a = np.complex(a1, b1)
  62. b = np.complex(a2, b2)
  63. lL = [a, b]
  64. liX = np.transpose(lL)
  65.  
  66. matX = dY()
  67.  
  68. res = np.dot(matX, liX)
  69. return res
  70.  
  71.  
  72. def Z(a1, b1, a2, b2):
  73. a = np.complex(a1, b1)
  74. b = np.complex(a2, b2)
  75. lL = [a, b]
  76. liX = np.transpose(lL)
  77.  
  78. matX = dZ()
  79.  
  80. res = np.dot(matX, liX)
  81. return res
  82.  
  83.  
  84. def CNOT(a, b):
  85. if a == 0:
  86. return b
  87. elif a == 1:
  88. if b == 1:
  89. return 0
  90. elif b == 0:
  91. return 1
  92. else:
  93. return None
  94. else:
  95. return None
  96.  
  97.  
  98. def CCNOT(a1, a2, b):
  99. if a2 == 0:
  100. return b
  101. elif a1 == 1:
  102. CNOT(a2, b)
  103. else:
  104. return None
  105.  
  106.  
  107. def H(a1, b1, a2, b2):
  108. a = np.complex(a1, b1)
  109. b = np.complex(a2, b2)
  110. lL = [a, b]
  111. lL = np.transpose(lL)
  112. return (1 / np.sqrt(2)) * np.dot((dX() + dZ()), lL)
  113.  
  114.  
  115. def HN(list):
  116. n = len(list)
  117. res = 0
  118. for i in range(n - 3):
  119. N = H(list[i + 0], list[i + 1], list[i + 2], list[i + 3])
  120. res *= N
  121. return res
  122.  
  123.  
  124. app = QtWidgets.QApplication([])
  125. application = myinter()
  126. application.show()
  127.  
  128. sys.exit(app.exec())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement