def combine_X(n): #where n is no. pauli's X gates combined_x = wk3.combine_gate(np.array([[0, 1], [1, 0]]), np.array([[0, 1], [1, 0]])) for i in range(0, n - 2): combined_x = wk3.combine_gate(combined_x, np.array([[0, 1], [1, 0]])) return combined_x
def combine_H(n): #where n is no. Hardamard gates combined_h = wk3.combine_gate( (1 / np.sqrt(2)) * np.array([[1, 1], [1, -1]]), (1 / np.sqrt(2)) * np.array([[1, 1], [1, -1]])) for i in range(0, n - 2): combined_h = wk3.combine_gate(combined_h, (1 / np.sqrt(2)) * np.array([[1, 1], [1, -1]])) return combined_h
def superposition(n): #n is no. of state 0 combined_q = wk3.combine_qubits(np.array([[1], [0]]), np.array([[1], [0]])) for i in range(0, n - 2): combined_q = wk3.combine_qubits(combined_q, np.array([[1], [0]])) combined_g = wk3.combine_gate( (1 / np.sqrt(2)) * np.array([[1, 1], [1, -1]]), (1 / np.sqrt(2)) * np.array([[1, 1], [1, -1]])) for i in range(0, n - 2): combined_g = wk3.combine_gate(combined_g, (1 / np.sqrt(2)) * np.array([[1, 1], [1, -1]])) return np.dot(combined_g, combined_q)