Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PyQt5 import QtWidgets, uic
- from PyQt5.QtWidgets import *
- from interface import Ui_Dialog
- import sys
- import numpy as np
- class myinter(QtWidgets.QMainWindow):
- def __init__(self):
- super(myinter, self).__init__()
- self.ui = Ui_Dialog()
- self.ui.setupUi(self)
- def cheek(a, b):
- if (lambda x, y: x ** 2 + y ** 2)(a, b) == 1:
- return True
- return False
- def dX():
- a1P = np.complex(0)
- a2P = np.complex(1)
- b1P = np.complex(1)
- b2P = np.complex(0)
- matX = [[a1P, a2P], [b1P, b2P]]
- return matX
- def dY():
- a1P = np.complex(0)
- a2P = np.complex(0, -1)
- b1P = np.complex(0, 1)
- b2P = np.complex(0)
- matX = [[a1P, a2P], [b1P, b2P]]
- return matX
- def dZ():
- a1P = np.complex(1)
- a2P = np.complex(0)
- b1P = np.complex(0)
- b2P = np.complex(-1)
- matX = [[a1P, a2P], [b1P, b2P]]
- return matX
- def X(a1, b1, a2, b2):
- a = np.complex(a1, b1)
- b = np.complex(a2, b2)
- lL = [a, b]
- liX = np.transpose(lL)
- matX = dX()
- res = np.dot(matX, liX)
- return res
- def Y(a1, b1, a2, b2):
- a = np.complex(a1, b1)
- b = np.complex(a2, b2)
- lL = [a, b]
- liX = np.transpose(lL)
- matX = dY()
- res = np.dot(matX, liX)
- return res
- def Z(a1, b1, a2, b2):
- a = np.complex(a1, b1)
- b = np.complex(a2, b2)
- lL = [a, b]
- liX = np.transpose(lL)
- matX = dZ()
- res = np.dot(matX, liX)
- return res
- def CNOT(a, b):
- if a == 0:
- return b
- elif a == 1:
- if b == 1:
- return 0
- elif b == 0:
- return 1
- else:
- return None
- else:
- return None
- def CCNOT(a1, a2, b):
- if a2 == 0:
- return b
- elif a1 == 1:
- CNOT(a2, b)
- else:
- return None
- def H(a1, b1, a2, b2):
- a = np.complex(a1, b1)
- b = np.complex(a2, b2)
- lL = [a, b]
- lL = np.transpose(lL)
- return (1 / np.sqrt(2)) * np.dot((dX() + dZ()), lL)
- def HN(list):
- n = len(list)
- res = 0
- for i in range(n - 3):
- N = H(list[i + 0], list[i + 1], list[i + 2], list[i + 3])
- res *= N
- return res
- app = QtWidgets.QApplication([])
- application = myinter()
- application.show()
- sys.exit(app.exec())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement