-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
84 lines (66 loc) · 1.46 KB
/
test.py
File metadata and controls
84 lines (66 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#%%
from qiskit import QuantumCircuit, execute, Aer
from qiskit.visualization import plot_histogram, plot_bloch_vector
from math import sqrt, pi
import qiskit
# %%
# from qiskit_textbook.widgets import binary_widget
# binary_widget(nbits=5)
# # %%
# n = 8
# n_q = n
# n_b = n
# qc_output = QuantumCircuit(n_q,n_b)
# # %%
# for j in range(n):
# qc_output.measure(j,j)
# # %%
# qc_output.draw()
# %%
# counts = execute(qc_output,Aer.get_backend('qasm_simulator')).result().get_counts()
# plot_histogram(counts)
# # %%
# qc_encode = QuantumCircuit(n)
# qc_encode.x(7)
# qc_encode.draw()
# # %%
# qc = qc_encode + qc_output
# qc.draw()
# # %%
# counts = execute(qc,Aer.get_backend('qasm_simulator')).result().get_counts()
# plot_histogram(counts)
# # %%
# qc_cnot = QuantumCircuit(2)
# qc_cnot.cx(0,1)
# qc_cnot.draw()
# # %%
# qc = QuantumCircuit(2,2)
# qc.x(0)
# qc.cx(0,1)
# qc.measure(0,0)
# qc.measure(1,1)
# qc.draw()
#%%
qc = QuantumCircuit(1,1)
qc.rx(pi/(pi/.6435),0)
qc.measure(0,0)
qc.draw('mpl')
counts = execute(qc,Aer.get_backend('qasm_simulator'), shots=1).result().get_counts()
print(int(list(counts.keys())[0]))
#plot_histogram(counts)
# # %%
# qc_ha = QuantumCircuit(4,2)
# qc_ha.x(0)
# qc_ha.x(1)
# qc_ha.barrier()
# qc_ha.cx(0,2)
# qc_ha.cx(1,2)
# qc_ha.ccx(0,1,3)
# qc_ha.barrier()
# qc_ha.measure(2,0)
# qc_ha.measure(3,1)
# qc_ha.draw()
# # %%
# counts = execute(qc_ha,Aer.get_backend('qasm_simulator')).result().get_counts()
# plot_histogram(counts)
# %%