def matrix(self): qubit_1, qubit_2 = sorted(list(self.qubit_indices)) first = gates.op_for_qubit(self.gate1, qubit_1, self.num_qubits) second = gates.op_for_qubit(self.gate2, qubit_2, self.num_qubits) product = np.matmul(first, second) return product
def test_y(self): op = gates.op_for_qubit(gates.Y, 2, 2) expected = np.array([[ 0, -1j, 0, 0], [1j, 0, 0, 0], [ 0, 0, 0, -1j], [ 0, 0, 1j, 0]]) self.assertTrue(np.array_equal(expected, op))
def test_z3_three_qubit(self): op = gates.op_for_qubit(gates.Z, 3, 3) self.assertTrue(np.array_equal(z3_three_qubit, op))
def test_y2_three_qubit(self): op = gates.op_for_qubit(gates.Y, 2, 3) self.assertTrue(np.array_equal(y2_three_qubit, op))
def test_z2(self): op = gates.op_for_qubit(gates.Z, 2, 2) self.assertTrue(np.array_equal(z2_two_qubit, op))
def test_y1(self): op = gates.op_for_qubit(gates.Y, 1, 2) self.assertTrue(np.array_equal(y1_two_qubit, op))
def test_single_op(self): op = gates.op_for_qubit(gates.X, 1, 1) self.assertTrue(np.array_equal(gates.X.matrix, op))
def matrix(self): gate = gates.op_for_qubit(gates.Z, self.qubit_index, self.num_qubits) gate_times_v = self.v_coefficient * gate return gate_times_v