M1 = M1() # Inicjalizacja Bramek X = PauliX() Y = PauliY() Z = PauliZ() H = Hadamard() CNOT = Cnot() I = Identity() # Splątany Qubity Alicji i Boba x = Qubit(Complex(1, 0), Complex(0, 0)) y = Qubit(Complex(1, 0), Complex(0, 0)) x = x * H xy = tensordot(x, y) xy = np.tensordot(CNOT, xy, axes=[1, 0]) print("splątany = ", xy) # Pierwszy krok print("What you whant encode?") opcja = input() if opcja == '00': first = xy elif opcja == '01': X = np.kron(X, I) print(X) first = np.tensordot(X, xy, axes=[1, 0]) elif opcja == '10': Z = np.kron(Z, I) print(Z)
M0 = M0() M1 = M1() # Inicjalizacja Bramek H = Hadamard() CNOT = Cnot() I = Identity() RY_pi_4 = RY(pi / 4) RY_pi_8 = RY(pi / 8) # Splątany Qubity Alicji i Boba qx = Qubit(Complex(1, 0), Complex(0, 0)) qy = Qubit(Complex(1, 0), Complex(0, 0)) qx = qx * H xy = tensordot(qx, qy) first = np.tensordot(CNOT, xy, axes=[1, 0]) # print("splątany = ", xy) RYGATE = np.kron(RY(pi / 4), RY(pi / 8)) # print(RY) second = np.tensordot(RYGATE, first, axes=[1, 0]) # print(second) # print(x, y) # Alice if x == 0: M01 = np.kron(M0, M1) P = np.tensordot(M01, second, axes=[1, 0]) elif x == 1: RY_pi_4 = np.kron(RY(pi / 4), I)
from qubit import Qubit, tensordot, Hadamard, Cnot, Measure, Identity, RCnot, randomQ from complex import Complex import numpy as np import math Cnot = Cnot() I = Identity() q1 = randomQ() q2 = Qubit(Complex(1 / math.sqrt(2), 0), Complex(1 / math.sqrt(2), 0)) q3 = randomQ() Q = tensordot(q1, q3) # Q = np.kron(Q, q3.vector()) print(Q) # Cnot = np.kron(Cnot, I) # print(Cnot) # # Q = np.tensordot(Cnot, Q, axes=[1,0]) # print(Q)