experiments with qiskit
This commit is contained in:
parent
911d58bfde
commit
1106bc3d42
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
venv
|
venv
|
||||||
.idea
|
.idea
|
||||||
__pycache__
|
__pycache__
|
||||||
|
*.png
|
||||||
|
@ -11,17 +11,22 @@ from qiskit import(
|
|||||||
QuantumCircuit,
|
QuantumCircuit,
|
||||||
execute,
|
execute,
|
||||||
Aer)
|
Aer)
|
||||||
from qiskit.visualization import plot_histogram
|
from qiskit.visualization import plot_histogram, plot_bloch_vector
|
||||||
|
from matplotlib import pyplot as plt
|
||||||
|
|
||||||
from scipy.stats import unitary_group
|
from scipy.stats import unitary_group
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
|
|
||||||
from qiskit.quantum_info.random.utils import random_state
|
from qiskit.quantum_info.random.utils import random_state
|
||||||
|
|
||||||
# Use Aer's qasm_simulator
|
# Use Aer's qasm_simulator
|
||||||
simulator = Aer.get_backend('qasm_simulator')
|
simulator = Aer.get_backend('qasm_simulator')
|
||||||
|
|
||||||
|
def create_bloch_vector(theta, phi):
|
||||||
|
x =np.sin(theta)*np.cos(phi)
|
||||||
|
y =np.sin(theta)*np.sin(phi)
|
||||||
|
z =np.cos(theta)
|
||||||
|
return [x,y,z]
|
||||||
|
|
||||||
|
|
||||||
def perform_exp(iterations=100):
|
def perform_exp(iterations=100):
|
||||||
@ -36,7 +41,6 @@ def perform_exp(iterations=100):
|
|||||||
theta = np.arccos(1 - 2 * t)
|
theta = np.arccos(1 - 2 * t)
|
||||||
phi = round(np.random.uniform(0, 2 * np.pi), 10)
|
phi = round(np.random.uniform(0, 2 * np.pi), 10)
|
||||||
|
|
||||||
|
|
||||||
# 0_case, identical states
|
# 0_case, identical states
|
||||||
# qc.r(theta, phi, 0)
|
# qc.r(theta, phi, 0)
|
||||||
# qc.r(theta, phi, 1)
|
# qc.r(theta, phi, 1)
|
||||||
@ -46,8 +50,20 @@ def perform_exp(iterations=100):
|
|||||||
# qc.r(theta+np.pi, phi, 1)
|
# qc.r(theta+np.pi, phi, 1)
|
||||||
|
|
||||||
# my_case, phase difference DOESNT WORK
|
# my_case, phase difference DOESNT WORK
|
||||||
|
phi1 = 2 * np.pi - phi
|
||||||
qc.r(theta, phi, 0)
|
qc.r(theta, phi, 0)
|
||||||
qc.r(theta, 2*np.pi - phi, 1)
|
qc.r(theta, phi1, 1)
|
||||||
|
|
||||||
|
# print(theta, phi, phi1)
|
||||||
|
|
||||||
|
# q0 = create_bloch_vector(theta, phi)
|
||||||
|
# plot_bloch_vector(q0)
|
||||||
|
# plt.show()
|
||||||
|
#
|
||||||
|
# q1 = create_bloch_vector(theta, phi1)
|
||||||
|
# plot_bloch_vector(q1)
|
||||||
|
# plt.show()
|
||||||
|
|
||||||
|
|
||||||
# Measure in the Bell's basis
|
# Measure in the Bell's basis
|
||||||
qc.cx(0, 1)
|
qc.cx(0, 1)
|
||||||
@ -57,7 +73,6 @@ def perform_exp(iterations=100):
|
|||||||
|
|
||||||
# print(qc)
|
# print(qc)
|
||||||
|
|
||||||
|
|
||||||
job = execute(qc, simulator, shots=1)
|
job = execute(qc, simulator, shots=1)
|
||||||
result = job.result()
|
result = job.result()
|
||||||
# print(result)
|
# print(result)
|
||||||
@ -73,9 +88,5 @@ def perform_exp(iterations=100):
|
|||||||
print("{}: {}".format(k, v))
|
print("{}: {}".format(k, v))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
perform_exp()
|
perform_exp()
|
||||||
|
@ -16,6 +16,7 @@ from qiskit.visualization import plot_histogram
|
|||||||
from scipy.stats import unitary_group
|
from scipy.stats import unitary_group
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
|
|
||||||
def perform_exp(iterations=1000):
|
def perform_exp(iterations=1000):
|
||||||
simulator = Aer.get_backend('qasm_simulator')
|
simulator = Aer.get_backend('qasm_simulator')
|
||||||
all_counts = defaultdict(int)
|
all_counts = defaultdict(int)
|
||||||
@ -38,7 +39,6 @@ def perform_exp(iterations=1000):
|
|||||||
|
|
||||||
# print(qc)
|
# print(qc)
|
||||||
|
|
||||||
|
|
||||||
job = execute(qc, simulator, shots=1)
|
job = execute(qc, simulator, shots=1)
|
||||||
result = job.result()
|
result = job.result()
|
||||||
# print(result)
|
# print(result)
|
||||||
@ -54,9 +54,5 @@ def perform_exp(iterations=1000):
|
|||||||
print("{}: {}".format(k, v))
|
print("{}: {}".format(k, v))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
perform_exp()
|
perform_exp()
|
||||||
|
@ -1,41 +1,75 @@
|
|||||||
|
attrs==19.3.0
|
||||||
backcall==0.1.0
|
backcall==0.1.0
|
||||||
cachetools==3.1.1
|
cachetools==3.1.1
|
||||||
certifi==2019.9.11
|
certifi==2019.9.11
|
||||||
|
cffi==1.13.2
|
||||||
chardet==3.0.4
|
chardet==3.0.4
|
||||||
cirq==0.7.0
|
cirq==0.7.0
|
||||||
|
cryptography==2.8
|
||||||
|
cvxopt==1.2.4
|
||||||
cycler==0.10.0
|
cycler==0.10.0
|
||||||
Cython==0.29.14
|
Cython==0.29.14
|
||||||
|
dataclasses==0.7
|
||||||
decorator==4.4.0
|
decorator==4.4.0
|
||||||
|
dill==0.3.1.1
|
||||||
|
dlx==1.0.4
|
||||||
|
docloud==1.0.375
|
||||||
|
docplex==2.12.182
|
||||||
|
fastdtw==0.3.4
|
||||||
google-api-python-client==1.7.11
|
google-api-python-client==1.7.11
|
||||||
google-auth==1.6.3
|
google-auth==1.6.3
|
||||||
google-auth-httplib2==0.0.3
|
google-auth-httplib2==0.0.3
|
||||||
|
h5py==2.10.0
|
||||||
httplib2==0.13.1
|
httplib2==0.13.1
|
||||||
idna==2.8
|
idna==2.8
|
||||||
|
importlib-metadata==1.5.0
|
||||||
|
inflection==0.3.1
|
||||||
ipython==7.8.0
|
ipython==7.8.0
|
||||||
ipython-genutils==0.2.0
|
ipython-genutils==0.2.0
|
||||||
jedi==0.15.1
|
jedi==0.15.1
|
||||||
|
joblib==0.14.1
|
||||||
|
jsonschema==3.2.0
|
||||||
kiwisolver==1.1.0
|
kiwisolver==1.1.0
|
||||||
llvmlite==0.31.0
|
llvmlite==0.31.0
|
||||||
|
marshmallow==3.3.0
|
||||||
|
marshmallow-polyfield==5.8
|
||||||
matplotlib==3.1.2
|
matplotlib==3.1.2
|
||||||
|
more-itertools==8.2.0
|
||||||
mpmath==1.1.0
|
mpmath==1.1.0
|
||||||
|
nest-asyncio==1.2.3
|
||||||
networkx==2.3
|
networkx==2.3
|
||||||
|
ntlm-auth==1.4.0
|
||||||
numba==0.47.0
|
numba==0.47.0
|
||||||
numpy==1.17.2
|
numpy==1.17.2
|
||||||
pandas==0.25.3
|
pandas==0.25.3
|
||||||
parso==0.5.1
|
parso==0.5.1
|
||||||
pexpect==4.7.0
|
pexpect==4.7.0
|
||||||
pickleshare==0.7.5
|
pickleshare==0.7.5
|
||||||
|
ply==3.11
|
||||||
prompt-toolkit==2.0.9
|
prompt-toolkit==2.0.9
|
||||||
protobuf==3.8.0
|
protobuf==3.8.0
|
||||||
|
psutil==5.6.7
|
||||||
ptyprocess==0.6.0
|
ptyprocess==0.6.0
|
||||||
pyasn1==0.4.7
|
pyasn1==0.4.7
|
||||||
pyasn1-modules==0.2.6
|
pyasn1-modules==0.2.6
|
||||||
|
pycparser==2.19
|
||||||
Pygments==2.4.2
|
Pygments==2.4.2
|
||||||
pyparsing==2.4.2
|
pyparsing==2.4.2
|
||||||
|
pyrsistent==0.15.7
|
||||||
|
pyscf==1.7.0
|
||||||
python-dateutil==2.8.0
|
python-dateutil==2.8.0
|
||||||
pytz==2019.2
|
pytz==2019.2
|
||||||
|
qiskit==0.14.1
|
||||||
|
qiskit-aer==0.3.4
|
||||||
|
qiskit-aqua==0.6.2
|
||||||
|
qiskit-ibmq-provider==0.4.5
|
||||||
|
qiskit-ignis==0.2.0
|
||||||
|
qiskit-terra==0.11.1
|
||||||
|
Quandl==3.5.0
|
||||||
requests==2.22.0
|
requests==2.22.0
|
||||||
|
requests-ntlm==1.1.0
|
||||||
rsa==4.0
|
rsa==4.0
|
||||||
|
scikit-learn==0.22.1
|
||||||
scipy==1.3.1
|
scipy==1.3.1
|
||||||
six==1.12.0
|
six==1.12.0
|
||||||
sortedcontainers==2.1.0
|
sortedcontainers==2.1.0
|
||||||
@ -45,3 +79,5 @@ typing-extensions==3.7.4
|
|||||||
uritemplate==3.0.0
|
uritemplate==3.0.0
|
||||||
urllib3==1.25.6
|
urllib3==1.25.6
|
||||||
wcwidth==0.1.7
|
wcwidth==0.1.7
|
||||||
|
websockets==7.0
|
||||||
|
zipp==2.1.0
|
||||||
|
Loading…
Reference in New Issue
Block a user