一个非常简单的量子程序将是什么样?


15

看完“ 第一个可编程量子光子芯片 ”。我想知道用于使用量子纠缠的计算机的软件是什么样的。

是否有用于特定量子编程的代码示例?喜欢伪代码还是高级语言?具体来说,什么是可用于创建贝尔状态最短的程序从初始化为一个状态开始| ψ0⟩=| 00⟩同时使用模拟和IBM的一个量子经验处理器,如ibmqx4?

|ψ⟩=1个2(|00⟩+|11⟩)
|ψ0⟩=|00⟩

使概念从传统编程跃入纠缠并非易事。


我也找到了C的libquantum。

Answers:


12

假设您正在考虑基于门的量子计算机,则产生一个被标记状态的最简单方法是产生一个贝尔状态。以下电路显示了贝尔状态。|Φ+⟩

贝尔州

|ψ0⟩|ψ1个⟩|ψ2⟩

|ψ0⟩

|ψ0⟩=|00⟩

|ψ1个⟩

Hadamard-Gate应用于第一个量子位,结果如下:

|ψ1个⟩=(H⊗一世)|00⟩=H|0⟩⊗|0⟩=1个2(|0⟩+|1个⟩)|0⟩=1个2(|00⟩+|1个0⟩)

|ψ2⟩

现在,应用CNOT门并翻转第二个qubit,但仅在第一个qubit的值为1的情况下。结果是

|ψ2⟩=1个2(|00⟩+|1个1个⟩)

|ψ2⟩

尽管从通常的意义上讲,以上方法似乎对您而言并不像编程,但将门应用到状态基本上是对基于门的量子计算机进行编程的方式。存在一些抽象层,使您可以执行高级编程,但可以将命令转换为Gates的应用程序。在IBM量子经验接口提供这样的特征。

在像Microsoft的Q#这样的语言中,上面的示例可能与此类似:

operation BellTest () : ()
{
    body
    {
        // Use two qubits
        using (qubits = Qubit[2])
        {
            Set (One, qubits[0]);
            Set (Zero, qubits[1]);

            // Apply Hadamard gate to the first qubit
            H(qubits[0]);

            // Apply CNOT gate
            CNOT(qubits[0],qubits[1]);
         }
     }
}

可以在以下位置找到更详细的版本(包括测量值):Microsoft:编写Quantum Program。


14

编写量子程序的一种方法是使用QISKit。这可用于在IBM设备上运行程序。该QISKit网站提出下面的代码片段让你去,你想这是一个纠缠电路。它也与datell的回答相同。我将逐行对此进行评论。

# import and initialize the method used to store quantum programs
from qiskit import QuantumProgram
qp = QuantumProgram()
# initialize a quantum register of two qubits
qr = qp.create_quantum_register('qr',2) 
# and a classical register of two bits
cr = qp.create_classical_register('cr',2) 
# create a circuit with them which we call 'Bell'
qc = qp.create_circuit('Bell',[qr],[cr]) 
# apply a Hadamard to the first qubit
qc.h(qr[0]) 
# apply a controlled not with the first qubit as control
qc.cx(qr[0], qr[1]) 
# measure the first qubit and store its result on the first bit
qc.measure(qr[0], cr[0]) 
# the same for the second qubit and bit
qc.measure(qr[1], cr[1]) 
# run the circuit
result = qp.execute('Bell') 
# extract the results
print(result.get_counts('Bell')) 

请注意,此处的“执行”命令仅指定要运行的程序。所有其他设置,例如要使用的设备,要重复获取统计信息的次数等,均设置为默认值。要在ibmqx4上运行1024张照片,您可以改用

results = qp.execute(['Bell'], backend='ibmqx4', shots=1024)

4

我能想到的最简单的量子程序是一个(1位)真随机数发生器。作为量子电路,它看起来像这样:

您首先在状态中准备一个量子位 |0⟩,然后应用Hadamard门来产生叠加 22(|0⟩+|1个⟩)然后在计算基础上进行测量。测量结果是|0⟩ 要么 |1个⟩,每个概率为50%。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.