Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Quantum
提交
609a5bf1
Q
Quantum
项目概览
PaddlePaddle
/
Quantum
8 个月 前同步成功
通知
20
Star
492
Fork
166
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
5
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
Quantum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
5
Issue
5
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
609a5bf1
编写于
10月 19, 2021
作者:
Y
yangguohao
提交者:
GitHub
10月 19, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Create 单测文件.py
上级
dfa2b163
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
25 addition
and
0 deletion
+25
-0
documents/单测文件.py
documents/单测文件.py
+25
-0
未找到文件。
documents/单测文件.py
0 → 100644
浏览文件 @
609a5bf1
from
paddle_quantum.state
import
density_op_random
from
paddle_quantum.circuit
import
UAnsatz
from
paddle_quantum.utils
import
partial_trace
,
plot_state_in_bloch_sphere
,
partial_trace_discontiguous
,
NKron
,
plot_n_qubit_state_in_bloch_sphere
import
numpy
as
np
import
paddle
cir1
=
UAnsatz
(
1
)
cir2
=
UAnsatz
(
1
)
phi
,
theta
,
omega
=
2
*
np
.
pi
*
np
.
random
.
uniform
(
size
=
3
)
phi
=
paddle
.
to_tensor
(
phi
,
dtype
=
'float64'
)
theta
=
paddle
.
to_tensor
(
theta
,
dtype
=
'float64'
)
omega
=
paddle
.
to_tensor
(
omega
,
dtype
=
'float64'
)
cir1
.
rx
(
phi
,
0
)
cir1
.
rz
(
omega
,
0
)
cir2
.
ry
(
theta
,
0
)
mat1
,
mat2
=
np
.
array
(
cir1
.
run_density_matrix
()),
np
.
array
(
cir2
.
run_density_matrix
())
rho
=
NKron
(
mat1
,
mat2
)
state
=
[
cir1
.
run_state_vector
(),
cir2
.
run_state_vector
(),
rho
]
plot_n_qubit_state_in_bloch_sphere
(
state
,
show_arrow
=
True
)
n
=
2
rho
=
density_op_random
(
n
)
#print(rho)
plot_n_qubit_state_in_bloch_sphere
(
rho
,
show_arrow
=
True
)
plot_n_qubit_state_in_bloch_sphere
(
rho
,
show_qubits
=
[[
0
]],
show_arrow
=
True
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录