published on in Quantum computing

量子电路设计入门・示例六

在这个示例中,我们将看到 受控非门 与 泡利-X门 的混合使用。

In this example we will see a hybrid use of controlled-NOT gates and Pauli-X gates.

示例六、受控非门 和 泡利-X门

Example 6. Controlled-NOT gate and Pauli-X gate

在这个量子电路中,我们创建了 q0 和 q1 两个量子位元并分别初始化为 0 和 1。

In this quantum circuit, we create two qubits, q0 and q1, and initialize them to 0 and 1 respectively.

接着,我们使用泡利-X门将 q0 反转。然后我们使用受控非门作用于 q0 和 q1,其中 q0 作为控制位元,q1 作为目标位元。在受控非门结束后,我们再使用泡利-X门将 q0 进行反转。

Next, we apply a Pauli-X gate to q0, flipping it. We then apply a controlled-NOT gate between q0 and q1, with q0 as the control qubit and q1 as the target qubit. After the controlled-NOT gate, we apply another Pauli-X gate to q0, flipping it back.

最后,我们对 q0 和 q1 进行测量,并将结果分别保存在 c0 和 c1。

Finally, we measure both q0 and q1, storing the results in c0 and c1 respectively.

经过对该量子电路测量结果的采样,我们会以 100% 的机率得到二进制数值 0 0。

By sampling the measurement of the quantum circuit, we get the binary value 0 0 with 100% probability.