test.py 310 字节
Newer Older
Y
yangguohao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
from paddle_quantum.utils import img_to_density_matrix
import paddle
import matplotlib.image
import numpy as np


img_file = '/home/aistudio/f1.jpeg'
rho = (img_to_density_matrix(img_file))

#半正定
w,_=np.linalg.eig(rho)
print(all(w>=0))
#迹为1
print(np.trace(rho))
#shape为[2**n,2**n]
print(rho.shape)