Exemplo n.º 1
0
 def test_num_mcx_ancillas(self):
     """Test the number of ancilla bits for the mcx gate in zero_reflection."""
     #
     # q_0: ──■──────────────────────
     #        │
     # q_1: ──■──────────────────────
     #        │
     # q_2: ──┼────■─────────────────
     #        │    │
     # q_3: ──┼────■─────────────────
     #      ┌─┴─┐  │
     # q_4: ┤ X ├──┼────■────────────
     #      └───┘┌─┴─┐  │
     # q_5: ─────┤ X ├──■────────────
     #      ┌───┐├───┤┌─┴─┐┌───┐┌───┐
     # q_6: ┤ X ├┤ H ├┤ X ├┤ H ├┤ X ├
     #      └───┘└───┘└───┘└───┘└───┘
     oracle = QuantumCircuit(7)
     oracle.x(6)
     oracle.h(6)
     oracle.ccx(0, 1, 4)
     oracle.ccx(2, 3, 5)
     oracle.ccx(4, 5, 6)
     oracle.h(6)
     oracle.x(6)
     grover_op = GroverOperator(oracle, reflection_qubits=[0, 1])
     self.assertEqual(grover_op.width(), 7)
Exemplo n.º 2
0
 def test_num_mcx_ancillas(self):
     """Test the number of ancilla bits for the mcx gate in zero_reflection."""
     oracle = QuantumCircuit(7)
     oracle.x(6)
     oracle.h(6)
     oracle.ccx(0, 1, 4)
     oracle.ccx(2, 3, 5)
     oracle.ccx(4, 5, 6)
     oracle.h(6)
     oracle.x(6)
     grover_op = GroverOperator(oracle, reflection_qubits=[0, 1])
     self.assertEqual(grover_op.width(), 7)