From 609a5bf1e20f915470cda9472a0610181db41ef9 Mon Sep 17 00:00:00 2001 From: yangguohao <70266361+yangguohao@users.noreply.github.com> Date: Tue, 19 Oct 2021 22:39:01 +0800 Subject: [PATCH] =?UTF-8?q?Create=20=E5=8D=95=E6=B5=8B=E6=96=87=E4=BB=B6.p?= =?UTF-8?q?y?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...25\346\265\213\346\226\207\344\273\266.py" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "documents/\345\215\225\346\265\213\346\226\207\344\273\266.py" diff --git "a/documents/\345\215\225\346\265\213\346\226\207\344\273\266.py" "b/documents/\345\215\225\346\265\213\346\226\207\344\273\266.py" new file mode 100644 index 0000000..acba0e4 --- /dev/null +++ "b/documents/\345\215\225\346\265\213\346\226\207\344\273\266.py" @@ -0,0 +1,25 @@ +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) -- GitLab