模拟小规模量子计算的软件包

QCircuits的Python项目详细描述


www.awebb.info/qcircuits/index.html提供完整的文档。

qcircuits是一个python包,用于基于 quantum circuit model。 它被设计成一个简单、轻量级的界面 易于使用,特别是对于那些刚接触量子计算的人。

安装

使用pip安装:

pip install qcircuits

或者从这里的来源。

示例用法:量子隐形传态

量子电路:

http://www.awebb.info/qcircuits/_images/teleport.png

代码:

import qcircuits as qc

# Instantiating the operators we will need
CNOT = qc.CNOT()
H = qc.Hadamard()
X = qc.PauliX()
Z = qc.PauliZ()

# Alice's hidden state, that she wishes to transport to Bob.
alice = qc.qubit(theta=1, phi=1, global_phase=0.2)

# A previously prepared Bell state, with one qubit owned by
# alice, and another by Bob, now physically separated.
bell_state = qc.bell_state(0, 0)

# The state vector for the whole system.
phi = alice * bell_state

# Alice applies a CNOT gate to her two qubit, and then
# a Hadamard gate to her private qubit.
phi = CNOT(phi, qubit_indices=[0, 1])
phi = H(phi, qubit_indices=[0])

# Alice measures the first two bits, and transmits the classical
# bits to Bob.
# The only uncollapsed part of the state vector is Bob's.
M1, M2 = phi.measure(qubit_indices=[0, 1], remove=True)

# Apply X and/or Z gates to third qubit depending on measurements
if M2:
    print('First bit 1, applying X\n')
    phi = X(phi)
if M1:
    print('Second bit 1, applying Z\n')
    phi = Z(phi)

print('Original state:', alice)
print('\nTeleported state:', phi)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Requestcontextholder在spring 4中具有并发访问权限。IBMWebSphere上的x Web应用程序?   java如何下载、设置和使用Eclipse?   java如何组合这些mysql语句   java JDBC无法连接到openshift上的mysql数据库   如果存在允许正确处理的重载,java对于方便的方法来说是否可行?   使用hibernate序列的java Spring MVC不存在   具有路径的java Selenium ChromeDriver负载扩展问题   读一本书。java中的java文件   退出队列时,Java队列程序结果为空   Java lambda返回带有重复代码问题的列表   java使用意图从其他活动传递数据并在listview中显示   java如何在java中创建JSON输出   java Android:在不破坏或暂停活动的情况下关闭显示   支持Android电视和手机的java多apk   关于Java应用程序测试和调试的一组问题   如何在JavaSE中使用jdbcRealmShiro进行授权   在java中是否有一个无异常检查的URL解析实用程序?   当页面上有多个相同类型的元素时,java会选择一个特定的元素   递归需要帮助发现java代码中的缺陷