学习日志32

  • 本源量子计算平台使用
bash 复制代码
from numpy import pi
from pyqpanda import *
from pyqpanda.Visualization import circuit_draw

machine = CPUQVM()
machine.init_qvm()

qlist = machine.qAlloc_many(4)
clist = machine.cAlloc_many(4)

measure_prog = QProg()
measure_prog << hadamard_circuit(qlist) \
<< CZ(qlist[1], qlist[2]) \
<< RX(qlist[2], pi / 4) \
<< RX(qlist[1], pi / 4) \
<< CNOT(qlist[0], qlist[2]) \
<< Measure(qlist[0], clist[0])

print(measure_prog)

创建量子线路及其可视化

bash 复制代码
         ┌─┐                             ┌─┐ 
q_0:  |0>─┤H├ ──── ────────────── ───■── ─┤M├ 
          ├─┤      ┌────────────┐    │    └╥┘ 
q_1:  |0>─┤H├ ──■─ ┤RX(0.785398)├ ───┼── ──╫─ 
          ├─┤ ┌─┴┐ ├────────────┤ ┌──┴─┐   ║  
q_2:  |0>─┤H├ ┤CZ├ ┤RX(0.785398)├ ┤CNOT├ ──╫─ 
          ├─┤ └──┘ └────────────┘ └────┘   ║  
q_3:  |0>─┤H├ ──── ────────────── ────── ──╫─ 
          └─┘                              ║  
 c :   / ══════════════════════════════════╩═
                                            0

打印量子态的分布代码

bash 复制代码
from pyqpanda import *
import numpy as np

machine = CPUQVM()
machine.set_configure(50, 50)
machine.init_qvm()
q = machine.qAlloc_many(4)
c = machine.cAlloc_many(4)
prog = QProg()
prog.insert(X(q[1]))\
    .insert(T(q[0]))\
    .insert(RX(q[1], np.pi/2))\
    .insert(RZ(q[0], np.pi/4))
machine.directly_run(prog)
result = machine.get_qstate()
plot_state_city(result)
machine.finalize()

概率分布代码

bash 复制代码
from pyqpanda import *

machine = CPUQVM()
machine.init_qvm()
qubits = machine.qAlloc_many(3)

prog = QProg()
prog << Z(qubits[0])\
    << X1(qubits[1])\
    << H(qubits[:2])

machine.directly_run(prog)
result_dict = machine.prob_run_dict(prog, qubits, -1)
draw_probability_dict(result_dict)
machine.finalize()
相关推荐
genggeng不会代码1 小时前
用于协同显著目标检测的小组协作学习 2021 GCoNet(总结)
学习
搞机小能手2 小时前
六个能够白嫖学习资料的网站
笔记·学习·分类
The_cute_cat4 小时前
25.4.22学习总结
学习
冰茶_5 小时前
.NET MAUI 发展历程:从 Xamarin 到现代跨平台应用开发框架
学习·microsoft·微软·c#·.net·xamarin
帅云毅5 小时前
Web3.0的认知补充(去中心化)
笔记·学习·web3·去中心化·区块链
豆豆5 小时前
day32 学习笔记
图像处理·笔记·opencv·学习·计算机视觉
nenchoumi31195 小时前
VLA 论文精读(十六)FP3: A 3D Foundation Policy for Robotic Manipulation
论文阅读·人工智能·笔记·学习·vln
凉、介5 小时前
PCI 总线学习笔记(五)
android·linux·笔记·学习·pcie·pci
SuperSwaggySUP5 小时前
4/25 研0学习日志
学习
码起来呗6 小时前
基于SpringBoot的高校学习讲座预约系统-项目分享
spring boot·后端·学习