Пример #1
0
    def test_CZ_gate_cqubit_1(self):
        qc = QC(2, 0)
        CZ_gate_test = np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0],
                                 [0, 0, 0, -1]])

        gate_result = qc._create_2_qubit_gate(CZ_gate, 1, 0)
        np.testing.assert_array_equal(gate_result.toarray(), CZ_gate_test)
Пример #2
0
    def test_CNOT_gate_cqubit_0(self):
        qc = QC(2, 0)
        CNOT_gate_test = np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1],
                                   [0, 0, 1, 0]])

        gate_result = qc._create_2_qubit_gate(CNOT_gate, 0, 1)
        np.testing.assert_array_equal(gate_result.toarray(), CNOT_gate_test)
Пример #3
0
    def test_SWAP_gate_cqubit_1(self):
        qc = QC(2, 0)

        gate_result = qc._create_2_qubit_gate(SWAP_gate, 0, 1)
        np.testing.assert_array_equal(gate_result.toarray(), SWAP_gate.matrix)