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

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第三方库


热门话题
ArrayList Java中的搜索字符串   另一个web应用程序的java访问会话   另一个应用程序中的活动和服务之间的java通信   java根据Json字符串类型将Json字符串转换为对象   eclipse如何解决java中的错误异常。lang.NoSuchMethodError:'java。字符串javax。摆动JOptionPane。showInputDialog(java.lang.String)'   线程“main”java中的安卓异常。lang.NoClassDefFoundError:org/codehaus/jackson/JsonParseException   java如何在安卓 emulator上显示Mat图像?使用NDK   Java在本地读取测试源文件,但在服务器上读取失败   java dowhile循环用于计算输入数字中的数字。故障排除代码   JAva初学者在编写获取成本的方法时遇到困难   java是shell游戏。我如何让物体移动,特别是在特定的曲线上,但顺序是随机的?   java如何区分两个同名的JButton   java为什么我在Spring Boot中需要一个接口?   java将文件路径插入数据库将删除\   使用InterfaceType初始化java对象   java如何部署一个分为Angular、Spring Boot和MySQL的项目?   java如何使用Symja解决不等式?