def test_one_qubit_gate_Y(self): qc = QC(2, 0) Y_gate_test = np.array([[0, 0, -1j, 0], [0, 0, 0, -1j], [1j, 0, 0, 0], [0, 1j, 0, 0]]) gate_result = qc._create_1_qubit_gate(Y_gate, 0) np.testing.assert_array_equal(gate_result.toarray(), Y_gate_test)
def test_one_qubit_gate_X(self): qc = QC(2, 0) X_gate_test = np.array([[0, 0, 1, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 1, 0, 0]]) gate_result = qc._create_1_qubit_gate(X_gate, 0) np.testing.assert_array_equal(gate_result.toarray(), X_gate_test)
def test_one_qubit_gate_Z(self): qc = QC(2, 0) Z_gate_test = np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, -1, 0], [0, 0, 0, -1]]) gate_result = qc._create_1_qubit_gate(Z_gate, 0) np.testing.assert_array_equal(gate_result.toarray(), Z_gate_test)
def test_one_qubit_gate_H(self): qc = QC(2, 0) H_gate_test = (1 / np.sqrt(2)) * np.array( [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, -1, 0], [0, 1, 0, -1]]) gate_result = qc._create_1_qubit_gate(H_gate, 0) np.testing.assert_array_equal(gate_result.toarray(), H_gate_test)